/*****

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

var d=document, small_imgs = new Array(), zInterval = null, small_current=1, pause=false;

function small_init() {
	if(!d.getElementById || !d.createElement)return;
	
	small_imgs = d.getElementById("thumbleft").getElementsByTagName("img");
	for(i=2;i<small_imgs.length;i++) {
		small_imgs[i].xOpacity = 0;
		small_imgs[i].style.display = 'none';
	}
	small_imgs[1].style.display = "block";
	small_imgs[1].xOpacity = .99;
	setTimeout(small_xfade,1800);
}

function small_xfade() {
	cOpacity = small_imgs[small_current].xOpacity;
	nIndex = small_imgs[small_current+1]?small_current+1:1;
	nOpacity = small_imgs[nIndex].xOpacity;
	
	cOpacity-=.06; 
	nOpacity+=.06;
	
	small_imgs[nIndex].style.display = "block";
	small_imgs[small_current].xOpacity = cOpacity;
	small_imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(small_imgs[small_current]); 
	setOpacity(small_imgs[nIndex]);
	
	if(cOpacity<=0) {
		small_imgs[small_current].style.display = "none";
		small_current = nIndex;
		setTimeout(small_xfade,2500);
	} else {
		setTimeout(small_xfade,60);
	}

	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) + ")";
	}	
}


window.addEventListener?window.addEventListener("load",small_init2,false):window.attachEvent("onload",small_init2);

var d=document, small_imgs2 = new Array(), zInterval = null, small_current2=1, pause=false;

function small_init2() {
	if(!d.getElementById || !d.createElement)return;
	
	small_imgs2 = d.getElementById("thumbright").getElementsByTagName("img");
	for(i=2;i<small_imgs2.length;i++) {
		small_imgs2[i].xOpacity = 0;
		small_imgs2[i].style.display = 'none';
	}
	small_imgs2[1].style.display = "block";
	small_imgs2[1].xOpacity = .99;
	setTimeout(small_xfade2,700);
}

function small_xfade2() {
	cOpacity = small_imgs2[small_current2].xOpacity;
	nIndex = small_imgs2[small_current2+1]?small_current2+1:1;
	nOpacity = small_imgs2[nIndex].xOpacity;
	
	cOpacity-=.06; 
	nOpacity+=.06;
	
	small_imgs2[nIndex].style.display = "block";
	small_imgs2[small_current2].xOpacity = cOpacity;
	small_imgs2[nIndex].xOpacity = nOpacity;
	
	setOpacity(small_imgs2[small_current2]); 
	setOpacity(small_imgs2[nIndex]);
	
	if(cOpacity<=0) {
		small_imgs2[small_current2].style.display = "none";
		small_current2 = nIndex;
		setTimeout(small_xfade2,2500);
	} else {
		setTimeout(small_xfade2,60);
	}

	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) + ")";
	}	
}
