/**************************************************************************************

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_init3,false):window.attachEvent("onload",so_init3);
var d=document, imgs3 = new Array(), zInterval = null, current3=0, pause=false;

function so_init3() {
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement("link");
	css.setAttribute("href","../css/xfade.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);

	imgs3 = d.getElementById("insurance").getElementsByTagName("img");
	for(i=1;i<imgs3.length;i++) imgs3[i].xOpacity3 = 0;
	imgs3[0].style.display = "block";
	imgs3[0].xOpacity3 = .99;
	
	setTimeout(so_xfade3,1000);
}

function so_xfade3() {
	cOpacity3 = imgs3[current3].xOpacity3;
	nIndex3 = imgs3[current3+1]?current3+1:0;

	nOpacity3 = imgs3[nIndex3].xOpacity3;
	
	cOpacity3-=.03; 
	nOpacity3+=.03;
	
	imgs3[nIndex3].style.display = "block";
	imgs3[current3].xOpacity3 = cOpacity3;
	imgs3[nIndex3].xOpacity3 = nOpacity3;
	
	setOpacity3(imgs3[current3]); 
	setOpacity3(imgs3[nIndex3]);
	
	if(cOpacity3<=0) {
		imgs3[current3].style.display = "none";
		current3 = nIndex3;
		setTimeout(so_xfade3,3300);
	} else {
		setTimeout(so_xfade3,50);
	}
	
	function setOpacity3(obj3) {
		if(obj3.xOpacity3>.99) {
			obj3.xOpacity3 = .99;
			return;
		}
		obj3.style.opacity = obj3.xOpacity3;
		obj3.style.MozOpacity = obj3.xOpacity3;
		obj3.style.filter = "alpha(opacity=" + (obj3.xOpacity3*100) + ")";
	}
}
