var Browser ="";
var aktiv = "";
var Ausgabe="";
var FensterBreite = 0;
var FensterHoehe = 0;
var BildschirmBreite = 0;
var BildschirmHoehe = 0;
var TopPosition =0;
var i = 0;
var BlenderStand = "Aus";
var Richtung = "ohne";
if (navigator.userAgent.indexOf("MSIE")!= -1){
   FilmBrowser = ("IE");
}
   else if (navigator.userAgent.indexOf("Netscape")!= -1){
   FilmBrowser = ("Netscape");
}
   else if (navigator.userAgent.indexOf("Opera")!= -1){
   FilmBrowser = ("Opera");
}
   else if (navigator.userAgent.indexOf("Firefox")!= -1){
   FilmBrowser = ("Firefox");
}
   else if (navigator.userAgent.indexOf("Safari")!= -1){
   FilmBrowser = ("Safari");
}

   if(navigator.userAgent.indexOf("iPhone")!= -1 ||navigator.userAgent.indexOf("iPhone")!= -1){
		 //||iphone||ipod||opera mini||fennec||palm||blackberry||android||symbian||series60
   		FilmBrowser = ("IPhone");	
	}
	if(navigator.userAgent.indexOf("Android")!= -1){
		 //||iphone||ipod||opera mini||fennec||palm||blackberry||android||symbian||series60
   		FilmBrowser = ("Android");	
	}
if(navigator.userAgent.indexOf("iPad")!= -1){
   	FilmBrowser = ("iPad");	
}
if (navigator.userAgent.indexOf("MSIE 9")!= -1){
   		FilmBrowser = ("IE9");	
}

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

function FilmBlenderEin(Film){
	//alert(FilmBrowser);
	if(FilmBrowser == "IPhone"){
		Ausgabe = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab" WIDTH="320" HEIGHT="270" >';
		Ausgabe += '<PARAM NAME="src" VALUE="filmblender/Film/'+Film+'.mp4" >';
		Ausgabe += '<PARAM NAME="autoplay" VALUE="true" >';
		Ausgabe += '<EMBED SRC="filmblender/html/Film/'+Film+'.mp4" TYPE="image/x-macpaint" PLUGINSPAGE="http://www.apple.com/quicktime/download" WIDTH="320" HEIGHT="270" AUTOPLAY="true"></EMBED>';
		Ausgabe += '</OBJECT>';
		Ausgabe += '<br/><a href="#" onclick="javascript:FilmAus();" title="Panorama" class="SchliessenKnopf"><img src="filmblender/bilder/FilmSchliessen.png"/></a> ';
		document.getElementById("FilmBox").innerHTML= Ausgabe;
		//alert(Ausgabe);
		IPhoneFilmEin(Film);
	}
	
	if(FilmBrowser == "iPad"){
		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="filmblender/html/Film/'+Film+'.mp4" TYPE="image/x-macpaint" PLUGINSPAGE="http://www.apple.com/quicktime/download" WIDTH="620" HEIGHT="540" AUTOPLAY="true"></EMBED>';
		Ausgabe += '</OBJECT>';
		Ausgabe += '<br/><a href="#" onclick="javascript:FilmAus();" title="Panorama" class="SchliessenKnopf"><img src="filmblender/bilder/FilmSchliessen.png"/></a> ';
		document.getElementById("FilmBox").innerHTML= Ausgabe;
		//alert(Ausgabe);
		IPhoneFilmEin(Film);
	}
	
	if(FilmBrowser == "Android"){
		//skalierter Film
			Ausgabe = '<object id="FilmFenster" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="320" height="270"  align="middle ">';
				Ausgabe += '<param name="allowScriptAccess" value="sameDomain" />';
				Ausgabe += '<param name="allowFullScreen" value="false" />';
    			Ausgabe += '<param name="name" value="FilmFenster" />';
    			Ausgabe += '<param name="wmode" value="transparent"/>';
				Ausgabe += '<param name="movie" value="filmblender/html/Film/FilmPlayer.swf" />';
				Ausgabe += '<PARAM NAME=scale VALUE=exactfit> ';
    			Ausgabe += '<param name="quality" value="high" />';
    			Ausgabe += '<param name="bgcolor" value="#ffffff" />	';
    			Ausgabe += '<embed name="FilmFenster" id="filmfenster" allowScriptAccess="samedomain" src="filmblender/html/Film/FilmPlayer.swf" quality="high" bgcolor="#ffffff" width="320" height="270" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" scale="exactfit"/>';
			Ausgabe += '</object>';

		Ausgabe += '<br/><a href="#" onclick="javascript:FilmBlenderAus();" title="Panorama" class="SchliessenKnopf"><img src="filmblender/bilder/FilmSchliessen.png"/></a> ';
		
		document.getElementById("FilmBox").innerHTML= Ausgabe;
		
	}
	
	
	
	
	
	//alert (Betriebssystem);
	if(BlenderStand == "Aus"){
		BlenderStand = "Faden";
		
		if(FilmBrowser == "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(FilmBrowser=="IPhone"){
				document.getElementById("FilmBox").style.top = 20+"px";
				document.getElementById("FilmBox").style.width = 320+"px";
				document.getElementById("Deckblatt").style.width = 320+"px";
				document.getElementById("FilmBox").style.left = 0+"px";
			}
			if(FilmBrowser=="Android"){
				document.getElementById("FilmBox").style.top = 20+"px";
				document.getElementById("FilmBox").style.width = BildschirmBreite+"px";
				document.getElementById("Deckblatt").style.width = BildschirmBreite+"px";
				document.getElementById("FilmBox").style.left = 0+"px";
			}
			if(FilmBrowser=="iPad"){
				document.getElementById("FilmBox").style.top = window.pageYOffset;
				document.getElementById("FilmBox").style.width = 640+"px";
				document.getElementById("FilmBox").style.height = 640+"px";
				document.getElementById("Deckblatt").style.width = 900+"px";
				document.getElementById("Deckblatt").style.left = 0+"px";
				document.getElementById("FilmBox").style.left = (FensterBreite/2)-320+"px";
			}
			
			aktiv = window.setInterval("Faden('Ein')", 10);//Aufruf in x Millisekunden
		}
	
	}
}

