//impostazioni
var MaxIMG=3;
var holdingTimeOut=5000;
//end impostazioni
var pos=940;
var timo=0;
var currentImg=2;
var prevImg=1;


function timer(){
	//timo=3;

	var msg_span = document.getElementById("img"+prevImg);
	msg_span.style.backgroundPosition=(pos-940)+"px";
	var msg_span1 = document.getElementById("img"+currentImg);
	msg_span1.style.backgroundPosition=pos+"px";

	if (pos <= 40 || pos >= 900){
		timo=20;
		pos=pos-1;
	}
	else{
		timo=1;
		pos=pos-10;
	}

	if (pos <= 0){
		currentImg=currentImg+1;
		if(currentImg > MaxIMG){
			currentImg=1;
			prevImg=MaxIMG;
		}
		else
			prevImg=currentImg-1;
		
		//alert(currentImg);
		timo=holdingTimeOut;
		pos=940;
	}
	setTimeout("timer()", timo);
}
setTimeout("timer()", holdingTimeOut);

