/*
	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,false):window.attachEvent('onload',so_init);

function silentErrorHandler() {return true;}
	
window.onerror=silentErrorHandler;

var d1=document, imgs1 = new Array(), zInterval = null, current=0, pause=false;
var d2=document, imgs2 = new Array(), zInterval2 = null, current2=0, pause=false;  

var s_speed="4000";
var s_speed2="4500";



function so_init()
{
	ss_init1();
	ss_init2();
}

function ss_init1()
{
	 

		if(!d1.getElementById || !d1.createElement)return;	
		css1 = d1.createElement('link');
	
		css1.setAttribute('href','/lib/slideshow-2b.css');
		css1.setAttribute('rel','stylesheet');
		css1.setAttribute('type','text/css');
		d1.getElementsByTagName('head')[0].appendChild(css1);

		imgs1 = d1.getElementById("rotator").getElementsByTagName("img");
		
		for(i=1;i<imgs1.length;i++) imgs1[i].xOpacity = 0;
		imgs1[0].style.display = 'block';
		imgs1[0].xOpacity = .99;
	
		setTimeout(so_xfade,s_speed);
}

function ss_init2()
{
	
		if(!d2.getElementById || !d2.createElement)return;	
		css2 = d2.createElement('link');
	
		css2.setAttribute('href','/lib/slideshow-2b.css');
		css2.setAttribute('rel','stylesheet');
		css2.setAttribute('type','text/css');
		d2.getElementsByTagName('head')[0].appendChild(css2);

		imgs2 = d2.getElementById('rotator2').getElementsByTagName('img');
	
		for(i=1;i<imgs2.length;i++) imgs2[i].xOpacity = 0;
		imgs2[0].style.display = 'block';
		imgs2[0].xOpacity = .99;
	
		setTimeout(so_xfade2,s_speed2);
}

function so_xfade()
{
	cOpacity = imgs1[current].xOpacity;
	nIndex = imgs1[current+1]?current+1:0;
	nOpacity = imgs1[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs1[nIndex].style.display = 'block';
	imgs1[current].xOpacity = cOpacity;
	imgs1[nIndex].xOpacity = nOpacity;

	setOpacity(imgs1[current]);
	setOpacity(imgs1[nIndex]);

	if(cOpacity<=0)
	{
		imgs1[current].style.display = 'none';
		current = nIndex;
		setTimeout(so_xfade,s_speed);
	}
	else
	{
		setTimeout(so_xfade,50);
	}

}

function so_xfade2()
{
	cOpacity2 = imgs2[current2].xOpacity;
	nIndex2 = imgs2[current2+1]?current2+1:0;
	nOpacity2 = imgs2[nIndex2].xOpacity;

	cOpacity2-=.05;
	nOpacity2+=.05;

	imgs2[nIndex2].style.display = 'block';
	imgs2[current2].xOpacity = cOpacity2;
	imgs2[nIndex2].xOpacity = nOpacity2;

	setOpacity(imgs2[current2]);
	setOpacity(imgs2[nIndex2]);

	if(cOpacity2<=0)
	{
		imgs2[current2].style.display = 'none';
		current2 = nIndex2;
		setTimeout(so_xfade2,s_speed);
	}
	else
	{
		setTimeout(so_xfade2,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) + ')';
	}

