﻿

var myWidth = "";
var myHeight = "";
setWindowSize();
function setWindowSize() {

    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;
    }

}




var pageScrollPositionX = 0;
var pageScrollPositionY = 0;
var ScrollingInterval = null;
function getScrollXY_Background() {
    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;
    }
    pageScrollPositionX = scrOfX;
    pageScrollPositionY = scrOfY;

    var newdivElement = document.getElementById("divMrTransparentBackground");
    newdivElement.style.top = pageScrollPositionY;
    newdivElement.style.left = pageScrollPositionX;
}

window.onresize = function() {
    if (document.getElementById("divMrTransparentBackground")) {
        var divMrTransparentBackground = document.getElementById("divMrTransparentBackground");
        setWindowSize();
        divMrTransparentBackground.style.width = myWidth + "px";
        divMrTransparentBackground.style.height = myHeight + "px";
     }

}

function CreateTransparentDiv(zIndexParam) {
    var newdiv = document.createElement("div");
    newdiv.id = "divMrTransparentBackground";
    newdiv.style.position = "absolute";
    newdiv.style.width = myWidth + "px";
    newdiv.style.height = myHeight + "px";
    newdiv.style.top = "0px";
    newdiv.style.left = "0px";
    newdiv.style.paddingLeft = "0px";
    newdiv.style.paddingTop = "0px";
    newdiv.style.display = "none";
    newdiv.style.zIndex = "10000";
    newdiv.style.backgroundColor = "#000000";
    newdiv.style.opacity = "0.63";
    newdiv.style.filter = "alpha(opacity=63)";
    var DisplayMrTransparentBackground = document.getElementById("DisplayMrTransparentBackground");


    if (navigator.appName.toString().toLowerCase().search("microsoft") != -1) {
        DisplayMrTransparentBackground.style.position = "absolute";
     }
    else {
        DisplayMrTransparentBackground.style.position = "fixed";
    }
    
  
    DisplayMrTransparentBackground.style.top = "0px";
    DisplayMrTransparentBackground.style.left = "0px";
    DisplayMrTransparentBackground.style.zIndex = zIndexParam;
    DisplayMrTransparentBackground.appendChild(newdiv);
}




function DisplayMrTransparentBackground(zIndexParam) {

    if (document.getElementById("divMrTransparentBackground")) {
        document.getElementById("divMrTransparentBackground").style.display = "";
     }
    else { CreateTransparentDiv(zIndexParam); }
    ScrollingInterval = setInterval("getScrollXY_Background()", 100);
    document.getElementById("divMrTransparentBackground").style.display = "";
}

function HideMrTransparentBackground() {
    clearInterval(ScrollingInterval);
    document.getElementById("divMrTransparentBackground").style.display = "none";
}
