/*
	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',Left_so_init,false):window.attachEvent('onload',Left_so_init);

var dL=document, Limgs = new Array(), zInterval = null, Lcurrent=0, pause=false;

function Left_so_init()
{
	if(!dL.getElementById || !dL.createElement)return;

//	css = d.createElement('link');
//	css.setAttribute('href','L-slides.css');
//	css.setAttribute('rel','stylesheet');
//	css.setAttribute('type','text/css');
//	d.getElementsByTagName('head')[0].appendChild(css);

	Limgs = dL.getElementById('L-slide').getElementsByTagName('img');
	for(iL=1;iL<Limgs.length;iL++) Limgs[iL].LxOpacity = 0;
	Limgs[0].style.display = 'block';
	Limgs[0].LxOpacity = .99;

	setTimeout(Left_so_xfade,5500);
}

function Left_so_xfade()
{
	LcOpacity = Limgs[Lcurrent].LxOpacity;
	LnIndex = Limgs[Lcurrent+1]?Lcurrent+1:0;
	LnOpacity = Limgs[LnIndex].LxOpacity;

	LcOpacity-=.05;
	LnOpacity+=.05;

	Limgs[LnIndex].style.display = 'block';
	Limgs[Lcurrent].LxOpacity = LcOpacity;
	Limgs[LnIndex].LxOpacity = LnOpacity;

	Left_setOpacity(Limgs[Lcurrent]);
	Left_setOpacity(Limgs[LnIndex]);

	if(LcOpacity<=0)
	{
		Limgs[Lcurrent].style.display = 'none';
		Lcurrent = LnIndex;
		setTimeout(Left_so_xfade,3000);
	}
	else
	{
		setTimeout(Left_so_xfade,50);
	}

	function Left_setOpacity(obj)
	{
		if(obj.LxOpacity>.99)
		{
			obj.LxOpacity = .99;
			return;
		}

		obj.style.opacity = obj.LxOpacity;
		obj.style.MozOpacity = obj.LxOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.LxOpacity*100) + ')';
	}
}

