/*
	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
*/
function Ccrossfade_1011(){
	this.current=0;
	//--- Konfiguration --
	this.haltezeit=     4000; 	// Zeit, während das bild zu sehen ist.
	this.schrittzeit= 	 100; 	// Pause zwischen den einzelnen schritten.
	this.schrittweite= 	0.02; 	// Änderung der Transparenz pro schritt.
}
Ccrossfade_1011.prototype.go=function(){
	var d=document;
	css = d.createElement('link');
	css.setAttribute('href','inc/ermt_crossfade_1011/style2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);
	
	css = d.createElement('link');
	
//	this.imgs = d.getElementById('rotator').getElementsByTagName('img');
	this.imgs = d.getElementById('ermt_crossfade_1011').getElementsByTagName('div');
	for(i=1;i<this.imgs.length;i++) this.imgs[i].xOpacity = 0;
	this.imgs[0].style.display = 'block';
	this.imgs[0].xOpacity = .99;
	setTimeout(this.step,this.haltezeit);
}
Ccrossfade_1011.prototype.step=function(){
	cOpacity = crossfade.imgs[crossfade.current].xOpacity;
	nIndex = crossfade.imgs[crossfade.current+1]?crossfade.current+1:0;
	nOpacity = crossfade.imgs[nIndex].xOpacity;
	cOpacity-=crossfade.schrittweite;
	nOpacity+=crossfade.schrittweite;
	crossfade.imgs[nIndex].style.display = 'block';
	crossfade.imgs[crossfade.current].xOpacity = cOpacity;
	crossfade.imgs[nIndex].xOpacity = nOpacity;
	setOpacity(crossfade.imgs[crossfade.current]);
	setOpacity(crossfade.imgs[nIndex]);
	if(cOpacity<=0){
		crossfade.imgs[crossfade.current].style.display = 'none';
		crossfade.current = nIndex;
		setTimeout(crossfade.step,crossfade.haltezeit);
	}else{
		setTimeout(crossfade.step,crossfade.schrittzeit);
	}
	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) + ')';
	}
}
crossfade= new Ccrossfade_1011();
function crossfade_go(){
	crossfade.go();
}
window.addEventListener?window.addEventListener('load',crossfade_go,false):window.attachEvent('onload',crossfade_go);
