/*
	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_init5,false):window.attachEvent('onload',so_init5);

var d5=document, imgs5 = new Array(), zInterval = null, current5=0, pause=false;

function so_init5()
{
	if(!d5.getElementById || !d5.createElement)return;

	css = d5.createElement('link');
	css.setAttribute('href','slideshow.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d5.getElementsByTagName('head')[0].appendChild(css);

	imgs5 = d5.getElementById('rotator5').getElementsByTagName('img');
	for(i5=1;i5<imgs5.length;i5++) imgs5[i5].xOpacity5 = 0;
	imgs5[0].style.display = 'block';
	imgs5[0].xOpacity5 = .99;

	setTimeout(so_xfade5,5000);
}

function so_xfade5()
{
	cOpacity5 = imgs5[current5].xOpacity5;
	nIndex5 = imgs5[current5+1]?current5+1:0;
	nOpacity5 = imgs5[nIndex5].xOpacity5;

	cOpacity5-=.05;
	nOpacity5+=.05;

	imgs5[nIndex5].style.display = 'block';
	imgs5[current5].xOpacity5 = cOpacity5;
	imgs5[nIndex5].xOpacity5 = nOpacity5;

	setOpacity(imgs5[current5]);
	setOpacity(imgs5[nIndex5]);

	if(cOpacity5<=0)
	{
		imgs5[current5].style.display = 'none';
		current5 = nIndex5;
		setTimeout(so_xfade5,5000);
	}
	else
	{
		setTimeout(so_xfade5,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity5>.99)
		{
			obj.xOpacity5 = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity5;
		obj.style.MozOpacity = obj.xOpacity5;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity5*100) + ')';
	}
}
