var currentPhoto = 0;
var secondPhoto = 1;

var currentOpacity = new Array();
//var imageArray = new Array("img1.jpg","img2.jpg","img3.jpg","img4.jpg","img5.jpg","img6.jpg","img7.jpg","img8.jpg");

var FADE_STEP = 1;
var FADE_INTERVAL = 50;
var FADE_PAUSE = 5000;
var pause = false;
/*
.mPhoto {
	position:absolute; top:0px;	left:0px; -moz-opacity:0.0;	filter:Alpha(opacity=0);
}
*/
function effetua_fade(numero_uno,numero_due) {
	currentPhoto=numero_uno;
	secondPhoto=numero_due;
	currentOpacity[numero_uno]=99;
	currentOpacity[numero_due]=0;
	mHTML="";
	for(i=0;i<imageArray.length;i++)
	{
		mHTML+="<div id=\"photo\" name=\"photo\" class=\"mPhoto\" style=\"position:absolute; top:0px;	left:0px; -moz-opacity:0.0;	filter:Alpha(opacity=0);\"><img height=\"260\" width=\"752\" style=\"zindex:1;\" src=\"images/" + imageArray[i]  +"\"></div>";
	}
	alert(mHTML);
	document.getElementById("singolo_div_scroll").innerHTML = document.getElementById("singolo_div_scroll").innerHTML + mHTML;

	if(document.all) {
		document.getElementsByName("photo")[currentPhoto].style.filter="alpha(opacity=100)";
	} else {
		document.getElementsByName("photo")[currentPhoto].style.MozOpacity = .99;
	}
	setTimeout("crossFade()",FADE_PAUSE);
}
/*
function start()
{
	mInterval = setTimeout("crossFade()",FADE_INTERVAL);
}*/
function crossFade() {
	

	currentOpacity[currentPhoto]-=FADE_STEP;
	currentOpacity[secondPhoto] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity[currentPhoto] + ")";
		document.getElementsByName("photo")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity[secondPhoto] + ")";
	} else {
		document.getElementsByName("photo")[currentPhoto].style.MozOpacity = currentOpacity[currentPhoto]/100;
		document.getElementsByName("photo")[secondPhoto].style.MozOpacity =currentOpacity[secondPhoto]/100;
	}

	if(currentOpacity[secondPhoto]/100>=.98) {
		currentPhoto = secondPhoto;
		secondPhoto++;
		if(secondPhoto == imageArray.length)secondPhoto=0;
		pause = true;
		xInterval = setTimeout("pause=false",FADE_PAUSE);
	}
}
/*
function doPause()  {
	if(pause) {
		pause = false;
		document.getElementById("pauseBtn").value = "pause";
	} else {
		pause = true;
		document.getElementById("pauseBtn").value = "play";
	}
}*/
