// JavaScript Document
function init(){
	g1=document.getElementById("gallery_contenuto");
	g2=document.getElementById("gallery_contenuto2");
	lunghezza=g2.style.width;
	lg=parseInt(lunghezza.split("px")[0]);
	//alert (lunghezza.split("px")[0]);
	v=1;
	x=0;
	stop=0;
	quale=1;
	direzione="sx";
}
function vai() {
	if (!stop && lg>595) {
		if (direzione=="sx") {
			x-=v;
		} else {
			x+=v;
		}
		x2=x+lg;
		//alert (x2);
		if (x2>0 && x<=0) {  //se x2 è maggiore di zero il pezzo sinistro è visibile in parte
			g1.style.left=x+"px";
			g2.style.left=x2+"px";
		} else {
			//alert(lg);
			gx=g1;
			g1=g2;
			g2=gx;
			if (direzione=="sx"){
				x=0;
				x2=lg;
			} else {
				x=-lg;
				x2=0;
			}
			//g1.style.left=lg+"px";
			//g2.style.left="0";
		}
		setTimeout('vai()',10);//500-g.widthg.style.left>-500
	}
}
function dir(nuova_dir) {
	if (nuova_dir!=direzione) direzione=nuova_dir;
}
function frena_sx() {
	stop=1;
}
function vai_dx() {
	if (!stop) {
		x+=v;
		x2=x+lg;
		alert (x2);
		if (x2<0) {
			g1.style.left=x+"px";
			g2.style.left=x2+"px";
		} else {
			alert(lg);
			gx=g1;
			g1=g2;
			g2=gx;
			x=0;
			x2=lg;
			//g1.style.left=lg+"px";
			//g2.style.left="0";
		}
		setTimeout('vai_dx()',10);//500-g.widthg.style.left>-500
	}
}
function frena_dx() {
	stop=1;
}
