// JavaScript Document

// SLIDE SHOW CODE
/*
	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_banner,false):window.attachEvent('onload',so_init_banner);

var dd=document, imgs_banner = new Array(), zInterval = null, current_banner=0, pause=false;

function so_init_banner()
{
	if(!dd.getElementById || !dd.createElement)return;

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

	imgs_banner = dd.getElementById('rotator_banner').getElementsByTagName('img');
	for(i=1;i<imgs_banner.length;i++) imgs_banner[i].xOpacity = 0;
	imgs_banner[0].style.display = 'block';
	imgs_banner[0].xOpacity = .99;

	setTimeout(so_xfade_banner,3000);
}

function so_xfade_banner()
{
	cOpacity = imgs_banner[current_banner].xOpacity;
	nIndex = imgs_banner[current_banner+1]?current_banner+1:0;
	nOpacity = imgs_banner[nIndex].xOpacity;

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

	imgs_banner[nIndex].style.display = 'block';
	imgs_banner[current_banner].xOpacity = cOpacity;
	imgs_banner[nIndex].xOpacity = nOpacity;

	setOpacity_banner(imgs_banner[current_banner]);
	setOpacity_banner(imgs_banner[nIndex]);

	if(cOpacity<=0)
	{
		imgs_banner[current_banner].style.display = 'none';
		current_banner = nIndex;
		setTimeout(so_xfade_banner,3000);
	}
	else
	{
		setTimeout(so_xfade_banner,50);
	}

	function setOpacity_banner(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) + ')';
	}
}
// END SLIDE SHOW