/*****

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_init2,false):window.attachEvent("onload",so_init2);

var dd=document, imgss = new Array(), zIntervall = null, currentt=0, pausee=false; timeoutt = 6000;

function so_init2() {
	if(!dd.getElementById || !dd.createElement)return;
	
	css = dd.createElement("link");
	css.setAttribute("href","xfade3.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	dd.getElementsByTagName("head")[0].appendChild(css);
	
	imgss = dd.getElementById("bilboard").getElementsByTagName("img");
	for(i=1;i<imgss.length;i++) imgss[i].xOpacity = 0;
	imgss[0].style.display = "block";
	imgss[0].xOpacity = .99;
	
	setTimeout(so_xfade2,timeoutt);
}

function so_xfade2() {
	cOpacity = imgss[currentt].xOpacity;
	nIndex = imgss[currentt+1]?currentt+1:0;
	nOpacity = imgss[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgss[nIndex].style.display = "block";
	imgss[currentt].xOpacity = cOpacity;
	imgss[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgss[currentt]); 
	setOpacity(imgss[nIndex]);
	
	if(cOpacity<=0) {
		imgss[currentt].style.display = "none";
		currentt = nIndex;
		setTimeout(so_xfade2,timeoutt);
	} else {
		setTimeout(so_xfade2,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) + ")";
	}
	
}
