﻿function getDocHeight() {
    var D = document;
    return Math.max(
                Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
                Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
                Math.max(D.body.clientHeight, D.documentElement.clientHeight)
                );
}
function getDocWidth() {
    var D = document;
    return Math.max(
                Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
                Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
                Math.max(D.body.clientWidth, D.documentElement.clientWidth)
                );
}

function showPanel(panelID) {    
    document.getElementById(panelID).style.display = "block";
}

function show(panelID) {
    //document.getElementById(panelID).style.display = "block";
    //alert(panelID);
    document.getElementById("overlayLoadedContent").innerHTML = document.getElementById(panelID).innerHTML;
    document.getElementById(panelID).innerHTML = "";
    document.getElementById("overlay").style.display = "block";
    document.getElementById("overlayContent").style.display = "block";
    document.getElementById("overlay").style.height = getDocHeight() + "px";
    document.getElementById("overlay").style.width = getDocWidth() + "px";
    FullScreen(1);
    return false;
}

function hideOverLay(panelID) {
    document.getElementById(panelID).innerHTML = document.getElementById("overlayLoadedContent").innerHTML;
    document.getElementById("overlayLoadedContent").innerHTML = "";
    document.getElementById("overlay").style.display = "none";
    document.getElementById("overlayContent").style.display = "none";
    return false;
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
    alert(window.onload);
}

function FullScreen(mod) {
    if (mod == null) {
        if (document.getElementById('overlayLoadedContent').style.left == "") {
            document.getElementById('overlayLoadedContent').style.left = "0";
            document.getElementById('overlayLoadedContent').style.top = "0";
            document.getElementById('overlayLoadedContent').style.width = "100%";
            document.getElementById('overlayLoadedContent').style.height = "100%";
            document.getElementById('overlayLoadedContent').style.position = "fixed";
            document.getElementById('buttonFullscreen').style.backgroundImage = "url(/App_Themes/Default/images/overlayButtonNotFullscreen.png)";
        }
        else {
            document.getElementById('overlayLoadedContent').style.left = "";
            document.getElementById('overlayLoadedContent').style.top = "";
            document.getElementById('overlayLoadedContent').style.width = "590px";
            document.getElementById('overlayLoadedContent').style.width = "";
            document.getElementById('overlayLoadedContent').style.position = "relative";
            document.getElementById('buttonFullscreen').style.backgroundImage = "url(/App_Themes/Default/images/overlayButtonFullscreen.png)";
        }
    }
    else
    {
        if (mod == 1) {
            document.getElementById('overlayLoadedContent').style.left = "0";
            document.getElementById('overlayLoadedContent').style.top = "0";
            document.getElementById('overlayLoadedContent').style.width = "100%";
            document.getElementById('overlayLoadedContent').style.height = "100%";
            document.getElementById('overlayLoadedContent').style.position = "fixed";
            document.getElementById('buttonFullscreen').style.backgroundImage = "url(/App_Themes/Default/images/overlayButtonNotFullscreen.png)";
        }
        
    }
}

function NotFullScreen() {
    document.getElementById('overlayLoadedContent').style.left = "";
    document.getElementById('overlayLoadedContent').style.left = "";
    document.getElementById('overlayLoadedContent').style.width = "590px";
    document.getElementById('buttonFullscreen').style.backgroundImage = "url(/App_Themes/Default/images/overlayButtonFullscreen.png)";    
}
