﻿function getWindowHeight() {
    if (document.body.scrollHeight)
        return document.body.scrollHeight;
    return document.documentElement.offsetHeight;
}

function windowVisibleHeight() {
    var 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;
    }
}



function setLeft(modalContainerId, width) {
    var left = ($(window).width() - width) / 2 + 15;
    $('#' + modalContainerId).css('left', left + 'px');
}

function setRight(modalContainerId) {
    var top = (windowVisibleHeight() - 360) / 2 + 15;
    $('#' + modalContainerId).css('top', top + 'px');

}

function callModal(modalContainerId, width) {
    $(window).resize(function () {
        setLeft(modalContainerId);
        setRight(modalContainerId);
        $('#simplemodal-overlay').css('height', getWindowHeight() + 'px');
    });
    setLeft(modalContainerId, width);
    $('#' + modalContainerId).css('display', 'block');
    //$('.modal-window').css('display', 'block');
    $('#simplemodal-overlay').css('display', 'block');
    $('#simplemodal-overlay').css('height', getWindowHeight() + 'px');
}

function callModalOverlay(overlayId, modalContainerId, width) {
    $(window).resize(function () {
        setLeft(modalContainerId);
        setRight(modalContainerId);
        $('#' + overlayId).css('height', getWindowHeight() + 'px');
    });
    setLeft(modalContainerId, width);
    $('#' + modalContainerId).css('display', 'block');
    //$('.modal-window').css('display', 'block');
    $('#' + overlayId).css('display', 'block');
    $('#' + overlayId).css('height', getWindowHeight() + 'px');
}

function closeModal(modalContainerId) {
    $('.videoPlayerContainer').html('<div id="Player"></div>');
    $('#' + modalContainerId).css('display', 'none');
    $('.simplemodal-overlay').css('display', 'none');
}
