//JS per la rotazione delle pubblicita laterali

//matrice con immagini e indirizzi
mPub = new Array(31);
mPub[0]="";
mPub[1]="4.jpg";
mPub[2]="http://www.cavanotizie.it/";
mPub[3]="2.jpg";
mPub[4]="http://www.bussola24.it/";
mPub[5]="3.jpg";
mPub[6]="http://www.hotellalucertola.it/";
mPub[7]="20.jpg";
mPub[8]="http://www.sport2000.it/";
mPub[9]="5.jpg";
mPub[10]="MondoDiFate.htm";
mPub[11]="6.jpg";
mPub[12]="http://www.latavernaanticocorso.it/";
mPub[13]="7.jpg";
mPub[14]="SenatoreArredamenti.htm";
mPub[15]="8.jpg";
mPub[16]="bodyplanet.htm";
mPub[17]="9.jpg";
mPub[18]="Photo01/eventi/dechirico/brochure.PDF";
mPub[19]="10.jpg";
mPub[20]="trefranchising.htm";
mPub[21]="11.jpg";
mPub[22]="http://www.ilcertosino.com/";
mPub[23]="12.jpg";
mPub[24]="http://www.pizzametro.it/";
mPub[25]="13.jpg";
mPub[26]="bottegaapi.htm";
mPub[27]="14.jpg";
mPub[28]="http://www.bioebio.net/";
mPub[29]="15.jpg";
mPub[30]="tonerrigeneration.htm";
mPub[31]="16.jpg";
mPub[32]="http://www.radioamore.it/";
mPub[33]="17.jpg";
mPub[34]="http://www.albertoaccarino.it/index.htm";
mPub[33]="18.jpg";
mPub[34]="http://www.happyfamilies.it/";
mPub[35]="19.jpg";
mPub[36]="http://www.obiettivocavese.it/radio/";
var seeMyScritp = "yes";

function funzioneTest(x){
return  x+1;
};

//lunghezza "effettiva" matrice con immagini e indirizzi
var lunghezza = mPub.length-1;

// genera un numero causale pari
var randomnumber=Math.floor(Math.random() * lunghezza);
if (randomnumber < lunghezza)
 {randomnumber = rendiPari(randomnumber)};

function abbassa(numero)
{
        return (numero  <= lunghezza ?  numero : numero - lunghezza);
}

function rendiPari(numero)
{
    if (isNaN(numero) == false)
    {
        return (numero %2 == 1 ?  numero : numero+1);
    }
    else
    {
        return null;
    }
}

//matrice delle posizioni
mPos = new Array(lunghezza);
mPos[0] = "" ;
for(var i = 1; i <= lunghezza; i++){
	mPos[i] = abbassa(( randomnumber + i + 1 ));
};

//variabile di conteggio dell'inserimento nella pagina
var counterPub = 1;

//funzione che scrive il payload nella pagina
function adver() {
		var stringa	= "<A href='" +  mPub[ mPos[ counterPub +1] ] + "'><IMG src='_Pubb/" + mPub[ mPos[ counterPub ] ] + "' border='0' width='170' heigth='220'></A>";	
		document.write( stringa );
		counterPub = counterPub + 2;
		if ( counterPub > lunghezza - 1 ){ counterPub = 1};
		};

//funzione per il debug
function advert() {
		document.write( counterPub );
		document.write(" - ");
		document.write( mPub[ mPos[ counterPub ] ]);
		document.write(" - ");
		document.write( mPub[ mPos[counterPub + 1] ]);
		document.write("<BR>");
		counterPub = counterPub + 2;
};



