/*
	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_initt,false):window.attachEvent('onload',so_initt);

var d=document, imgst = new Array(), zInterval = null, currentt=0, pause=false;

function so_initt()
{
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement('link');
	css.setAttribute('href','slideshow2t.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);

	imgst = d.getElementById('rotatort').getElementsByTagName('img');
	for(i=1;i<imgst.length;i++) imgst[i].xOpacityt = 0;
	imgst[0].style.display = 'block';
	imgst[0].xOpacityt = .99;

	setTimeout(so_xfadet,3000);
}

function so_xfadet()
{
	cOpacity = imgst[currentt].xOpacityt;
	nIndext = imgst[currentt+1]?currentt+1:0;
	nOpacity = imgst[nIndext].xOpacityt;

	cOpacity-=.05;
	nOpacity+=.05;

	imgst[nIndext].style.display = 'block';
	imgst[currentt].xOpacityt = cOpacity;
	imgst[nIndext].xOpacityt = nOpacity;

	setOpacityt(imgst[currentt]);
	setOpacityt(imgst[nIndext]);

	if(cOpacity<=0)
	{
		imgst[currentt].style.display = 'none';
		currentt = nIndext;
		setTimeout(so_xfadet,3000);
	}
	else
	{
		setTimeout(so_xfadet,50);
	}

	function setOpacityt(obj)
	{
		if(obj.xOpacityt>.99)
		{
			obj.xOpacityt = .99;
			return;
		}

		obj.style.opacity = obj.xOpacityt;
		obj.style.MozOpacity = obj.xOpacityt;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacityt*100) + ')';
	}
}