var IsIE = false;

function logFlashVersion(installedFlashVer) {
    if (installedFlashVer) {
        var flashVerStr = getFlashPlatform() + ' ' + installedFlashVer.major + ',' + installedFlashVer.minor + ',' + installedFlashVer.release + ',0';
        var xmlhttp = createXMLHTTPObject();

        if (xmlhttp) {
            xmlhttp.open("GET", "/all/statistic/flash/?version=" + flashVerStr + "&statistic=v2", true);
            xmlhttp.send(null);
        }
    }
}

function getFlashPlatform() {
    var pp = 'n/a'
    var p = new platformDetect();
    if (p.isWin)
        pp = 'WIN';
    else if (p.isMac)
        pp = 'MAC';
    else if (p.isUnix)
        pp = 'UNIX';
    else if (p.isLinux)
        pp = 'LNX';
    else pp = 'OTHER';

    return pp;
}

var XMLHttpFactories = [
	function() { return new XMLHttpRequest() },
	function() { return new ActiveXObject("Msxml2.XMLHTTP") },
	function() { return new ActiveXObject("Msxml3.XMLHTTP") },
	function() { return new ActiveXObject("Microsoft.XMLHTTP") }
];

function createXMLHTTPObject() {
    var xmlhttp = false;
    for (var i = 0; i < XMLHttpFactories.length; i++) {
        try {
            xmlhttp = XMLHttpFactories[i]();
        }
        catch (e) {
            continue;
        }
        break;
    }
    return xmlhttp;
}
function showSite(sSiteURL, bandWidth, startWithLogin) {
	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 +",startWithLogin=" + startWithLogin;

	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);
	sSiteURL = sSiteURL + "&startWithLogin=" + escape(startWithLogin);
	var site = window.open(sSiteURL,"porschemicrosite", sProps);
	site.focus();		
}

function platformDetect()
{
    var ua = navigator.userAgent.toLowerCase(); 
   this.isWin    = (ua.indexOf('win') != -1);
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
}