/**************************************************************************************

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_init1,false):window.attachEvent("onload",so_init1);
var d=document, imgs1 = new Array(), zInterval = null, current1=0, pause=false;

function so_init1() {
	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);

	imgs1 = d.getElementById("mortgages").getElementsByTagName("img");
	for(i=1;i<imgs1.length;i++) imgs1[i].xOpacity1 = 0;
	imgs1[0].style.display = "block";
	imgs1[0].xOpacity1 = .99;
	
	setTimeout(so_xfade1,2100);
}

function so_xfade1() {
	cOpacity1 = imgs1[current1].xOpacity1;
	nIndex1 = imgs1[current1+1]?current1+1:0;

	nOpacity1 = imgs1[nIndex1].xOpacity1;
	
	cOpacity1-=.02; 
	nOpacity1+=.02;
	
	imgs1[nIndex1].style.display = "block";
	imgs1[current1].xOpacity1 = cOpacity1;
	imgs1[nIndex1].xOpacity1 = nOpacity1;
	
	setOpacity1(imgs1[current1]); 
	setOpacity1(imgs1[nIndex1]);
	
	if(cOpacity1<=0) {
		imgs1[current1].style.display = "none";
		current1 = nIndex1;
		setTimeout(so_xfade1,2000);
	} else {
		setTimeout(so_xfade1,50);
	}
	
	function setOpacity1(obj1) {
		if(obj1.xOpacity1>.99) {
			obj1.xOpacity1 = .99;
			return;
		}
		obj1.style.opacity = obj1.xOpacity1;
		obj1.style.MozOpacity = obj1.xOpacity1;
		obj1.style.filter = "alpha(opacity=" + (obj1.xOpacity1*100) + ")";
	}
}
