var flashready = 0;
var parktippno = 0;
var weissmehrno = 0;
var soundanaus = "an";
var drachentonbild = "";
var drachenboxaktiv = 0;
var flashvars = {};

function SendDataToFlashMovie()
{
	if(flashready == 1){
		var flashMovie = getFlashMovieObject("headerflash");
		flashMovie.sendTextToFlash(newPage);
	}else{
		//alert("Bitte warten Sie, bis die Seite vollständig geladen worden ist!");
	}
}

function DrachenInfoSprache(ID){
	if(flashready == 1){
		var flashMovie = getFlashMovieObject("headerflash");
		flashMovie.DrachenInfoSprachAusgabe(ID);
	}
}

function MoviePlayerStart(){
	if(flashready == 1){
		var flashMovie = getFlashMovieObject("headerflash");
		flashMovie.JSMoviePlayerStart();
	}
}

function MoviePlayerStop(){
	if(flashready == 1){
		var flashMovie = getFlashMovieObject("headerflash");
		flashMovie.JSMoviePlayerStop();
	}
}
	
function DrachenInfoZu(){
	if(flashready == 1){
		var flashMovie = getFlashMovieObject("headerflash");
		flashMovie.DrachenInfoSprachAusgabeStop();
	}
}

function DrachenInfoTonAnAus(ID){
	if(soundanaus == "an"){
		setSoundAnAus("aus");
		//document.getElementById('dracheninfotonanaus'+drachenboxaktiv).innerHTML = '<a href="javascript:void(true);" onClick="DrachenInfoTonAnAus(\''+ ID +'\');" title="Ton an/aus"><img src="' + PHLpathstatic + 'tonaus_blau.png" id="drachentonausan" alt="Ton an/aus" width="30" height="31" border="0" onMouseOver="showDrachenTonImgAn()" onMouseOut="showDrachenTonImgAus()" /></a>';
	}else if(soundanaus == "aus"){
		setSoundAnAus("an");
		//document.getElementById('dracheninfotonanaus'+drachenboxaktiv).innerHTML = '<a href="javascript:void(true);" onClick="DrachenInfoTonAnAus(\''+ ID +'\');" title="Ton an/aus"><img src="' + PHLpathstatic + 'tonan_blau.png" id="drachentonausan" alt="Ton an/aus" width="30" height="31" border="0" onMouseOver="showDrachenTonImgAus()" onMouseOut="showDrachenTonImgAn()"/></a>';
	};
}


function setFlashReady(){
	flashready = 1;
}

function setSoundStatus(Status){
	if(Status == "aus"){
		soundanaus = "aus";
		//document.getElementById('dracheninfotonanaus'+ drachenboxaktiv).innerHTML = '<a href="javascript:void(true);" onClick="DrachenInfoTonAnAus(\'drago\');" title="Ton an/aus"><img src="' + PHLpathstatic + 'tonaus_blau.png" id="drachentonausan" alt="Ton an/aus" width="30" height="31" border="0" onMouseOver="showDrachenTonImgAn()" onMouseOut="showDrachenTonImgAus()" /></a>';				
		
	}else if(Status == "an"){
		soundanaus = "an";
		//document.getElementById('dracheninfotonanaus'+ drachenboxaktiv).innerHTML = '<a href="javascript:void(true);" onClick="DrachenInfoTonAnAus(\'drago\');" title="Ton an/aus"><img src="' + PHLpathstatic + 'tonan_blau.png" id="drachentonausan" alt="Ton an/aus" width="30" height="31" border="0" onMouseOver="showDrachenTonImgAus()" onMouseOut="showDrachenTonImgAn()" /></a>';
	}
}

function setSoundAnAus(Status){
	var flashMovie = getFlashMovieObject("headerflash");
	if(Status == "aus"){
		soundanaus = "aus";
		flashMovie.JSSchalteSoundAufLautlos();
	}else if(Status == "an"){
		soundanaus = "an";
		flashMovie.JSSchalteSoundAufAn();
	}
}
	
function getFlashMovieObject(movieName){
	if (window.document[movieName]){
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1){
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName];
		}
		else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
		{
			return document.getElementById(movieName);
	}
}

function openDrachenText(Drachenname, ID){
 var temp = "dracheninfo" + ID;
 //document.getElementById(temp).style.visibility = 'visible';
 DrachenInfoSprache(Drachenname);
 
 var temp = '<div id="drachenpop'+ID+'"class="dracheninfobox dracheninfobox'+Drachenname+'">' + document.getElementById(temp).innerHTML + '</div>';
 jQuery(document).ready(function() {
 $.fancybox(
  temp,
  {
    'titleShow'   : false,
    'transitionIn'  : 'none',
    'transitionOut'  : 'none',
    'overlayShow'       : false,
    'showCloseButton' : false,
    'centerOnScroll' : true
  }
 );
 });
}
 