function FilmBlenderAus(){
	if(FilmBrowser == "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(FilmBrowser == "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
		}
		if(FilmBrowser=="Android"){
			//alert(FilmBrowser);
			//document.FilmFenster.SetVariable("FilmTyp","undefined");
			//document.getElementById("FilmBox").style.display = "none";
			document.getElementById("Deckblatt").style.top = -1000+"px";
			document.getElementById("FilmBox").style.left = -1000+"px";
		}
		if(FilmBrowser=="iPad"){
			//alert(FilmBrowser);
			//document.FilmFenster.SetVariable("FilmTyp","undefined");
			//document.getElementById("FilmBox").style.display = "none";
			document.getElementById("Deckblatt").style.top = 0+"px";
			document.getElementById("FilmBox").style.left = 0+"px";
		}
	}
}

function Faden(Richtung) {
	
	if(FilmBrowser == "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(FilmBrowser == "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");
	
			document.getElementById("FilmBox").style.width = 320+"px";
			document.getElementById("FilmBox").style.height = 320+"px";
			document.getElementById("FilmBox").style.display = "block";
			
			//Fensterbreite - halbes Flaschformat
			document.getElementById("FilmBox").style.left = 0+"px";
			document.getElementById("FilmBox").style.top = 0+"px";
			
			if(FilmBrowser == "iPad"){
				document.getElementById("FilmBox").style.top = window.pageYOffset;
				document.getElementById("FilmBox").style.width = 640+"px";
				document.getElementById("FilmBox").style.height = 640+"px";
				document.getElementById("Deckblatt").style.width = 900+"px";
				document.getElementById("Deckblatt").style.left = 0+"px";
				document.getElementById("FilmBox").style.left = (FensterBreite/2)-320+"px";
				document.getElementById("Deckblatt").style.opacity =0.9;
				
			}
	
		
	//FilmFenster.style.display = "block";
}





function FilmAus(){
	//alert("Film Ausblenden")
		Ausgabe = '';
		document.getElementById("FilmBox").innerHTML= Ausgabe;
		document.getElementById("Deckblatt").style.display = "none";
		document.getElementById("Deckblatt").style.opacity = 0.1;
		
		if(FilmBrowser=="IPhone"){
			document.getElementById("FilmBox").style.display = "none";
			document.getElementById("Deckblatt").style.top = -1000+"px";
			document.getElementById("FilmBox").style.left = -1000+"px";
		}
		if(FilmBrowser=="iPad"){
			document.getElementById("FilmBox").style.display = "none";
		}
		
}

