/*****

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 d3=document, imgs3 = new Array(), zInterval3 = null, current3=0, pause3=false;

function so_init3() {
	if(!d3.getElementById("imgLeftBox")) return; // makes sure that the box where images should be displayed really exists on the current page (to avoid JS error)
	if(!d3.getElementById || !d.createElement)return;

	// DON'T FORGET TO GRAB THIS FILE AND PLACE IT ON YOUR SERVER IN THE SAME DIRECTORY AS THE JAVASCRIPT!
	// http://slayeroffice.com/code/imageCrossFade/xfade2.css
	css = d3.createElement("link");
	css.setAttribute("href","includes/templates/rgf_antiop2/css/xfade3.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d3.getElementsByTagName("head")[0].appendChild(css);

	imgs3 = d3.getElementById("imgLeftBox").getElementsByTagName("img");
	for(i=1;i<imgs3.length;i++) imgs3[i].xOpacity = 0;
	imgs3[0].style.display = "block";
	imgs3[0].xOpacity = .99;
	
	setTimeout(so_xfade3,3000);
}

function so_xfade3() {
	cOpacity = imgs3[current3].xOpacity;
	nIndex = imgs3[current3+1]?current3+1:0;

	nOpacity = imgs3[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs3[nIndex].style.display = "block";
	imgs3[current3].xOpacity = cOpacity;
	imgs3[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs3[current3]); 
	setOpacity(imgs3[nIndex]);
	
	if(cOpacity<=0) {
		imgs3[current3].style.display = "none";
		current3 = nIndex;
		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) + ")";
	}
	
}

