/*****

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 dt=document, imgtxttxt = new Array(), zInterval = null, tcurrent=0, pause=false;

function so_init() {
	if(!dt.getElementById || !dt.createElement)return;
	
		
	imgtxt = dt.getElementById("txtContainer").getElementsByTagName("p");
	for(i=1;i<imgtxt.length;i++) imgtxt[i].xOpacity = 0;
	imgtxt[0].style.display = "block";
	imgtxt[0].xOpacity = .99;
	
	setTimeout(so_xfadet,5000);
}

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