﻿var popupStatus = 0;

function loadPopup() {
    if (popupStatus == 0) {
        jQuery("#backgroundPopup").css({ "opacity": "0.8" });
        jQuery("#backgroundPopup").fadeIn("slow");
        jQuery("#popupDeliveryInfo").fadeIn("slow");
        popupStatus = 1;

    }
}

function disablePopup() {
    if(popupStatus==1) {
        jQuery("#backgroundPopup").fadeOut("slow");
        jQuery("#popupDeliveryInfo").fadeOut("slow");
        popupStatus = 0;
    }
}

function centerPopup() {
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = jQuery("#popupDeliveryInfo").height();
    var popupWidth = jQuery("#popupDeliveryInfo").width();
   // alert("wWidth:" + windowWidth + " wHeight:" + windowHeight + " pWidth:" + popupWidth + "pHeight:" + popupHeight);
    jQuery("#popupDeliveryInfo").css({ "position": "absolute", "top": windowHeight / 2 - popupHeight / 2, "left": windowWidth / 2 - popupWidth / 2 });


    jQuery("#backgroundPopup").css({ "height": windowHeight });

}

//$(document).ready(function () {

//    alert("Ready");

//    $('deliveryMoreInfo').click(function () {
//        alert('Handler for .click() called.');
//    });

    //    $('#deliveryMoreInfo').click(function () {
    //        alert("Clicked");
    //        centerPopup();
    //        loadPopup();
    //    });

//    $("#popupDeliveryClose").click(function () {
//        disablePopup();
//    });

//    $("#backgroundPopup").click(function () {
//        disablePopup();
//    });

//    $(document).keypress(function (e) {
//        if (e.keyCode == 27 && popupStatus == 1) {
//            disablePopup();
//        }
//    });


//});

