/*
	Image Cross Fade Redux
	Version 1.0
	Last revision: 02.15.2006
	steve@slayeroffice.com

	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(), zInterval = null, current3=0, pause=false;

function so_init3()
{
	if(!d3.getElementById || !d3.createElement)return;

	css = d3.createElement('link');
	css.setAttribute('href','slideshow.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d3.getElementsByTagName('head')[0].appendChild(css);

	imgs3 = d3.getElementById('rotator3').getElementsByTagName('img');
	for(i3=1;i3<imgs3.length;i3++) imgs3[i3].xOpacity3 = 0;
	imgs3[0].style.display = 'block';
	imgs3[0].xOpacity3 = .99;

	setTimeout(so_xfade3,3000);
}

function so_xfade3()
{
	cOpacity3 = imgs3[current3].xOpacity3;
	nIndex3 = imgs3[current3+1]?current3+1:0;
	nOpacity3 = imgs3[nIndex3].xOpacity3;

	cOpacity3-=.05;
	nOpacity3+=.05;

	imgs3[nIndex3].style.display = 'block';
	imgs3[current3].xOpacity3 = cOpacity3;
	imgs3[nIndex3].xOpacity3 = nOpacity3;

	setOpacity(imgs3[current3]);
	setOpacity(imgs3[nIndex3]);

	if(cOpacity3<=0)
	{
		imgs3[current3].style.display = 'none';
		current3 = nIndex3;
		setTimeout(so_xfade3,3000);
	}
	else
	{
		setTimeout(so_xfade3,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity3>.99)
		{
			obj.xOpacity3 = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity3;
		obj.style.MozOpacity = obj.xOpacity3;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity3*100) + ')';
	}
}
