﻿window.onresize = setBackgroundSize;
window.onscroll = setBackgroundSize;
function setBackgroundSize() {
    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;
    }
    // Get scroll offsets
    var scrollOffsets = getScrollXY();
    var backgroundContainer = document.getElementById("dimBackground");
//    backgroundContainer.style.width = myWidth;
    backgroundContainer.style.height = document.body.scrollHeight;
    backgroundContainer.style.width = scrollOffsets[0] + myWidth;
    //backgroundContainer.style.height = scrollOffsets[1] + myHeight;
    
    // Now centre the message div within.
    var messageContainer = document.getElementById("messageDiv");
    messageContainer.style.height = myHeight*3/4 ;
    messageContainer.style.width = myWidth / 2;
    messageContainer.style.top = scrollOffsets[1] + (myHeight / 8);
    messageContainer.style.left = myWidth / 4;
}
function getScrollXY() {
    var scrOffX = 0, scrOffY = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOffY = window.pageYOffset;
        scrOffX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOffY = document.body.scrollTop;
        scrOffX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOffY = document.documentElement.scrollTop;
        scrOffX = document.documentElement.scrollLeft;
    }
    return [scrOffX, scrOffY];
}
function dimBackground() {
    setBackgroundSize();
    document.getElementById('dimBackground').style.display = "";
    document.body.offsetHeight
}
function showBackground() {
    document.getElementById('dimBackground').style.display = "none";
}
function showMessage(message) {
    dimBackground();
    document.getElementById('messageDiv').style.display = "";
    document.getElementById('messageDiv_message').innerHTML = message;
}
function hideMessage() {
    showBackground();
    document.getElementById('messageDiv').style.display = "none";
}