

/* Source: */
/*****

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


*****/
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.10; 
	nOpacity+=.10;
	
	if (nIndex == 0)
		imgs[nIndex].style.visibility = "visible";
	else
		imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		if (current == 0)
			imgs[current].style.visibility = "hidden";
		else
			imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,5000);
	} else {
		setTimeout(so_xfade,100);
	}
	
	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) + ")";
	}
	
}

function fadeAll()
{
	var ic = d.getElementById("image-container");
	if (ic == null) return;
	imgs = ic.getElementsByTagName("img");
	if (imgs.length > 1)
	{
		/* Se nao for IE saímos, porque fica muito lento */
		ic.style.width = imgs[0].style.width;
		for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
		imgs[0].xOpacity = .99;
		
		setTimeout(so_xfade,5000);
	}
}

//window.onload = rotateAll;
addLoadEvent(fadeAll);

