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

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

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

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

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

	setTimeout(so_xfade_three,4000);
}

function so_xfade_three()
{
	cOpacity3 = imgs3[current3].xOpacity;
	nIndex3 = imgs3[current3+1]?current3+1:0;
	nOpacity3 = imgs3[nIndex3].xOpacity;

	cOpacity3-=.05;
	nOpacity3+=.05;

	imgs3[nIndex3].style.display = 'block';
	imgs3[current3].xOpacity = cOpacity3;
	imgs3[nIndex3].xOpacity = nOpacity3;

	setOpacity(imgs3[current3]);
	setOpacity(imgs3[nIndex3]);

	if(cOpacity3<=0)
	{
		imgs3[current3].style.display = 'none';
		current3 = nIndex3;
		setTimeout(so_xfade_three,3000);
	}
	else
	{
		setTimeout(so_xfade_three,50);
	}

	function setOpacity(obj3)
	{
		if(obj3.xOpacity>.99)
		{
			obj3.xOpacity = .99;
			return;
		}

		obj3.style.opacity = obj3.xOpacity;
		obj3.style.MozOpacity = obj3.xOpacity;
		obj3.style.filter = 'alpha(opacity=' + (obj3.xOpacity*100) + ')';
	}
}
