﻿
var centerPosX = getScreenCenterX();
var centerPosY = getScreenCenterY();
var clientTotalHeight = getInnerHeight();
var clientTotalWidth = document.body.clientWidth;

function showPopUp(el) {
    var cvr = document.getElementById("cover");
    var dlg = document.getElementById(el);
    cvr.style.display = "block";
    dlg.style.display = "block";
    if (document.body.style.overflow = "hidden") {
        cvr.style.width = clientTotalWidth + "px";
        cvr.style.height = clientTotalHeight + "px";
    }

    //positioning of dialog:
    dlg.style.top = (centerPosY - (dlg.clientHeight / 2)) + "px";
    dlg.style.left = (centerPosX - (dlg.clientWidth / 2)) + "px";

    return false;
}

function getScreenCenterY() {
    var y = 0;

    y = getScrollOffset() + (getInnerHeight() / 2);

    return (y);
}

function getScreenCenterX() {
    return (document.body.clientWidth / 2);
}

function getInnerHeight() {
    var y;
    if (self.innerHeight) // all except Explorer   
    {
        y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)   // Explorer 6 Strict Mode               
    {
        y = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers   
    {
        y = document.body.clientHeight;
    }
    return (y);
}

function getScrollOffset() {
    var y;
    if (self.pageYOffset) // all except Explorer   
    {
        y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict     
    {
        y = document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers   
    {
        y = document.body.scrollTop;
    }
    return (y);
}


function getScreenDimensions() {
    centerPosX = getScreenCenterX();
    centerPosY = getScreenCenterY();
    clientTotalHeight = getInnerHeight() + getScrollOffset();
    clientTotalWidth = document.body.clientWidth;

    var cvr = document.getElementById("cover")
    if (cvr != null && cvr.style.display == "block") {
        cvr.style.width = clientTotalWidth + "px";
        cvr.style.height = clientTotalHeight + "px";
    }
}        