﻿var popupInfoStatus = 0;


function loadPopupInfo() {
    if (popupInfoStatus == 0) {
        $("popupInfoBackground").setStyle("opacity", "0.7");
        $("popupInfoContainer").setStyle("display", "block");
        $("popupInfoBackground").setStyle("display", "block");
        popupInfoStatus = 1;
    }
}

function disablePopupInfo() {
    document.getElementById("popupInfoContainer").style.display = 'none';
    document.getElementById("popupInfoBackground").style.display = 'none';
    popupInfoStatus = 0;
}

function centerPopupInfo() {
    var rootObject = (document.documentElement && document.compatMode == 'CSS1Compat') ? document.documentElement : document.body;
    var vpWidth = self.innerWidth ? self.innerWidth : rootObject.clientWidth; // viewport width
    var vpHeight = self.innerHeight ? self.innerHeight : rootObject.clientHeight; // viewport height 

    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;

    var popupHeight = $("popupInfoContainer").getStyle("height").toInt();
    var popupWidth = $("popupInfoContainer").getStyle("width").toInt();
    if (popupHeight == 0) popupHeight = 600;
    if (popupWidth == 0) popupWidth = 460;

    $("popupInfoContainer").setStyle("position", "absolute");
    //$("popupInfoContainer").setStyle("top", (rootObject.scrollTop + ((windowHeight / 2) - (popupHeight / 2) + 10)) + "px");
    $("popupInfoContainer").setStyle("top", "123px");
    $("popupInfoContainer").setStyle("left", ((vpWidth / 2) - (popupWidth / 2) -20) + "px");
    //only need force for IE6
    $("popupInfoBackground").setStyle("height", windowHeight);
}

function setCookie(c_name, expireHours) {
    var exdate = new Date();
    exdate.setHours(exdate.getHours() + expireHours);
    document.cookie = c_name + "=1" + ((expireHours == null) ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}
