var Browser ="";
var aktiv = "";
var i = 0;
var BlenderStand = "Aus";
if (navigator.userAgent.indexOf("MSIE")!= -1){
   Browser = ("IE");
}
   else if (navigator.userAgent.indexOf("Netscape")!= -1){
   Browser = ("Netscape");
}
   else if (navigator.userAgent.indexOf("Opera")!= -1){
   Browser = ("Opera");
}
   else if (navigator.userAgent.indexOf("Firefox")!= -1){
   Browser = ("Firefox");
}
   else if (navigator.userAgent.indexOf("Safari")!= -1){
   Browser = ("Safari");
}

if(navigator.userAgent.indexOf("iPhone")!= -1){
   	Browser = ("iPhone");	
}
if(navigator.userAgent.indexOf("iPad")!= -1){
   	Browser = ("iPhone");	
}
if (navigator.userAgent.indexOf("MSIE 9")!= -1){
   		Browser = ("IE9");	
}

if(navigator.userAgent.indexOf("Win")!= -1){
   		Betriebssystem = ("Windows");
	}else if (navigator.userAgent.indexOf("Mac")!= -1){
   		Betriebssystem = ("Mac");
   	}else{
   		Betriebssystem = navigator.userAgent;
}
//alert(Browser);
//SubMenue/***************************************

function MediaBlenderEin(Film){
	//alert(Browser);
	if(Browser == "iPhone"){
		Ausgabe = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" WIDTH="640" HEIGHT="540" >';
		Ausgabe += '<PARAM NAME="src" VALUE="filmblender/Film/'+Film+'.mp4" >';
		Ausgabe += '<PARAM NAME="autoplay" VALUE="true" >';
		Ausgabe += '<EMBED SRC="http://www.klarer.com/filmblender/html/Film/'+Film+'.mp4" TYPE="image/x-macpaint" PLUGINSPAGE="http://www.apple.com/quicktime/download" WIDTH="640" HEIGHT="540" AUTOPLAY="true"></EMBED>';
		Ausgabe += '</OBJECT>';
		Ausgabe += '<br/><a href="#" onclick="javascript:FilmAus();" title="Panorama" class="SchliessenKnopf">Film schliessen</a> ';
		document.getElementById("FilmBox").innerHTML= Ausgabe;
		//alert(Ausgabe);
		IPhoneFilmEin(Film);
	}
	
	//alert (Betriebssystem);
	if(BlenderStand == "Aus"){
		BlenderStand = "Faden";
		
		if(Browser == "IE"){
			//alert(document.documentElement.clientWidth );
//**********************************************************************************************************	
			document.getElementById('FilmFenster').SetVariable("FilmTyp",Film); //film laden
//**********************************************************************************************************
		//Deckblatt = schwarzer Hintergrund	
			FensterBreite = document.documentElement.clientWidth;
			FensterHoehe = document.documentElement.clientHeight;
			BildschirmBreite = screen.width;
			BildschirmHoehe = screen.height;
			//alert(FensterBreite);
			TopPosition =document.documentElement.scrollTop+20;
			document.getElementById("Deckblatt").style.width = BildschirmBreite;
			document.getElementById("Deckblatt").style.height = BildschirmHoehe;
			document.getElementById("Deckblatt").style.display = "block";
			
			//Fensterbreite - halbes Flaschformat
			document.getElementById("FilmBox").style.left = (FensterBreite/2)-320;
			document.getElementById("FilmBox").style.top = 80;
			
			aktiv = window.setInterval("Faden('Ein')", 10);//Aufruf in x Millisekunden
			
		}else{
//**********************************************************************************************************
			//document.getElementById("FilmFenster").SetVariable("FilmTyp",Film); //film laden
			if(document.FilmFenster) document.FilmFenster.SetVariable("FilmTyp",Film);
//**********************************************************************************************************
			FensterHoehe = window.innerHeight  ;
			FensterBreite = window.innerWidth ;
			BildschirmBreite = window.screen.width;
			BildschirmHoehe = window.screen.height;
			TopPosition = window.pageYOffset+20+"px";
			document.getElementById("Deckblatt").style.opacity = 0;
			document.getElementById("Deckblatt").style.width = BildschirmBreite+"px";
			document.getElementById("Deckblatt").style.height = BildschirmHoehe+"px";
			document.getElementById("Deckblatt").style.left = "0px";
			document.getElementById("Deckblatt").style.top = "0px";
			document.getElementById("FilmBox").style.left = FensterBreite/2-320+"px";
			document.getElementById("FilmBox").style.top = "80px";
			document.getElementById("Deckblatt").style.display = "block";
			
			if(Browser=="iPhone"){
				document.getElementById("FilmBox").style.top = "30px";
				document.getElementById("Deckblatt").style.width = "980px";
			}
			
			aktiv = window.setInterval("Faden('Ein')", 10);//Aufruf in x Millisekunden
		}	
	}
}

