var x = 0;
var y = 0;

// Array nel quale inserire gli url delle varie immagini che si desiderano far alternare. Si possono aggiungere quanti url si vogliono
immages = new Array();
immages[0]='img/pubblicita/pennella_sm.gif';
immages[1]='img/pubblicita/blank.gif';
immages[2]='img/pubblicita/alinormanne_sm.gif';
immages[3]='img/pubblicita/201110Unicef_sm.gif';

links = new Array();
links[0]='img/pubblicita/pennella.gif';
links[1]='';
links[2]='img/pubblicita/alinormanne.gif';
links[3]='img/pubblicita/201110Unicef.gif';

var velocita = 1;
var ritorno = 0;
var elePub = Math.round((immages.length-1)*Math.random());

function muoviImmagine() {

var dest_y = 0;
var dest_x = 0;

var interval_y = velocita;
var img = document.getElementById('leftBanner');
var imgHeight = img.offsetHeight;
var imgWidth = img.offsetWidth;

if (self.innerHeight){dest_y = self.innerHeight;dest_x = self.innerWidth;}
else if (document.documentElement && document.documentElement.clientHeight){
	 			dest_y = document.documentElement.clientHeight;
				dest_x = document.documentElement.clientWidth;
				}
				else if (document.body){
						dest_y = document.body.clientHeight;
						dest_x = document.body.clientWidth;
						}

if((y<dest_y-imgHeight) && ritorno == 0){
			if((y + interval_y > dest_y-imgHeight)){y = dest_y - imgHeight;}
			else{y = y + interval_y;}
			if(y==dest_y-imgHeight){ritorno = 1;elePub++;}
			}
else if(y>0){
	if(y - interval_y < 0){y = 0;}
	else{y = y - interval_y;}
	if(y==0){ritorno = 0;elePub++;}
	}
if (elePub>=immages.length) {elePub=0;}
document.getElementById("leftBanner").style.top = y+'px';
document.getElementById("leftBannerIMG").style.width = ((dest_x-662)/2)+'px';
document.getElementById("leftBannerIMG").src = immages[elePub];
document.getElementById("leftBannerLNK").href = links[elePub];
window.setTimeout("muoviImmagine()",1);
}