function showDrachenTonImgAn(){
	//document.getElementById('drachentonausan'+drachenboxaktiv).src = PHLpathstatic + 'tonan_blau.png';
}

function showDrachenTonImgAus(){
	//document.getElementById('drachentonausan'+drachenboxaktiv).src = PHLpathstatic + 'tonaus_blau.png';
}

function showNavText(Welcher){
	document.getElementById("navtext").src = PHLpathstatic + 'nav_text_' + Welcher + '.png';
}

function removeNavText(){
	document.getElementById("navtext").src = PHLpathstatic + 'nav_text_leer.png';
}

function startVideo(PlayerID,Movie){
}

function randomParktipp(){
	parktippno++;
	if(parktippno>parktippsno){
		parktippno = 1;
	};
	//document.getElementById("baduparktippinfo").href = "#baduparktipp" + (parktippno);
	//alert(document.getElementById("baduparktippinfo").href);
	var temp = '<div class="parktippinfobox infoboxen">' + document.getElementById('baduparktipp'+parktippno).innerHTML + '</div>';
	jQuery(document).ready(function() {
	$.fancybox(
		temp,
		{
				'titleShow'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'overlayShow'       : false,
				'showCloseButton'	: false,
				'centerOnScroll'	: true
		}
	);
	});
}

function randomWeissmehr(){
	weissmehrno++;
	if(weissmehrno>weissmehrsno){
		weissmehrno = 1;
	};
	//document.getElementById("baduweissmehrinfo").href = "#baduweissmehr" + (weissmehrno);
	var temp = '<div class="weissmehrinfobox infoboxen">' + document.getElementById('baduweissmehr'+weissmehrno).innerHTML + '</div>';
	jQuery(document).ready(function() {
	$.fancybox(
		temp,
		{
				'titleShow'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'overlayShow'       : false,
				'showCloseButton'	: false,
				'centerOnScroll'	: true
		}
	);
	});
}

function doCreateMediaboxContent(Path,Name,Width,Height,Link,LinkTitle){
	var temp = '';
	temp = '<img src="' + PHLpath + Path + '" alt="'+ Name +'" width="' + Width + '" height="' + Height +'" border="0"/>';
	if(Link != ''){
			temp = '<a href="javascript:void(true);" onClick="' + Link +'" title="' + LinkTitle +'">' + temp +'</a>';
	}	
	return temp;
}

function showMediaboxThumbContent(ID,No){
	var temp = this["mediabox" + ID][No];
	var content = "";
	content = '<img src="' + PHLpath + temp['thumbpath'] + '" alt="'+ temp['name'] +'" width="' + temp['thumbwidth'] + '" height="' + temp['thumbheight'] +'" border="0"/>';
	return content;
}
function returnMediaboxContent(ID,No){
	var temp = this["mediabox" + ID][No];
	var content = "";
	if(temp['type'] == 'img'){
		content = '<img src="' + PHLpath + temp['path'] + '" alt="'+ temp['name'] +'" width="' + temp['width'] + '" height="' + temp['height'] +'" border="0" />';
	}else if(temp['type'] == 'swf'){
		content = "<object data=\"" + temp['path'] + "\" type=\"application/x-shockwave-flash\" width=\"" + temp['width'] + "\" height=\"" + temp['height'] + "\"><param name=\"movie\" value=\"" + temp['path'] + "\"><param name=\"wmode\" value=\"transparent\"><param name=\"quality\" value=\"high\"><param name=\"scale\" value=\"exactfit\"><param name=\"menu\" value=\"true\"></object>";
	};	
	return content;
}

function showMediaboxContent(ID,No){
	var temp = this["mediabox" + ID];
	var temp2 = "mediaboxno" + ID;
	var activeno = this["mediabox" + ID + "active"];
	var temp3 = "";
	var temp4 = "";
	if(document.getElementById(temp2)){
		document.getElementById(temp2 + "image").innerHTML = returnMediaboxContent(ID,No);
		
		if(No != this["mediabox" + ID + "active"] && temp.length > 3){ 
			/* Thumb 1 */
			if(document.getElementById(temp2 + "thumb1")){
				if(No > 0){
					temp4 = (No - 1);
				}else{
					temp4 = temp.length-1;
				};
				temp3 = temp[temp4];
				document.getElementById(temp2 + "thumb1").innerHTML = doCreateMediaboxContent(temp3['thumbpath'],temp3['name'],temp3['thumbwidth'],temp3['thumbheight'],'showMediaboxContent(' + ID + ',' + temp4 +');','');
			};
			
			/* Thumb 2 */
			if(document.getElementById(temp2 + "thumb1")){
				temp4 = No;
				temp3 = temp[temp4];
				document.getElementById(temp2 + "thumb2").innerHTML = doCreateMediaboxContent(temp3['thumbpath'],temp3['name'],temp3['thumbwidth'],temp3['thumbheight'],'showMediaboxContent(' + ID + ',' + temp4 +');','');
			};
			
			/* Thumb 3 */
			if(document.getElementById(temp2 + "thumb3")){
				temp4 = '';
				if((No+1) >= (temp.length)){
					temp4 = 0;
				}else{
					temp4 = (No + 1);
				};
				temp3 = temp[temp4];
				document.getElementById(temp2 + "thumb3").innerHTML = doCreateMediaboxContent(temp3['thumbpath'],temp3['name'],temp3['thumbwidth'],temp3['thumbheight'],'showMediaboxContent(' + ID + ',' + temp4 + ');','');
			};
		}
		
		this["mediabox" + ID + "active"] = No;
	}
	
}

