/*****

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 da=document, imgsa = new Array(), zInterval = null, acurrent=0, pause=false;

function so_init() {
	if(!da.getElementById || !d.createElement)return;
	
	
	
	imgsa = da.getElementById("imageContainerads").getElementsByTagName("img");
	for(i=1;i<imgsa.length;i++) imgsa[i].xOpacity = 0;
	imgsa[0].style.display = "block";
	imgsa[0].xOpacity = .99;
	
	setTimeout(so_xfadea,5000);
}

function so_xfadea() {
	cOpacity = imgsa[acurrent].xOpacity;
	anIndex = imgsa[acurrent+1]?acurrent+1:0;
	nOpacity = imgsa[anIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgsa[anIndex].style.display = "block";
	imgsa[acurrent].xOpacity = cOpacity;
	imgsa[anIndex].xOpacity = nOpacity;
	
	setOpacity(imgsa[acurrent]); 
	setOpacity(imgsa[anIndex]);
	
	if(cOpacity<=0) {
		imgsa[acurrent].style.display = "none";
		acurrent = anIndex;
		setTimeout(so_xfadea,5000);
	} else {
		setTimeout(so_xfadea,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) + ")";
	}
	
}