/*
	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_init4,false):window.attachEvent('onload',so_init4);

var d4=document, imgs4 = new Array(), zInterval4 = null, current4=0, pause4=false;

function so_init4()
{
	if(!d4.getElementById || !d4.createElement)return;

	css = d4.createElement('link');
	css.setAttribute('href','slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d4.getElementsByTagName('head')[0].appendChild(css);

	imgs4 = d4.getElementById('rotator4').getElementsByTagName('img');
	for(i=1;i<imgs4.length;i++) imgs4[i].xOpacity = 0;
	imgs4[0].style.display = 'block';
	imgs4[0].xOpacity = .99;

	setTimeout(so_xfade4,5000);
}

function so_xfade4()
{
	cOpacity = imgs4[current4].xOpacity;
	nIndex = imgs4[current4+1]?current4+1:0;
	nOpacity = imgs4[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs4[nIndex].style.display = 'block';
	imgs4[current4].xOpacity = cOpacity;
	imgs4[nIndex].xOpacity = nOpacity;

	setOpacity(imgs4[current4]);
	setOpacity(imgs4[nIndex]);

	if(cOpacity<=0)
	{
		imgs4[current4].style.display = 'none';
		current4 = nIndex;
		setTimeout(so_xfade4,7000);
	}
	else
	{
		setTimeout(so_xfade4,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) + ')';
	}
}