function MediaBlenderAus(){
	if(Browser == "IE"){
		//document.FilmFenster.StopPlay(1);//Flash Bearbeiten, damit Film entladen wird.
		document.FilmFenster.SetVariable("FilmTyp","undefined");
		if(BlenderStand == "Ein"){
			BlenderStand = "Faden";
			aktiv = window.setInterval("Faden('Aus')", 10);//Aufruf in x Millisekunden
		}
	  
	}else if(Browser == "IE9"){
		if(document.FilmFenster) document.FilmFenster.SetVariable("FilmTyp","undefined");
		//alert("Film Abschalten?")
		//window.document["FilmFenster"].SetVariable("FilmTyp","undefined");
		if(BlenderStand == "Ein"){
			BlenderStand = "Faden";
			aktiv = window.setInterval("Faden('Aus')", 150);//Aufruf in x Millisekunden
			
		}
		}else{
		
//**********************************************************************************************************
		//if(window.FilmFenster) window.document["FilmFenster"].SetVariable("FilmTyp","undefined");
  		//if(document.FilmFenster) document.FilmFenster.SetVariable("FilmTyp","undefined");
		if(document.FilmFenster) document.FilmFenster.SetVariable("FilmTyp","undefined");
//**********************************************************************************************************

		if(BlenderStand == "Ein"){
			BlenderStand = "Faden";
			aktiv = window.setInterval("Faden('Aus')", 10);//Aufruf in x Millisekunden
		}
	}
}

function Faden(Richtung) {
	
	if(Browser == "IE"){
		if(Richtung == "Ein"){
			i=i+7;
		}else{
			i=i-7;
		}
		ii=i-20;
		document.getElementById("Deckblatt").style.filter="alpha(opacity="+ii+")";
		document.getElementById("FilmBox").style.filter="alpha(opacity="+i+")";
		document.getElementById("FilmFenster").style.filter="alpha(opacity="+i+")";
	}else{
		if(Richtung == "Ein"){
			i=i+0.05;
		}else{
			i=i-0.05;
		}
		document.getElementById("Deckblatt").style.opacity =i-0.2;
		document.getElementById("FilmBox").style.opacity =i;
		document.getElementById("filmfenster").style.opacity =i;
	}
	if(Browser == "IE"){
  		if (i > 100){
    		window.clearInterval(aktiv);
			i = 100;
			BlenderStand = "Ein";
		}
		if(i < 0){
			window.clearInterval(aktiv);
			i = 0;
			document.getElementById("Deckblatt").style.display = "none";
			BlenderStand = "Aus";
			document.getElementById("FilmBox").style.left = -1000;
			document.getElementById("FilmBox").style.top = -1000;
		}
	}else{
		if (i > 1.0){
    		window.clearInterval(aktiv);
			i = 1.0;
			BlenderStand = "Ein";
		}
		if(i < 0){
			window.clearInterval(aktiv);
			i = 0;
			document.getElementById("Deckblatt").style.display = "none";
			BlenderStand = "Aus";
			document.getElementById("FilmBox").style.left = "-1000px";
			document.getElementById("FilmBox").style.top = "-1000px";

			
			
			
		}
	}
}

function IPhoneFilmEin(FilmName){
	var FilmFenster=document.getElementById("FilmBox");
		
	FilmFenster.style.display = "block";
		
	//Deckblatt = schwarzer Hintergrund	
	//FensterHoehe = window.innerHeight  ;
	//FensterBreite = window.innerWidth ;
	//BildschirmBreite = window.screen.width;
	//BildschirmHoehe = window.screen.height;
	//ScrollX =	window.pageXOffset
	//ScrollY =	window.pageYOffset
		//XPosition = BildschirmBreite/2 + ScrollX;
		//YPosition = BildschirmHoehe/2 + ScrollY;
	//XPosition = (event.clientX+ScrollX)/2
	//YPosition =(event.clientY+ScrollY)/2
	//TopPosition = window.pageYOffset+20+"px";
		
/*
	
	document.getElementById("Deckblatt").style.height = BildschirmHoehe+"px";
	
	document.getElementById("Deckblatt").style.top = "0px";
	
	document.getElementById("Deckblatt").style.left = "0px";	
	document.getElementById("FilmBox").style.left = XPosition+"px";
	document.getElementById("FilmBox").style.top = YPosition+"px";
*/	
	document.getElementById("Deckblatt").style.width = "980px";
	document.getElementById("Deckblatt").style.display = "block";	
	i=0.1;
	document.getElementById("Deckblatt").style.opacity = i;
}

function FilmAus(){
	//alert("Film Ausblenden")
		Ausgabe = '';
		document.getElementById("FilmBox").innerHTML= Ausgabe;
		document.getElementById("Deckblatt").style.display = "none";
		document.getElementById("Deckblatt").style.opacity = 0.1;
}

