window.addEventListener?window.addEventListener('load',so_initRoll,false):window.attachEvent('onload',so_initRoll);

var d=document, imgs1b = new Array(), imgs2b = new Array(), imgs3b = new Array(), zInterval = null, current1b=0, current2b=0, current3b=0, pause=false;

function so_initRoll()
{
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement('link');
	css.setAttribute('href','scripts/slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);
	
	imgs1b = d.getElementById('slideshow1b').getElementsByTagName('img');
	imgs2b = d.getElementById('slideshow2b').getElementsByTagName('img');	
	imgs3b = d.getElementById('slideshow3b').getElementsByTagName('img');	
	
	for(i=1;i<imgs1b.length;i++) 
	imgs1b[i].xOpacity = 0;
	imgs1b[0].style.display = 'block';
	imgs1b[0].xOpacity = .99;

	for(i=1;i<imgs2b.length;i++) 
	imgs2b[i].xOpacity = 0;
	imgs2b[0].style.display = 'block';
	imgs2b[0].xOpacity = .99;


	for(i=1;i<imgs3b.length;i++) 
	imgs3b[i].xOpacity = 0;
	imgs3b[0].style.display = 'block';
	imgs3b[0].xOpacity = .99;

	setTimeout(so_xfade1b,3000);
	setTimeout(so_xfade2b,3500);
	setTimeout(so_xfade3b,4000);
}


function so_xfade1b()
{
	cOpacity1b = imgs1b[current1b].xOpacity;
	nIndex1b = imgs1b[current1b+1]?current1b+1:0;
	nOpacity1b = imgs1b[nIndex1b].xOpacity;

	cOpacity1b-=.05;
	nOpacity1b+=.05;

	imgs1b[nIndex1b].style.display = 'block';
	imgs1b[current1b].xOpacity = cOpacity1b;
	imgs1b[nIndex1b].xOpacity = nOpacity1b;

	setOpacity1b(imgs1b[current1b]);
	setOpacity1b(imgs1b[nIndex1b]);

	if(cOpacity1b<=0)
	{
		imgs1b[current1b].style.display = 'none';
		current1b = nIndex1b;
		setTimeout(so_xfade1b,3000);
	}
	else
	{
		setTimeout(so_xfade1b,50);
	}

	function setOpacity1b(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) + ')';
	}
}

function so_xfade2b()
{
	cOpacity2b = imgs2b[current2b].xOpacity;
	nIndex2b = imgs2b[current2b+1]?current2b+1:0;
	nOpacity2b = imgs2b[nIndex2b].xOpacity;

	cOpacity2b-=.05;
	nOpacity2b+=.05;

	imgs2b[nIndex2b].style.display = 'block';
	imgs2b[current2b].xOpacity = cOpacity2b;
	imgs2b[nIndex2b].xOpacity = nOpacity2b;

	setOpacity2b(imgs2b[current2b]);
	setOpacity2b(imgs2b[nIndex2b]);

	if(cOpacity2b<=0)
	{
		imgs2b[current2b].style.display = 'none';
		current2b = nIndex2b;
		setTimeout(so_xfade2b,3500);
	}
	else
	{
		setTimeout(so_xfade2b,50);
	}

	function setOpacity2b(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) + ')';
	}
}

function so_xfade3b()
{
	cOpacity3b = imgs3b[current3b].xOpacity;
	nIndex3b = imgs3b[current3b+1]?current3b+1:0;
	nOpacity3b = imgs3b[nIndex3b].xOpacity;

	cOpacity3b-=.05;
	nOpacity3b+=.05;

	imgs3b[nIndex3b].style.display = 'block';
	imgs3b[current3b].xOpacity = cOpacity3b;
	imgs3b[nIndex3b].xOpacity = nOpacity3b;

	setOpacity3b(imgs3b[current3b]);
	setOpacity3b(imgs3b[nIndex3b]);

	if(cOpacity3b<=0)
	{
		imgs3b[current3b].style.display = 'none';
		current3b = nIndex3b;
		setTimeout(so_xfade3b,4000);
	}
	else
	{
		setTimeout(so_xfade3b,50);
	}

	function setOpacity3b(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) + ')';
	}
}
