var timer;
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;


if(lang=="en") var text=new Array("Pump systems","Reformer development","Test rigs","Industrial burners");
else var text=new Array("Pumpensysteme","Reformerentwicklung","Prüfstände","Industriebrenner");

window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);


function so_init() {
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement("link");
	css.setAttribute("href","style.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
//	d.getElementsByTagName("head")[0].appendChild(css);

	imgs = d.getElementById("imageContainerFade").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = 1.00;
	d.getElementById("TextContainerFade").innerHTML=text[0];
	
	timer=setTimeout("pulse(0)",5000);
}


function pulse(mouseov) {

	clearTimeout ( timer );

		if(mouseov>0) {
			nIndex = mouseov -1;
		}
		else {
			nIndex = imgs[current+1]?current+1:0;
		}

	d.getElementById("TextContainerFade").innerHTML=text[nIndex];
	so_xfade(nIndex);
	if(pause==false) timer=setTimeout("pulse(0)",5000);
}



function so_xfade(nIndex) {

	cOpacity = imgs[current].xOpacity;
	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	if(cOpacity<0.00) cOpacity=0.00;
	if(nOpacity>1.00) nOpacity=1.00;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0.00) {
		imgs[current].style.display = "none";
		current = nIndex;
	} 
	else {
		setTimeout("so_xfade(nIndex)",10);
	}
}



function setOpacity(obj) {

	if(obj.xOpacity>.99) {
		obj.xOpacity = .99;
		return;
	}
	if(obj.xOpacity > .01) obj.style.display="block";
	else obj.style.display="none";
		
	obj.style.opacity = obj.xOpacity;
	obj.style.MozOpacity = obj.xOpacity;
	obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
}
