﻿
var gCurrentLayerID = null;

function getBrowserHeight() {
    var intH = 0;
    var intW = 0;

    if (typeof window.innerWidth == 'number') {
        intH = window.innerHeight;
        intW = window.innerWidth;
    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        intH = document.documentElement.clientHeight;
        intW = document.documentElement.clientWidth;
    }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        intH = document.body.clientHeight;
        intW = document.body.clientWidth;
    }
    return { width: parseInt(intW), height: parseInt(intH) };
}

function setLayerPosition() {
    if (gCurrentLayerID != null) {
        var shadow = document.getElementById('shadow');
        var question = document.getElementById(gCurrentLayerID);

        var bws = getBrowserHeight();
        shadow.style.width = bws.width + 'px';
        shadow.style.height = bws.height + 'px';
        question.style.left = parseInt((bws.width - 350) / 2) + 'px';
        question.style.top = parseInt((bws.height - 200) / 2) + 'px';
        shadow = null;
        question = null;
    }
}

function showLayer(layerId) {
    gCurrentLayerID = layerId;
    setLayerPosition();

    var shadow = document.getElementById('shadow');
    var question = document.getElementById(layerId);

    shadow.style.display = 'block';
    question.style.display = 'block';

    shadow = null;
    question = null;
}

function hideLayer(layerId) {
    var shadow = document.getElementById('shadow');
    var question = document.getElementById(layerId);

    shadow.style.display = 'none';
    question.style.display = 'none';

    shadow = null;
    question = null;
    gCurrentLayerID = null;
}

window.onresize = setLayerPosition;
