/*
	Image Cross Fade Redux
	Version 1.0
	Last revision: 04.15.4006
	steve@slayeroffice.com

	Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*/

window.addEventListener?window.addEventListener('load',so_init4,false):window.attachEvent('onload',so_init4);

var d4=document, imgs4 = new Array(), zInterval = null, current4=0, pause=false;

function so_init4()
{
	if(!d4.getElementById || !d4.createElement)return;

	css = d4.createElement('link');
	css.setAttribute('href','slideshow.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d4.getElementsByTagName('head')[0].appendChild(css);

	imgs4 = d4.getElementById('rotator4').getElementsByTagName('img');
	for(i4=1;i4<imgs4.length;i4++) imgs4[i4].xOpacity4 = 0;
	imgs4[0].style.display = 'block';
	imgs4[0].xOpacity4 = .99;

	setTimeout(so_xfade4,4000);
}

function so_xfade4()
{
	cOpacity4 = imgs4[current4].xOpacity4;
	nIndex4 = imgs4[current4+1]?current4+1:0;
	nOpacity4 = imgs4[nIndex4].xOpacity4;

	cOpacity4-=.05;
	nOpacity4+=.05;

	imgs4[nIndex4].style.display = 'block';
	imgs4[current4].xOpacity4 = cOpacity4;
	imgs4[nIndex4].xOpacity4 = nOpacity4;

	setOpacity(imgs4[current4]);
	setOpacity(imgs4[nIndex4]);

	if(cOpacity4<=0)
	{
		imgs4[current4].style.display = 'none';
		current4 = nIndex4;
		setTimeout(so_xfade4,4000);
	}
	else
	{
		setTimeout(so_xfade4,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity4>.99)
		{
			obj.xOpacity4 = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity4;
		obj.style.MozOpacity = obj.xOpacity4;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity4*100) + ')';
	}
}
