var xmlHttp

function ShowWhatsThis(bool) {
    if (!bool) {
        document.getElementById("popupWhatsthis").innerHTML = "";
        document.getElementById("popupWhatsthis").style.display = "none";
        return;
    }
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        return;
    }
    document.getElementById("popupWhatsthis").style.display = "block";
    var url = "/global/general%20settings/whats-this.aspx";
    xmlHttp.onreadystatechange = WTstateChanged;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    ShowPrivacyPolicy(false);
}

function WTstateChanged() {
    if (xmlHttp.readyState == 4) {
        document.getElementById("popupWhatsthis").innerHTML = xmlHttp.responseText;
    }
}

function ShowPrivacyPolicy(bool) {
    if (!bool) {
        document.getElementById("popupPrivacy").innerHTML = "";
        document.getElementById("popupPrivacy").style.display = "none";
        return;
    }
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        return;
    }
    document.getElementById("popupPrivacy").style.display = "block";
    var url = "/global/general%20settings/privacy-policy.aspx";
    xmlHttp.onreadystatechange = PPstateChanged;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    ShowWhatsThis(false);
}

function PPstateChanged() {
    if (xmlHttp.readyState == 4) {
        document.getElementById("popupPrivacy").innerHTML = "<div class=\"privacyFilter pngWrapper\"><div id=\"scrollDiv\" class=\"innerScroll\">" + xmlHttp.responseText + "</div><a onclick=\"ShowPrivacyPolicy(false)\" style=\"cursor: pointer;\" class=\"close\" style=\"color:#fff\">Close</a></div>";
    }
}

function ShowPopupPP(loopIndex, ok) {
    myLoopIndex = loopIndex;
    if (!ok) {
        document.getElementById("popupPP" + loopIndex).innerHTML = "";
        document.getElementById("popupPP" + loopIndex).style.display = "none";
        return;
    }
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        return;
    }
    document.getElementById("popupPP" + loopIndex).style.display = "block";
    var url = "/global/general%20settings/privacy-policy.aspx";
    xmlHttp.onreadystatechange = PPPopUpstateChanged;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function PPPopUpstateChanged() {
    if (xmlHttp.readyState == 4) {
        document.getElementById("popupPP" + myLoopIndex).innerHTML = "<div class=\"friendFilter pngWrapper\"><div id=\"scrollDiv\" class=\"innerScroll\">" + xmlHttp.responseText + "</div><a onclick=\"ShowPopupPP(" + myLoopIndex + ",false)\" style=\"cursor: pointer;\" class=\"close\" style=\"color:#fff\">Close</a></div>";
    }
}

function ShowSendToFriend(bool) {
    if (!bool) {
        document.getElementById("popupFriend").innerHTML = "";
        document.getElementById("popupFriend").style.display = "none";
        return;
    }
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        return;
    }
    document.getElementById("popupFriend").style.display = "block";
    var url = "/global/general%20settings/sendtofriend.aspx";
    xmlHttp.onreadystatechange = STFstateChanged;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    ShowPrivacyPolicy(false);
}

function STFstateChanged() {
    if (xmlHttp.readyState == 4) {
        document.getElementById("popupFriend").innerHTML = xmlHttp.responseText;
    }
}

function showProductHint2() {
    new Ajax.Autocompleter("keyword", "popupProducts", "/global/general%20settings/advancedproductsearch.aspx", { paramName: "q", minChars: 3 });
}

function showProductHint(str) {
    if (str.length < 2) {
        document.getElementById("popupProducts").innerHTML = "";
        document.getElementById("popupProducts").style.display = "none";
        return;
    }
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        return;
    }
    var url = "/global/general%20settings/advancedproductsearch.aspx";
    url = url + "?q=" + str;
    xmlHttp.onreadystatechange = stateChangedProduct;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function stateChangedProduct() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.responseText.length > 10) {
            document.getElementById("popupProducts").style.display = "block";
            document.getElementById("popupProducts").innerHTML = xmlHttp.responseText;
        }
    }
}

function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function clickButton(e, buttonid) {
    var bt = document.getElementById(buttonid);
    if (typeof bt == 'object') {
        if (navigator.appName.indexOf("Netscape") > (-1)) {
            if (e.keyCode == 13) {
                bt.click();
                return false;
            }
        }
        if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1)) {
            if (event.keyCode == 13) {
                bt.click();
                return false;
            }
        }
    }
}
