//
// Popups.js
//
// required:  JQuery library to use this script
//
// var mp = null;
//
// function showPopup()
// {
//      var mp = new myPopup(id);
//      mp.center();
//      mp.load();
// }
//
//
// function hidePopup()
// {
//      if ( mp != null ) {
//          mp.disable();
//      }
// }
//


function myPopup(popupid)
{
    this.id = popupid;
    this.popupStatus = 0;
    return this;
}

myPopup.prototype.center = function()
{
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#"+this.id).height();
    var popupWidth = $("#"+this.id).width();

    //centering
    $("#"+this.id).css({
        "position": "absolute",
        "top": windowHeight/2-popupHeight/2 + $(window).scrollTop(),
        "left": windowWidth/2-popupWidth/2
    });

    //$("#backgroundPopup").css({"height": windowHeight,"background-color":"#333333"});
}

myPopup.prototype.load = function ()
{
    //loads popup only if it is disabled
    if ( this.popupStatus == 0 ){
        //$("#backgroundPopup").css({"opacity": "0.7","-moz-opacity":"0.7","-khtml-opacity":"0.7","filter":"alpha(opacity=7)"});
        //$("#backgroundPopup").fadeIn("slow");
        //$("#"+this.id).fadeIn("slow");
        $("#"+this.id).show("bounce",200);
        this.popupStatus = 1;
    }
}

myPopup.prototype.disable = function()
{
    //disables popup only if it is enabled
    if ( this.popupStatus == 1 ) {
        //$("#backgroundPopup").fadeOut("slow");
        $("#"+this.id).fadeOut("slow");
        this.popupStatus = 0;
    }
}




