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

var d_right=document, imgs_right = new Array(), zInterval_right = null, current_right=0, pause_right=false;

function so_init_right()
{
	if(!d_right.getElementById || !d_right.createElement)return;

	imgs_right = d_right.getElementById('rotator_right').getElementsByTagName('img');
	for(i=1;i<imgs_right.length;i++) imgs_right[i].xOpacity = 0;
	imgs_right[0].style.display = 'block';
	imgs_right[0].xOpacity = .99;

	setTimeout(so_xfade_right,6000);
}

function so_xfade_right()
{
	cOpacity_right = imgs_right[current_right].xOpacity;
	nIndex_right = imgs_right[current_right+1]?current_right+1:0;
	nOpacity_right = imgs_right[nIndex_right].xOpacity;

	cOpacity_right-=.05;
	nOpacity_right+=.05;

	imgs_right[nIndex_right].style.display = 'block';
	imgs_right[current_right].xOpacity = cOpacity_right;
	imgs_right[nIndex_right].xOpacity = nOpacity_right;

	setOpacity_right(imgs_right[current_right]);
	setOpacity_right(imgs_right[nIndex_right]);

	if(cOpacity_right<=0)
	{
		imgs_right[current_right].style.display = 'none';
		current_right = nIndex_right;
		setTimeout(so_xfade_right,6000);
	}
	else
	{
		setTimeout(so_xfade_right,50);
	}

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