﻿// SETTING UP OUR POPUP   
// 0 means disabled; 1 means enabled;   
function CVPopup (id)
{
    this.ctlid = id;
}


//loading popup 
CVPopup.prototype.load = function () {
    //loads popup only if it is disabled
    $("#backgroundPopup").css({
    "opacity": "0.5"
    });
    $("#backgroundPopup").fadeIn("fast");
    $("#" + this.ctlid).fadeIn("fast");
}


CVPopup.prototype.disable = function () {
    //disables popup only if it is enabled
    $("#backgroundPopup").fadeOut("fast");
    $("#" + this.ctlid).fadeOut("fast");
}


CVPopup.prototype.center = function () {
    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#" + this.ctlid).height();
    var popupWidth = $("#" + this.ctlid).width();
    
    //centering
    $("#" + this.ctlid).css({
        "position": "absolute",
        "top": windowHeight/2-popupHeight/2,
        "left": windowWidth/2-popupWidth/2
        });
}

