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 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);
}



function openDealerLocator(refForm, sWidth, sHeight, sName, sUrl)
{
	if (!sUrl) sUrl = "";
	
	var topOffset = 40;
	
	if (sHeight > (self.screen.availHeight + topOffset - 40))
	{
		sHeight = self.screen.availHeight - 40;
		topOffset = 0;
	}

    newWin = window.open(sUrl, sName, "width=" + sWidth + ",height=" + sHeight + ",left=40,top=" + topOffset + ",dependent=yes,location=no,resizable=no,scrollbars=no,status=no");

	if (refForm)
	{
		refForm.target=sName;
		return true;
	}
}

function openWindow(sURL, iWidth, iHeight) {
	var sProps = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=" + Math.round((screen.width - iWidth) / 2) + ",top=" + Math.round((screen.height - iHeight) / 2) + ",width=" + iWidth + ",height=" + iHeight;
	var miscWin = window.open(sURL, "miscWin", sProps);
	miscWin.focus();
}