/*****

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

var d=document, imgs_n = new Array(), current_n=0;

function so_init_n() {
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement("link");
	css.setAttribute("href","xfade_n.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);

	imgs_n = d.getElementById("images_n").getElementsByTagName("img");
	for(i=1;i<imgs_n.length;i++) imgs_n[i].xOpacity = 0;
	imgs_n[0].style.display = "block";
	imgs_n[0].xOpacity = .99;
	
	setTimeout(so_xfade_n,5000);
}

function so_xfade_n() {
	cOpacity = imgs_n[current_n].xOpacity;
	nIndex = imgs_n[current_n+1]?current_n+1:0;

	nOpacity = imgs_n[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs_n[nIndex].style.display = "block";
	imgs_n[current_n].xOpacity = cOpacity;
	imgs_n[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs_n[current_n]); 
	setOpacity(imgs_n[nIndex]);
	
	if(cOpacity<=0) {
		imgs_n[current_n].style.display = "none";
		current_n = nIndex;
		setTimeout(so_xfade_n,5000);
	} else {
		setTimeout(so_xfade_n,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) + ")";
	}
	
}
