﻿var popupStatus = false;


function displayFancyLoginBox(itemId) {
    $('#' + itemId).fancybox();
}

function loadPopup() {   

    //loads popup only if it is disabled  
    if (!popupStatus) {
        /*$("#login_background").css({
            "opacity": "0.7"
        });*/

        $("#login_container").css({
            "opacity": "1.0"
        });
        
        $("#login_background").fadeIn("slow");
        $("#login_container").fadeIn("slow");
        
        popupStatus = true;
    }
    centerPopup();
}

function disablePopup() {
    //disables popup only if it is enabled  
    if (popupStatus) {
        $("#login_background").fadeOut("slow");
        $("#login_container").fadeOut("slow");
        popupStatus = false;
    }
}  

function centerPopup() {
    //request data for centering  
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#login_container").height();
    var popupWidth = $("#login_container").width();
    
    //centering
    $("#login_container").css({
        "position": "absolute",
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });
    
    //only need force for IE6
    $("#login_background").css({
        "height": windowHeight
    });

}


