﻿function getWindowHeight() {
    var windowHeight1 = 0;
    var windowHeight2 = 0;
    if (document.documentElement && document.documentElement.clientHeight) {
        windowHeight1 = document.documentElement.clientHeight;
    }

    if (document.body && document.body.clientHeight) {
        windowHeight2 = document.body.clientHeight;
    }
    if (windowHeight1 >= windowHeight2) {
        return windowHeight1;
    } else if (windowHeight1 < windowHeight2) {
        return windowHeight2;
    }
}
function getWindowWidth() {
    var windowWidth = 0;
    if (typeof (window.innerHeight) == 'number') {
        windowWidth = window.innerWidth;
    }
    else {
        if (document.documentElement && document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        }
        else {
            if (document.body && document.body.clientWidth) {
                windowWidth = document.body.clientWidth;
            }
        }
    }
    return windowWidth;
}
function setHeight(wrapperElementName) {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) {
            var wraperElement = document.getElementById(wrapperElementName);
            if (wraperElement.offsetHeight < windowHeight) {
                wraperElement.style.height = windowHeight + 'px';
            }
        }
    }
}
//function setPopupMargins() {
//    if (document.getElementById) {
//        var popupElement = document.getElementById('gallerypopup_holder');

//        popupElement.style.margin = '-' + (popupElement.offsetHeight / 2) + 'px 0 0 -' + (popupElement.offsetWidth / 2) + 'px';
//    }
//}

function setPopupCoordinates(popupElementName) {
    if (document.getElementById) {
        
        var popupElement = document.getElementById(popupElementName);
        var scrollXY = getScrollXY();
        
        popupElement.style.left = ((document.documentElement.clientWidth / 2) - (popupElement.offsetWidth / 2)) + scrollXY[0] + 'px';
        popupElement.style.top = ((document.documentElement.clientHeight / 2) - (popupElement.offsetHeight / 2)) + scrollXY[1] + 'px';
    }
}

function getScrollXY() {
    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;
    }
    return [scrOfX, scrOfY];
}

//function setWidth() {
//    if (document.getElementById) {
//        var windowWidth = getWindowWidth();
//        if (windowWidth > 0) {
//            var wraperElement = document.getElementById('back_black');
//            wraperElement.style.width = windowWidth + 'px';
//        }
//    }
//}

//-->
