/*****

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

var d=document, imgsA = new Array(), zInterval = null, currentA=0, pause=false;

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

	css = d.createElement("link");
	css.setAttribute("href","xfade2a.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);


        imgsA = d.getElementById("imageContainerA").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,8000);
}

function so_xfadeA() {
	cOpacity = imgsA[currentA].xOpacity;
	nIndex = imgsA[currentA+1]?currentA+1:0;

	nOpacity = imgsA[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgsA[nIndex].style.display = "block";
	imgsA[currentA].xOpacity = cOpacity;
	imgsA[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgsA[currentA]);
	setOpacity(imgsA[nIndex]);
	
	if(cOpacity<=0) {
		imgsA[currentA].style.display = "none";
		currentA = nIndex;
		setTimeout(so_xfadeA,8000);
	} 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) + ")";
	}
	
}
