var openedPopup;
//centering popup
    function centerPopup(id) {
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $("#"+id).height();
        var popupWidth = $("#"+id).width();

        //centering
        $("#"+id).css({
            "position": "fixed",
            "top": (windowHeight / 2 - popupHeight / 2),
            "left": windowWidth / 2 - popupWidth / 2
        });
        //only need force for IE6

        $("#backgroundPopup").css({
            "height": windowHeight
        });
    }

    //loading popup with jQuery magic!
    function loadPopup(id) {
        //$(document.body).css("overflow", "hidden");
        centerPopup(id);

        //loads popup only if it is disabled
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#"+id).fadeIn("slow");
		
		openedPopup = "#"+id;
    }

    //disabling popup with jQuery magic!
    function disablePopup(id) {
        //disables popup only if it is enabled
        $("#backgroundPopup").fadeOut("slow");
        $(openedPopup).fadeOut("slow");

        //$(document.body).css("overflow", "visible");
    }

    $(document).ready(function() {
        $(".popupContactClose").click(function() {
            disablePopup();
        });
        //Click out event!
        $("#backgroundPopup").click(function() {
            disablePopup();
        });
        //Press Escape event!
        $(document).keypress(function(e) {
            if (e.keyCode == 27 && popupStatus == 1) {
                disablePopup();
            }
        });
        //loadPopup();
    });
