

// funzione per scroll contenuti

var y=0;    // spostamento verticale
var x=0;    // spostamento orizzontale
var inizio=0;   // posizione iniziale del testo in pixel
var attesa=10;  // millisecondi di attesa 
var fine;   // posizione finale del testo
var pos=inizio; // variabile corrente che memorizza la posizione
var globalContId; //id del box che si vuole muovere
var globalMaschId; //id del box maschera
var vel=2 // velocità scorrimento in px

function muovi(contId, maschId) {
	if (x==0 && y!=0){
		if(contId){
			globalContId = contId;
			globalMaschId = maschId;
		}
		var hCont = document.getElementById(globalContId).offsetHeight;
		var hMasch = document.getElementById(globalMaschId).offsetHeight;
		var fine = (hMasch - hCont);
		var pos = Number(document.getElementById(globalContId).style.top.replace('px',''));
		if ( ( (pos<=fine)&&(y==-vel) )||( (pos>=inizio)&&(y==vel) ) ) y=0;
		pos=pos+y;
		document.getElementById(globalContId).style.top=pos+'px';
		if (y!=0) setTimeout('muovi();',attesa);
	} else if (y==0 && x!=0) {
		var pos = Number(document.getElementById(globalContId).style.left.replace('px',''));
		if ( ( (pos<=fine)&&(x==-vel) )||( (pos>=inizio)&&(x==vel) ) ) x=0;
		pos=pos+x;
		document.getElementById(globalContId).style.left=pos+'px';
		if (x!=0) setTimeout('muovi();',attesa);
	}
}
