var FlashVersion = 0;
var IsIE = 0;

function init() {	
	if (navigator.plugins &&
	    navigator.plugins.length > 0 &&
	    navigator.plugins["Shockwave Flash"]) {
	
	    var WordList = navigator.plugins["Shockwave Flash"].description.split(" ");
	
	    for (var index = 0; index < WordList.length; ++index) {
	        if (isNaN(parseInt(WordList[index])))  continue;
	        FlashVersion = WordList[index];
	    }
	}	

	if (FlashVersion < 7) showFallback();
	
	logFlashVersion(FlashVersion);	
} 


function logFlashVersion(ver) {
        var xmlhttp = false;
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	if (xmlhttp) {
		xmlhttp.open("GET", "/all/statistic/flash/?version=" + ver + "&statistic=v2", true);
		xmlhttp.send(null);
	}
}

function showSite(sSiteURL, bandWidth) {
	var width = screen.width; //950; //
	var height = screen.height; //590; //
	var left = (screen.width / 2) - ((width + 10) / 2); // 0;
	if (left < 0)
	    left = 0;
	var top = (screen.height / 2) - ((height + 55) / 2); //0;
	if (top < 0)
	    top = 0;

	/*
	if (screen.width > 1920)
	{
		width = 1920;
		height = 1200;
		left = Math.round((screen.width - width) / 2);
		top = Math.round((screen.height - height) / 2);
	}
	*/

	//var sProps = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=" + left + ",top=" + top + ",width=" + (width - 10) + ",height=" + (height - 55);
	var sProps = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=" + left + ",top=" + top + ",width=" + width + ",height=" + height;

	sSiteURL = sSiteURL + "?language=" + escape(sLanguage);
	sSiteURL = sSiteURL + "&market=" + escape(sMarket);
	sSiteURL = sSiteURL + "&pool=" + escape(sSiteId);
	sSiteURL = sSiteURL + "&browser=" + escape((IsIE == 1) ? "ie" : "other");	
	sSiteURL = sSiteURL + "&instance=" + escape(sInstance);
	sSiteURL = sSiteURL + "&variant=" + escape(sVariant);
	sSiteURL = sSiteURL + "&section=" + escape(sSection);
	sSiteURL = sSiteURL + "&showintro=" + escape(sShowIntro);
	sSiteURL = sSiteURL + "&bandwidth=" + escape(bandWidth);
	sSiteURL = sSiteURL + "&width=" + escape(width);
	sSiteURL = sSiteURL + "&height=" + escape(height);
	//sSiteURL = sSiteURL + "&width=" + escape(iWidth);
	//sSiteURL = sSiteURL + "&height=" + escape(iHeight);
	sSiteURL = sSiteURL + "&specialguest=" + escape(sSpecialguest);
	var site = window.open(sSiteURL,"porschemicrosite", sProps);
	site.focus();		
}

function showFallback() {
	window.document.getElementById("buttons").style.display = "none";
	window.document.getElementById("introText1").style.display = "none";
	window.document.getElementById("introText2").style.display = "none";
	window.document.getElementById("fallback").style.display = "block";
}