/*****

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);

a_tags = new Array(), zInterval = null, current=0, pause=false;
a_tags2 = new Array(), zInterval = null, current2=0, pause=false;
/*  a_tags3 = new Array(), zInterval = null, current3=0, pause=false;  */

function so_init() {
	if(!document.getElementById || !document.createElement)return;
 
	a_tags = document.getElementById("imageContainer").getElementsByTagName("a");
	for(i=1;i<a_tags.length;i++) a_tags[i].xOpacity = 0;
	a_tags[0].style.display = "block";
	a_tags[0].xOpacity = .99;
    
	setTimeout(so_xfade,3000);    


	a_tags2 = document.getElementById("imageContainer2").getElementsByTagName("a");
	for(i=1;i<a_tags2.length;i++) a_tags2[i].xOpacity = 0;
	a_tags2[0].style.display = "block";
	a_tags2[0].xOpacity = .99;

	
	setTimeout(so_xfade2,3000);
	
	/*
	a_tags3 = document.getElementById("imageContainer3").getElementsByTagName("a");
	for(i=1;i<a_tags3.length;i++) a_tags3[i].xOpacity = 0;
	a_tags3[0].style.display = "block";
	a_tags3[0].xOpacity = .99;

	
	setTimeout(so_xfade3,3000);	
    */
}

function so_xfade() {

	cOpacity = a_tags[current].xOpacity;
	nIndex = a_tags[current+1]?current+1:0;

	nOpacity = a_tags[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;

	a_tags[nIndex].style.display = "block";
	a_tags[current].xOpacity = cOpacity;
	a_tags[nIndex].xOpacity = nOpacity;
	
	setOpacity(a_tags[current]); 
	setOpacity(a_tags[nIndex]);
	
	if(cOpacity<=0) {
		a_tags[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,3000);
	} else {
		setTimeout(so_xfade,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) + ")";
	}
	
}

function so_xfade2() {

	cOpacity = a_tags2[current2].xOpacity;
	nIndex2 = a_tags2[current2+1]?current2+1:0;

	nOpacity = a_tags2[nIndex2].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;

	a_tags2[nIndex2].style.display = "block";
	a_tags2[current2].xOpacity = cOpacity;
	a_tags2[nIndex2].xOpacity = nOpacity;
	
	setOpacity(a_tags2[current2]); 
	setOpacity(a_tags2[nIndex2]);
	
	if(cOpacity<=0) {
		a_tags2[current2].style.display = "none";
		current2 = nIndex2;
		setTimeout(so_xfade2,3000);
	} else {
		setTimeout(so_xfade2,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) + ")";
	}
	
}
/*
function so_xfade3() {

	cOpacity = a_tags3[current3].xOpacity;
	nIndex2 = a_tags3[current3+1]?current3+1:0;

	nOpacity = a_tags3[nIndex3].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;

	a_tags3[nIndex3].style.display = "block";
	a_tags3[current3].xOpacity = cOpacity;
	a_tags3[nIndex3].xOpacity = nOpacity;
	
	setOpacity(a_tags3[current3]); 
	setOpacity(a_tags3[nIndex3]);
	
	if(cOpacity<=0) {
		a_tags3[current3].style.display = "none";
		current3 = nIndex3;
		setTimeout(so_xfade3,3000);
	} else {
		setTimeout(so_xfade3,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) + ")";
	}
	
}  */