/*
	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);

var d=document, imgsh, imgsv, zInterval = null, currenth, currentv, pause=false, th, tv;
var imgshfix1, currenthfix1, thfix1;
var imgshfix2, currenthfix2, thfix2;
var imgshfix3, currenthfix3, thfix3;
var imgsh0, currenth0, th0;
var imgsh1, currenth1, th1;
var imgsh2, currenth2, th2;
var imgsh3, currenth3, th3;
var imgsh4, currenth4, th4;
var imgsh5, currenth5, th5;
var imgsh6, currenth6, th6;
var imgsh7, currenth7, th7;
var imgsh8, currenth8, th8;
var imgsh9, currenth9, th9;

function so_init()
{
	if(!d.getElementById || !d.createElement) return;

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

	if (d.getElementById('rotator'))
	{
		currenth = 0;
		clearTimeout(th);
		imgsh = new Array();
		imgsh = d.getElementById('rotator').getElementsByTagName('img');
		for(i=1;i<imgsh.length;i++) imgsh[i].xOpacity = 0;
		imgsh[0].style.display = 'block';
		imgsh[0].xOpacity = .99;

		th = setTimeout("so_xfade()",0000);
	}
	if (d.getElementById('rotatorfix1'))
	{
		currenthfix1 = 0;
		clearTimeout(thfix1);
		imgshfix1 = new Array();
		imgshfix1 = d.getElementById('rotatorfix1').getElementsByTagName('img');
		for(i=1;i<imgshfix1.length;i++) imgshfix1[i].xOpacity = 0;
		imgshfix1[0].style.display = 'block';
		imgshfix1[0].xOpacity = .99;

		thfix1 = setTimeout("so_xfadefix1()",0000);
	}
	if (d.getElementById('rotatorfix2'))
	{
		currenthfix2 = 0;
		clearTimeout(thfix2);
		imgshfix2 = new Array();
		imgshfix2 = d.getElementById('rotatorfix2').getElementsByTagName('img');
		for(i=1;i<imgshfix2.length;i++) imgshfix2[i].xOpacity = 0;
		imgshfix2[0].style.display = 'block';
		imgshfix2[0].xOpacity = .99;

		thfix2 = setTimeout("so_xfadefix2()",0000);
	}
	if (d.getElementById('rotatorfix3'))
	{
		currenthfix3 = 0;
		clearTimeout(thfix3);
		imgshfix3 = new Array();
		imgshfix3 = d.getElementById('rotatorfix3').getElementsByTagName('img');
		for(i=1;i<imgshfix3.length;i++) imgshfix3[i].xOpacity = 0;
		imgshfix3[0].style.display = 'block';
		imgshfix3[0].xOpacity = .99;

		thfix3 = setTimeout("so_xfadefix3()",0000);
	}
	if (d.getElementById('rotatorsmall0'))
	{
		currenth0 = 0;
		clearTimeout(th0);
		imgsh0 = new Array();
		imgsh0 = d.getElementById('rotatorsmall0').getElementsByTagName('img');
		for(i=1;i<imgsh0.length;i++) imgsh0[i].xOpacity = 0;
		imgsh0[0].style.display = 'block';
		imgsh0[0].xOpacity = .99;

		th0 = setTimeout("so_xfade0()",0000);
	}
	if (d.getElementById('rotatorsmall1'))
	{
		currenth1 = 0;
		clearTimeout(th1);
		imgsh1 = new Array();
		imgsh1 = d.getElementById('rotatorsmall1').getElementsByTagName('img');
		for(i=1;i<imgsh1.length;i++) imgsh1[i].xOpacity = 0;
		imgsh1[0].style.display = 'block';
		imgsh1[0].xOpacity = .99;

		th1 = setTimeout("so_xfade1()",0000);
	}
	if (d.getElementById('rotatorsmall2'))
	{
		currenth2 = 0;
		clearTimeout(th2);
		imgsh2 = new Array();
		imgsh2 = d.getElementById('rotatorsmall2').getElementsByTagName('img');
		for(i=1;i<imgsh2.length;i++) imgsh2[i].xOpacity = 0;
		imgsh2[0].style.display = 'block';
		imgsh2[0].xOpacity = .99;

		th2 = setTimeout("so_xfade2()",0000);
	}
	if (d.getElementById('rotatorsmall3'))
	{
		currenth3 = 0;
		clearTimeout(th3);
		imgsh3 = new Array();
		imgsh3 = d.getElementById('rotatorsmall3').getElementsByTagName('img');
		for(i=1;i<imgsh3.length;i++) imgsh3[i].xOpacity = 0;
		imgsh3[0].style.display = 'block';
		imgsh3[0].xOpacity = .99;

		th3 = setTimeout("so_xfade3()",0000);
	}
	if (d.getElementById('rotatorsmall4'))
	{
		currenth4 = 0;
		clearTimeout(th4);
		imgsh4 = new Array();
		imgsh4 = d.getElementById('rotatorsmall4').getElementsByTagName('img');
		for(i=1;i<imgsh4.length;i++) imgsh4[i].xOpacity = 0;
		imgsh4[0].style.display = 'block';
		imgsh4[0].xOpacity = .99;

		th4 = setTimeout("so_xfade4()",0000);
	}
	if (d.getElementById('rotatorsmall5'))
	{
		currenth5 = 0;
		clearTimeout(th5);
		imgsh5 = new Array();
		imgsh5 = d.getElementById('rotatorsmall5').getElementsByTagName('img');
		for(i=1;i<imgsh5.length;i++) imgsh5[i].xOpacity = 0;
		imgsh5[0].style.display = 'block';
		imgsh5[0].xOpacity = .99;

		th5 = setTimeout("so_xfade5()",0000);
	}
	if (d.getElementById('rotatorsmall6'))
	{
		currenth6 = 0;
		clearTimeout(th6);
		imgsh6 = new Array();
		imgsh6 = d.getElementById('rotatorsmall6').getElementsByTagName('img');
		for(i=1;i<imgsh6.length;i++) imgsh6[i].xOpacity = 0;
		imgsh6[0].style.display = 'block';
		imgsh6[0].xOpacity = .99;

		th6 = setTimeout("so_xfade6()",0000);
	}
	if (d.getElementById('rotatorsmall7'))
	{
		currenth7 = 0;
		clearTimeout(th7);
		imgsh7 = new Array();
		imgsh7 = d.getElementById('rotatorsmall7').getElementsByTagName('img');
		for(i=1;i<imgsh7.length;i++) imgsh7[i].xOpacity = 0;
		imgsh7[0].style.display = 'block';
		imgsh7[0].xOpacity = .99;

		th7 = setTimeout("so_xfade7()",0000);
	}
	if (d.getElementById('rotatorsmall8'))
	{
		currenth8 = 0;
		clearTimeout(th8);
		imgsh8 = new Array();
		imgsh8 = d.getElementById('rotatorsmall8').getElementsByTagName('img');
		for(i=1;i<imgsh8.length;i++) imgsh8[i].xOpacity = 0;
		imgsh8[0].style.display = 'block';
		imgsh8[0].xOpacity = .99;

		th8 = setTimeout("so_xfade8()",0000);
	}
	if (d.getElementById('rotatorsmall9'))
	{
		currenth9 = 0;
		clearTimeout(th9);
		imgsh9 = new Array();
		imgsh9 = d.getElementById('rotatorsmall9').getElementsByTagName('img');
		for(i=1;i<imgsh9.length;i++) imgsh9[i].xOpacity = 0;
		imgsh9[0].style.display = 'block';
		imgsh9[0].xOpacity = .99;

		th9 = setTimeout("so_xfade9()",0000);
	}
}

function so_xfade()
{
	cOpacityh = imgsh[currenth].xOpacity;
	nIndexh = imgsh[currenth+1]?currenth+1:0;
	nOpacityh = imgsh[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh[nIndexh].style.display = 'block';
	imgsh[currenth].xOpacity = cOpacityh;
	imgsh[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh[currenth]);
	setOpacity(imgsh[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh[currenth].style.display = 'none';
		currenth = nIndexh;
		th = setTimeout("so_xfade()",2000);
	}
	else
	{
		th = setTimeout("so_xfade()",50);
	}
}

function so_xfadefix1()
{
	cOpacityh = imgshfix1[currenthfix1].xOpacity;
	nIndexh = imgshfix1[currenthfix1+1]?currenthfix1+1:0;
	nOpacityh = imgshfix1[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgshfix1[nIndexh].style.display = 'block';
	imgshfix1[currenthfix1].xOpacity = cOpacityh;
	imgshfix1[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgshfix1[currenthfix1]);
	setOpacity(imgshfix1[nIndexh]);

	if(cOpacityh<=0)
	{
		imgshfix1[currenthfix1].style.display = 'none';
		currenthfix1 = nIndexh;
		thfix1 = setTimeout("so_xfadefix1()",2000);
	}
	else
	{
		thfix1 = setTimeout("so_xfadefix1()",50);
	}
}

function so_xfadefix2()
{
	cOpacityh = imgshfix2[currenthfix2].xOpacity;
	nIndexh = imgshfix2[currenthfix2+1]?currenthfix2+1:0;
	nOpacityh = imgshfix2[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgshfix2[nIndexh].style.display = 'block';
	imgshfix2[currenthfix2].xOpacity = cOpacityh;
	imgshfix2[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgshfix2[currenthfix2]);
	setOpacity(imgshfix2[nIndexh]);

	if(cOpacityh<=0)
	{
		imgshfix2[currenthfix2].style.display = 'none';
		currenthfix2 = nIndexh;
		thfix2 = setTimeout("so_xfadefix2()",2000);
	}
	else
	{
		thfix2 = setTimeout("so_xfadefix2()",50);
	}
}

function so_xfadefix3()
{
	cOpacityh = imgshfix3[currenthfix3].xOpacity;
	nIndexh = imgshfix3[currenthfix3+1]?currenthfix3+1:0;
	nOpacityh = imgshfix3[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgshfix3[nIndexh].style.display = 'block';
	imgshfix3[currenthfix3].xOpacity = cOpacityh;
	imgshfix3[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgshfix3[currenthfix3]);
	setOpacity(imgshfix3[nIndexh]);

	if(cOpacityh<=0)
	{
		imgshfix3[currenthfix3].style.display = 'none';
		currenthfix3 = nIndexh;
		thfix3 = setTimeout("so_xfadefix3()",2000);
	}
	else
	{
		thfix3 = setTimeout("so_xfadefix3()",50);
	}
}

function so_xfade0()
{
	cOpacityh = imgsh0[currenth0].xOpacity;
	nIndexh = imgsh0[currenth0+1]?currenth0+1:0;
	nOpacityh = imgsh0[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh0[nIndexh].style.display = 'block';
	imgsh0[currenth0].xOpacity = cOpacityh;
	imgsh0[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh0[currenth0]);
	setOpacity(imgsh0[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh0[currenth0].style.display = 'none';
		currenth0 = nIndexh;
		th0 = setTimeout("so_xfade0()",2000);
	}
	else
	{
		th0 = setTimeout("so_xfade0()",50);
	}
}

function so_xfade1()
{
	cOpacityh = imgsh1[currenth1].xOpacity;
	nIndexh = imgsh1[currenth1+1]?currenth1+1:0;
	nOpacityh = imgsh1[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh1[nIndexh].style.display = 'block';
	imgsh1[currenth1].xOpacity = cOpacityh;
	imgsh1[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh1[currenth1]);
	setOpacity(imgsh1[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh1[currenth1].style.display = 'none';
		currenth1 = nIndexh;
		th1 = setTimeout("so_xfade1()",2000);
	}
	else
	{
		th1 = setTimeout("so_xfade1()",50);
	}
}

function so_xfade2()
{
	cOpacityh = imgsh2[currenth2].xOpacity;
	nIndexh = imgsh2[currenth2+1]?currenth2+1:0;
	nOpacityh = imgsh2[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh2[nIndexh].style.display = 'block';
	imgsh2[currenth2].xOpacity = cOpacityh;
	imgsh2[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh2[currenth2]);
	setOpacity(imgsh2[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh2[currenth2].style.display = 'none';
		currenth2 = nIndexh;
		th2 = setTimeout("so_xfade2()",2000);
	}
	else
	{
		th2 = setTimeout("so_xfade2()",50);
	}
}

function so_xfade3()
{
	cOpacityh = imgsh3[currenth3].xOpacity;
	nIndexh = imgsh3[currenth3+1]?currenth3+1:0;
	nOpacityh = imgsh3[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh3[nIndexh].style.display = 'block';
	imgsh3[currenth3].xOpacity = cOpacityh;
	imgsh3[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh3[currenth3]);
	setOpacity(imgsh3[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh3[currenth3].style.display = 'none';
		currenth3 = nIndexh;
		th3 = setTimeout("so_xfade3()",2000);
	}
	else
	{
		th3 = setTimeout("so_xfade3()",50);
	}
}

function so_xfade4()
{
	cOpacityh = imgsh4[currenth4].xOpacity;
	nIndexh = imgsh4[currenth4+1]?currenth4+1:0;
	nOpacityh = imgsh4[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh4[nIndexh].style.display = 'block';
	imgsh4[currenth4].xOpacity = cOpacityh;
	imgsh4[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh4[currenth4]);
	setOpacity(imgsh4[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh4[currenth4].style.display = 'none';
		currenth4 = nIndexh;
		th4 = setTimeout("so_xfade4()",2000);
	}
	else
	{
		th4 = setTimeout("so_xfade4()",50);
	}
}

function so_xfade5()
{
	cOpacityh = imgsh5[currenth5].xOpacity;
	nIndexh = imgsh5[currenth5+1]?currenth5+1:0;
	nOpacityh = imgsh5[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh5[nIndexh].style.display = 'block';
	imgsh5[currenth5].xOpacity = cOpacityh;
	imgsh5[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh5[currenth5]);
	setOpacity(imgsh5[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh5[currenth5].style.display = 'none';
		currenth5 = nIndexh;
		th5 = setTimeout("so_xfade5()",2000);
	}
	else
	{
		th5 = setTimeout("so_xfade5()",50);
	}
}

function so_xfade6()
{
	cOpacityh = imgsh6[currenth6].xOpacity;
	nIndexh = imgsh6[currenth6+1]?currenth6+1:0;
	nOpacityh = imgsh6[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh6[nIndexh].style.display = 'block';
	imgsh6[currenth6].xOpacity = cOpacityh;
	imgsh6[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh6[currenth6]);
	setOpacity(imgsh6[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh6[currenth6].style.display = 'none';
		currenth6 = nIndexh;
		th6 = setTimeout("so_xfade6()",2000);
	}
	else
	{
		th6 = setTimeout("so_xfade6()",50);
	}
}

function so_xfade7()
{
	cOpacityh = imgsh7[currenth7].xOpacity;
	nIndexh = imgsh7[currenth7+1]?currenth7+1:0;
	nOpacityh = imgsh7[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh7[nIndexh].style.display = 'block';
	imgsh7[currenth7].xOpacity = cOpacityh;
	imgsh7[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh7[currenth7]);
	setOpacity(imgsh7[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh7[currenth7].style.display = 'none';
		currenth7 = nIndexh;
		th7 = setTimeout("so_xfade7()",2000);
	}
	else
	{
		th7 = setTimeout("so_xfade7()",50);
	}
}

function so_xfade8()
{
	cOpacityh = imgsh8[currenth8].xOpacity;
	nIndexh = imgsh8[currenth8+1]?currenth8+1:0;
	nOpacityh = imgsh8[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh8[nIndexh].style.display = 'block';
	imgsh8[currenth8].xOpacity = cOpacityh;
	imgsh8[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh8[currenth8]);
	setOpacity(imgsh8[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh8[currenth8].style.display = 'none';
		currenth8 = nIndexh;
		th8 = setTimeout("so_xfade8()",2000);
	}
	else
	{
		th8 = setTimeout("so_xfade8()",50);
	}
}

function so_xfade9()
{
	cOpacityh = imgsh9[currenth9].xOpacity;
	nIndexh = imgsh9[currenth9+1]?currenth9+1:0;
	nOpacityh = imgsh9[nIndexh].xOpacity;

	cOpacityh-=.05;
	nOpacityh+=.05;

	imgsh9[nIndexh].style.display = 'block';
	imgsh9[currenth9].xOpacity = cOpacityh;
	imgsh9[nIndexh].xOpacity = nOpacityh;

	setOpacity(imgsh9[currenth9]);
	setOpacity(imgsh9[nIndexh]);

	if(cOpacityh<=0)
	{
		imgsh9[currenth9].style.display = 'none';
		currenth9 = nIndexh;
		th9 = setTimeout("so_xfade9()",2000);
	}
	else
	{
		th9 = setTimeout("so_xfade9()",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) + ')';
}

