﻿

HC$(document).ready(function() {
    ShowStartUpPopup();
});





function ShowStartUpPopup() {
    centerAlertPopup('StartUpPopup');
    BackDivCall('StartUpPopup');
    HC$("#StartUpPopup").show();
}

function hidePopup() {
    HC$("#StartUpPopup").hide();
    HC$("#BackDIV").hide();
    
}



function centerAlertPopup(divId) {
    try {
        //request data for centering

        var windowDim = getWindowSize();


        var popupHeight = HC$("#" + divId).height();
        var popupWidth = HC$("#" + divId).width();
        var scroll = getScrollXY();


        HC$("#" + divId).css({
            "position": "absolute",
            "top": windowDim.Y / 2 - popupHeight / 2 + scroll.Y,
            "left": windowDim.X / 2 - popupWidth / 2 + scroll.X

        });
    }
    catch (Error) {
        TraceError(Error.message, 'PopupCenter.js:centerAlertPopup');
    }

}

function getWindowSize() {
    try {
        var myWidth = 0, myHeight = 0;
        if (typeof (window.innerWidth) == 'number') {
            //Non-IE 
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode' 
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            //IE 4 compatible 
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }
        return { X: myWidth, Y: myHeight }
    }
    catch (Error) {
        TraceError(Error.message, 'PopupCenter.js:getWindowSize');
    }
}

function getScrollXY() {
    try {
        var scrOfX = 0, scrOfY = 0;
        if (typeof (window.pageYOffset) == 'number') {
            //Netscape compliant 
            scrOfY = window.pageYOffset;
            scrOfX = window.pageXOffset;
        } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            //DOM compliant 
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
        } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
            //IE6 standards compliant mode 
            scrOfY = document.documentElement.scrollTop;
            scrOfX = document.documentElement.scrollLeft;
        }
        return { X: scrOfX, Y: scrOfY };
    }
    catch (Error) {
        TraceError(Error.message, 'PopupCenter.js:getScrollXY');
    }
}


function BackDivCall(divid) {
    try {
        popupid = divid;
        var WidthHeight = GetPageSizeWithScroll();
        var width = WidthHeight[0].split("px");
        var height = WidthHeight[1].split("px");

        document.getElementById("BackDIV").style.height = parseInt(height[0]) + 15 + "px";
        document.getElementById("BackDIV").style.width = screen.width;
        document.getElementById("BackDIV").style.display = 'block';
        var z = document.getElementById(divid).style.zIndex;
        document.getElementById("BackDIV").style.zIndex = z - 20;
    }
    catch (Error) {
        TraceError(Error.message, 'Common.js:BackDivCall');
    }
}

function GetPageSizeWithScroll() {
    if (window.innerHeight && window.scrollMaxY) {
        yWithScroll = (window.innerHeight + window.scrollMaxY) + "px";
        xWithScroll = (window.innerWidth + window.scrollMaxX) + "px";
    }
    else if (document.body.scrollHeight > document.body.offsetHeight) {
        yWithScroll = (document.body.scrollHeight) + "px";
        xWithScroll = (document.body.scrollWidth) + "px";
    }
    else {
        yWithScroll = (document.height || document.body.offsetHeight) + "px";
        xWithScroll = (document.width || document.body.offsetWidth) + "px";
    }
    arrayPageSizeWithScroll = new Array(xWithScroll, yWithScroll);
    return arrayPageSizeWithScroll;

}