function showMediaboxPrevContent(ID){
	var temp = this["mediabox" + ID];
	var activeno = this["mediabox" + ID + "active"];
	if(activeno > 0){
		var temp2 = (activeno-1);
	}else{
		var temp2 = temp.length-1;
	};
	showMediaboxContent(ID,temp2);
}

function showMediaboxNextContent(ID){
	var temp = this["mediabox" + ID];
	var activeno = this["mediabox" + ID + "active"];
	if(activeno < (temp.length-1)){
		var temp2 = activeno+1;
	}else{
		var temp2 = 0;
	};
	showMediaboxContent(ID,temp2);
}

function doCreateMediabox(ID){
	var temp = this["mediabox" + ID];
	var temp2 = "mediaboxno" + ID;
	activeno = this["mediabox" + ID + "active"];
	if(document.getElementById(temp2)){
		if(temp.length > 1){
			temp3 = temp[1];
			document.getElementById(temp2 + "image").innerHTML = returnMediaboxContent(ID,'1');
			activeno = 1;
			this["mediabox" + ID + "active"] = activeno;
		}else{
			temp3 = temp[0];
			document.getElementById(temp2 + "image").innerHTML = returnMediaboxContent(ID,'0');
			activeno = 0;
			this["mediabox" + ID + "active"] = activeno;
		}
		
		/* Thumb 1 */
		if(document.getElementById(temp2 + "thumb1")){
			temp3 = temp[0];
			document.getElementById(temp2 + "thumb1").innerHTML = doCreateMediaboxContent(temp3['thumbpath'],temp3['name'],temp3['thumbwidth'],temp3['thumbheight'],'showMediaboxContent(' + ID + ',0);','');
		};
		
		/* Thumb 2 */
		if(temp.length > 1 && document.getElementById(temp2 + "thumb2")){
			temp3 = temp[1];
			document.getElementById(temp2 + "thumb2").innerHTML = doCreateMediaboxContent(temp3['thumbpath'],temp3['name'],temp3['thumbwidth'],temp3['thumbheight'],'showMediaboxContent(' + ID + ',1);','');
		};
		
		/* Thumb3 */
		if(temp.length > 2 && document.getElementById(temp2 + "thumb3")){
			temp3 = temp[2];
			document.getElementById(temp2 + "thumb3").innerHTML = doCreateMediaboxContent(temp3['thumbpath'],temp3['name'],temp3['thumbwidth'],temp3['thumbheight'],'showMediaboxContent(' + ID + ',2);','');
		};
		
		/* Back / Forward */
		if(temp.length > 1 && document.getElementById(temp2 + "back")){
			document.getElementById(temp2 + "back").innerHTML = '<a href="javascript:void(true)" title="Zurück" onClick="showMediaboxPrevContent('+ ID +');"><img src="' + PHLpathstatic + 'mediabox_'+aktiveSeite+'_zurueck.png" width="30" height="35" alt="Zurück" border="0" /></a>';
		}
		if(temp.length > 1 && document.getElementById(temp2 + "forward")){
			document.getElementById(temp2 + "forward").innerHTML = '<a href="javascript:void(true)" title="Weiter" onClick="showMediaboxNextContent('+ ID +');"><img src="' + PHLpathstatic + 'mediabox_'+aktiveSeite+'_weiter.png" width="30" height="35" alt="Weiter" border="0" /></a>';
		}

	}
}

function getRandom( min, max ) {
	if( min > max ) {
		return( -1 );
	}
	if( min == max ) {
		return( min );
	}
	return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}

function DrachenBoxRandom(){
	var nr = getRandom(0, maxDragoObjects);
	var el = document.getElementById('drachen' + nr);
	drachenboxaktiv = nr;
	if (el) {
		el.style.display = 'block';
	}
}
