// JavaScript Document


function init(){
	
	global_array_wechselbilder_verlinkung = new Array();
	global_startdisplay = document.getElementById("startdisplay");
	global_wechselbilder = global_startdisplay.getElementsByTagName("IMG");
	global_rotationIndex = 0;
	global_ueberblendenAktiv = 0;
	global_wechselbilder_breite = 1000;
	global_wechselbilder_hoehe = 340;
	
	if(global_wechselbilder.length > 1){
		var kleinbildhalter = document.createElement("DIV");
		kleinbildhalter.setAttribute("id", "startdisplay_kleinbild_halter");
		kleinbildhalter.setAttribute("onmouseover", "RotationStop()");
		kleinbildhalter.setAttribute("onmouseout", "RotationStart()");
		global_startdisplay.parentNode.appendChild(kleinbildhalter);
	
		for(var i = 0; i < global_wechselbilder.length; i++){
			global_array_wechselbilder_verlinkung[i] = global_wechselbilder[i].getAttribute("longdesc");
			global_wechselbilder[i].removeAttribute("longdesc");
		
			var kleinbild = document.createElement("IMG");
			kleinbild.setAttribute("src", global_wechselbilder[i].getAttribute("src"));
			kleinbild.setAttribute("alt", global_wechselbilder[i].getAttribute("alt"));
			kleinbild.setAttribute("title", global_wechselbilder[i].getAttribute("alt"));
			kleinbild.setAttribute("width", "80px");
			kleinbild.setAttribute("height", "34px");
			var rotationslink = "rotation(" + i + ")";
			kleinbild.setAttribute("onclick", rotationslink);
			kleinbildhalter.appendChild(kleinbild);
		}
	
	
		global_rotation = window.setTimeout("RotationStart()", 10000);
		kleinbildhalter.getElementsByTagName("IMG")[0].className = "aktiv_kleinbild";
	}
}
init();


function rotation(){
	if(global_ueberblendenAktiv == 0){
		
		if(rotation.arguments.length < 1){
			var index = global_rotationIndex + 1;
			if(index == global_wechselbilder.length){
				index = 0;
			}
			RotationStart();
		}
		
		else{
			var index = rotation.arguments[0];
			RotationStop();
		}
		
		if(index != global_rotationIndex){
			global_ueberblendenAktiv = 1;
			global_wechselbilder[global_rotationIndex].style.zIndex = 3;
			global_wechselbilder[index].style.zIndex = 2;
			global_wechselbilder[index].style.display = "block";
			global_wechselbilder[index].style.width = global_wechselbilder_breite + "px";
			global_wechselbilder[index].style.height = global_wechselbilder_hoehe + "px";
			global_wechselbilder[index].style.top = "0px";
			global_wechselbilder[index].style.left = "0px";
			global_wechselbilder[index].style.filter = "alpha(opacity=100)";
			global_wechselbilder[index].style.opacity = 1;
			
			var kleinbildhalter_bilder = document.getElementById("startdisplay_kleinbild_halter").getElementsByTagName("IMG");
			kleinbildhalter_bilder[global_rotationIndex].className = null;
			kleinbildhalter_bilder[index].className = "aktiv_kleinbild";
			
			global_startdisplay.href=global_array_wechselbilder_verlinkung[index];
			ebene_ausfaden(index, 100);
		}

	}
}

function ebene_ausfaden(index, opac)
{
	global_wechselbilder[global_rotationIndex].style.opacity = opac/100;
	global_wechselbilder[global_rotationIndex].style.filter = "alpha(opacity=" + opac + ")";
	global_wechselbilder[global_rotationIndex].style.width = global_wechselbilder[global_rotationIndex].offsetWidth + 29 + "px";
	global_wechselbilder[global_rotationIndex].style.height = global_wechselbilder[global_rotationIndex].offsetHeight + 10 + "px";
	global_wechselbilder[global_rotationIndex].style.top = global_wechselbilder[global_rotationIndex].offsetTop -4 + "px";
	global_wechselbilder[global_rotationIndex].style.left = global_wechselbilder[global_rotationIndex].offsetLeft -14 + "px";
	if (opac > 20){
		opac = opac - 10;
	}
	else{
		opac = opac - 5;
	}
	if (opac > 0){
		window.setTimeout(function () { ebene_ausfaden(index, opac); }, 50);
	}
	else{
		global_wechselbilder[global_rotationIndex].style.display = "none";
		global_wechselbilder[global_rotationIndex].style.zIndex = 1;
		global_rotationIndex = index;
		global_ueberblendenAktiv = 0;
	}
}


function RotationStart()
{
	if(typeof(global_rotation) != "undefined")
	{
		window.clearTimeout(global_rotation);
	}
	global_rotation = window.setTimeout("rotation()", 10000);
}

function RotationStop()
{
	if(typeof(global_rotation) != "undefined")
	{
		window.clearTimeout(global_rotation);
	}
}
