var minFlashVersion 	= 10;
var flashContent;
var noFlashContent;
var flashVersion;

function openDatenschutz(){
	if(window.datenShutzWindow)
		window.datenShutzWindow.close();	
	window.datenShutzWindow = 
	window.open("Datenschutz.html",
		"teilnahmebedingungen",
		"toolbar=no"
		+ ",location=no"
		+ ",directories=no"
		+ ",status=no"
		+ ",menubar=no"
		+ ",scrollbars=yes"
		+ ",resizable=no"
		+ ",width="+500+",height="+600+", screenx=" + 10 + ", screeny=" + 50+ " ");
}
function openTeilnahme(){
	window.open("teilnahmebedingungen.html",
		"teilnahmebedingungen",
		"toolbar=no"
		+ ",location=no"
		+ ",directories=no"
		+ ",status=no"
		+ ",menubar=no"
		+ ",scrollbars=yes"
		+ ",resizable=no"
		+ ",width="+500+",height="+600+", screenx=" + 10 + ", screeny=" + 50+ " ");
}
function openTeilnahme2(){
	window.open("teilnahmebedingungen2.html",
		"teilnahmebedingungen",
		"toolbar=no"
		+ ",location=no"
		+ ",directories=no"
		+ ",status=no"
		+ ",menubar=no"
		+ ",scrollbars=yes"
		+ ",resizable=no"
		+ ",width="+500+",height="+600+", screenx=" + 10 + ", screeny=" + 50+ " ");

}
function popUp(src){
window.open(src,
		"teilnahmebedingungen",
		"toolbar=no"
		+ ",location=no"
		+ ",directories=no"
		+ ",status=no"
		+ ",menubar=no"
		+ ",scrollbars=yes"
		+ ",resizable=no"
		+ ",width="+500+",height="+600+", screenx=" + 10 + ", screeny=" + 50+ " ");

}



function redirectIfNeedet(){
	var urlSplitted = window.location.href.split("/");
	if(urlSplitted.length > 3 && urlSplitted[3] != "#" && urlSplitted[3] != ""){
		urlSplitted.splice(0,3);
		var newUrl = "/#/"+urlSplitted.join("/");
		// patch...
		newUrl = newUrl.replace(/\/qualit.+?t/,"/qualitaet");
		location.href = newUrl;
		return;
	}
}

function detectFlashLoader(){
	var flashVersion = swfobject.ua.pv[0];
	if (flashVersion >= minFlashVersion ){
		flashContent.style.display = "block";
		if(location.href.indexOf("#") != -1)
		{
			loadFlash("WeihnStephan");
		}
		else
		{
			loadFlash("WSWeiche");
		}
	}
	else
	{	// HTML 
		noFlashContent.style.display="";			
	}

}

function loadFlash(swf)
{
	var url;
	if(swf == "WeihnStephanLight")
		url = "flash/WeihnStephan.swf?lightVersion=1&v="+Math.random();
	else
		url = "flash/"+swf+".swf?v="+Math.random();
	
	//#305093
	var flashvars	= {};
	var params		= {menu:"false",allowFullScreen:"true",bgcolor:"#305093"};
	var attributes	= {};

	swfobject.embedSWF(url, "flashContent", "100%", "100%", "9.0.0","/scripts/swfobject/expressInstall.swf", flashvars, params, attributes);
}

window.onload = function()
{
	flashContent 		= document.getElementById("flashContent");
	noFlashContent 		= document.getElementById("noFlashContent");
	
	swfobject.registerObject("flashContent", "9.0.115", "/scripts/swfobject/expressInstall.swf");
	
	redirectIfNeedet();
	detectFlashLoader();
}
