/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/


window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	css = d.createElement("link");
	css.setAttribute("href","/css/xfade2.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);

	imgs = d.getElementById("imageContainer").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;
	
	setTimeout(so_xfade,1000);
}

function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,5000);
	} else {
		setTimeout(so_xfade,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}


/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/


window.addEventListener?window.addEventListener("load",so_init_2,false):window.attachEvent("onload",so_init_2);

var docs=document, divs = new Array(), zIntervals = null, currents=0, pauses=false;

function so_init_2() {
	if(!docs.getElementById || !docs.createElement)return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	css2 = docs.createElement("link");
	css2.setAttribute("href","/css/xfade2.css");
	css2.setAttribute("rel","stylesheet");
	css2.setAttribute("type","text/css");
	docs.getElementsByTagName("head")[0].appendChild(css2);

	divs = docs.getElementById("prodotto_1").getElementsByTagName("div");
	for(i=1;i<divs.length;i++) divs[i].xOpacity = 0;
	divs[0].style.display = "block";
	divs[0].xOpacity = .99;
	
	setTimeout(so_xfade_2,3000);
}

function so_xfade_2() {
	cOpacity = divs[currents].xOpacity;
	nIndex = divs[currents+1]?currents+1:0;

	nOpacity = divs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	divs[nIndex].style.display = "block";
	divs[currents].xOpacity = cOpacity;
	divs[nIndex].xOpacity = nOpacity;
	
	setOpacity(divs[currents]); 
	setOpacity(divs[nIndex]);
	
	if(cOpacity<=0) {
		divs[currents].style.display = "none";
		currents = nIndex;
		setTimeout(so_xfade_2,3000);
	} else {
		setTimeout(so_xfade_2,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}


/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/


window.addEventListener?window.addEventListener("load",so_init_3,false):window.attachEvent("onload",so_init_3);

var doc_3=document, divs_3 = new Array(), zIntervals_3 = null, currents_3=0, pauses_3=false;

function so_init_3() {
	if(!doc_3.getElementById || !doc_3.createElement)return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	css3 = doc_3.createElement("link");
	css3.setAttribute("href","xfade2.css");
	css3.setAttribute("rel","stylesheet");
	css3.setAttribute("type","text/css");
	doc_3.getElementsByTagName("head")[0].appendChild(css3);

	divs_3 = doc_3.getElementById("prodotto_2").getElementsByTagName("div");
	for(i=1;i<divs_3.length;i++) divs_3[i].xOpacity = 0;
	divs_3[0].style.display = "block";
	divs_3[0].xOpacity = .99;
	
	setTimeout(so_xfade_3,6000);
}

function so_xfade_3() {
	cOpacity = divs_3[currents_3].xOpacity;
	nIndex = divs_3[currents_3+1]?currents_3+1:0;

	nOpacity = divs_3[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	divs_3[nIndex].style.display = "block";
	divs_3[currents_3].xOpacity = cOpacity;
	divs_3[nIndex].xOpacity = nOpacity;
	
	setOpacity(divs_3[currents_3]); 
	setOpacity(divs_3[nIndex]);
	
	if(cOpacity<=0) {
		divs_3[currents_3].style.display = "none";
		currents_3 = nIndex;
		setTimeout(so_xfade_3,3000);
	} else {
		setTimeout(so_xfade_3,50);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}