/*
	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_init3,false):window.attachEvent('onload',so_init3);

var d3=document, imgs3 = new Array(), zInterval3 = null, current3=0, pause3=false;

function so_init3()
{
	if(!d3.getElementById || !d3.createElement)return;

	/*css = d3.createElement('link');
	css.setAttribute('href','../css/slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d3.getElementsByTagName('head')[0].appendChild(css);*/

	imgs3 = d3.getElementById('slideshow3').getElementsByTagName('img');
	for(i=1;i<imgs3.length;i++) imgs3[i].xOpacity = 0;
	imgs3[0].style.display = 'block';
	imgs3[0].xOpacity = .99;

	setTimeout(so_xfade3,3500);
}

function so_xfade3()
{
	cOpacity = imgs3[current3].xOpacity;
	nIndex = imgs3[current3+1]?current3+1:0;
	nOpacity = imgs3[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs3[nIndex].style.display = 'block';
	imgs3[current3].xOpacity = cOpacity;
	imgs3[nIndex].xOpacity = nOpacity;

	setOpacity3(imgs3[current3]);
	setOpacity3(imgs3[nIndex]);

	if(cOpacity<=0)
	{
		imgs3[current3].style.display = 'none';
		current3 = nIndex;
		setTimeout(so_xfade3,3500);
	}
	else
	{
		setTimeout(so_xfade3,50);
	}

	function setOpacity3(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) + ')';
	}
}
