/*
	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;

	css4 = d4.createElement('link');
	css4.setAttribute('href','css/slideshow4.css');
	css4.setAttribute('rel','stylesheet');
	css4.setAttribute('type','text/css');
	d4.getElementsByTagName('head')[0].appendChild(css4);

	imgs4 = d4.getElementById('slideshow4').getElementsByTagName('img');
	for(j=1;j<imgs4.length;j++) imgs4[j].xOpacity = 0;
	imgs4[0].style.display = 'block';
	imgs4[0].xOpacity = .99;

	setTimeout(so_xfade4,2000);
}

function so_xfade4()
{
	cOpacity4 = imgs4[current4].xOpacity;
	nIndex4 = imgs4[current4+1]?current4+1:0;
	nOpacity4 = imgs4[nIndex4].xOpacity;

	cOpacity4-=.05;
	nOpacity4+=.05;

	imgs4[nIndex4].style.display = 'block';
	imgs4[current4].xOpacity = cOpacity4;
	imgs4[nIndex4].xOpacity = nOpacity4;

	setOpacity4(imgs4[current4]);
	setOpacity4(imgs4[nIndex4]);

	if(cOpacity4<=0)
	{
		imgs4[current4].style.display = 'none';
		current4 = nIndex4;
		setTimeout(so_xfade4,4000);
	}
	else
	{
		setTimeout(so_xfade4,50);
	}

	function setOpacity4(obj4)
	{
		if(obj4.xOpacity>.99)
		{
			obj4.xOpacity = .99;
			return;
		}

		obj4.style.opacity = obj4.xOpacity;
		obj4.style.MozOpacity = obj4.xOpacity;
		obj4.style.filter = 'alpha(opacity=' + (obj4.xOpacity*100) + ')';
	}
}
