﻿var popupStatus = 0;function loadPopup() {   
    if (popupStatus == 0) {
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#popupContact").fadeIn("slow");
        try{
        $("#iframe1").fadeIn("slow");
        }
        catch(e){}
        popupStatus = 1;
    }}
function disablePopup() {
    if (popupStatus == 1) {
        window.onresize = null;
        $("#backgroundPopup").fadeOut("slow");
        $("#popupContact").fadeOut("slow");
        try {
            $("#iframe1").fadeOut("slow");
        }
        catch (e) { }       
        popupStatus = 0;
    }}
function centerPopup() {
    var windowWidth = 0;var windowHeight = 0; 
    if (window.innerWidth)
        windowWidth = window.innerWidth;
    else if ((document.body) && (document.body.clientWidth)) windowWidth = document.body.clientWidth;   
    if (window.innerHeight)  windowHeight = window.innerHeight;
    else if ((document.body) && (document.body.clientHeight))
        windowHeight = document.body.clientHeight;    
    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
        windowHeight = document.documentElement.clientHeight; windowWidth = document.documentElement.clientWidth;
    }
    var popupHeight = $("#popupContact").height();
    var popupWidth = $("#popupContact").width();   
    $("#popupContact").css({
        "position": "absolute",
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });   
    $("#backgroundPopup").css({
        "height": windowHeight,
        "width": windowWidth
    });
    try {
        $("#iframe1").css({
        "position": "absolute",
        "height": windowHeight,
        "width": windowWidth
        });
    }
    catch (e) { }
}
function InitDiv() {
    centerPopup();
    loadPopup();
    window.onresize = centerPopup;
}
$(document).ready(function() {
    $("#popupContactClose").click(function() {
        disablePopup();
    });
    $("#ok").click(function() {
        disablePopup();
    });
    $("#backgroundPopup").click(function() {
        disablePopup();
    });
    $(document).keypress(function(e) {
        if (e.keyCode == 27 && popupStatus == 1) {
            disablePopup();
        }
    });

});


