﻿/// <reference path="~/Scripts/jquery-1.5.1-vsdoc.js"/>
/// <reference path="~/Scripts/jquery-ui-1.8.11.min.js"/>

//
//
//
//
//

var MenuStatus = 0;

//Load the Popup
function loadMenu() {
    //Load the popup only if it is hidden
    if (MenuStatus == 0) {
        $("#menuPopupWrapper").show({
            effect: "blind",
            duration: 200
        });

        $("#loginBackground").show();
        MenuStatus = 1;
    }
}

//Disable the Popup
function disableMenu() {
    //disables popup only if it is shown and not submitting
    if (MenuStatus == 1) {
        $("#menuPopupWrapper").hide({
            effect: "blind",
            duration: 200
        });
        $("#loginBackground").hide();
        MenuStatus = 0;
    }
}

function fixMenuBackground() {
    var windowHeight = document.documentElement.clientHeight;
    $("#loginBackground").css({
        "height": windowHeight
    });
}

//Triggers
$(document).ready(function () {

    //LOADING POPUP
    //Click the button event!
    $("#OpenMenuButton").click(function () {
        loadMenu();
    });
    //CLOSING POPUP
    //Click the x event!
    $("#loginBackground").click(function () {
        disableMenu();
    });
    //Press Escape event!
    $(document).keyup(function (e) {
        if (e.keyCode == 27) {
            if (MenuStatus == 1) {
                disableMenu();
            }
        }
    });
 });
