//SETTING UP OUR POPUP  
//0 means disabled; 1 means enabled;  
//var popupStatus = 0; 


//loading popup with jQuery magic!  
function loadPopup(popup_id, width, height)
{
    centerPopup(popup_id, width, height);
    $("#backgroundPopup").css({  
       "opacity": "0.7"  
        });  
    $("#backgroundPopup").fadeIn();
    $("#"+popup_id).fadeIn();
    popup_is_loaded = 1;
}  
  
//disabling popup with jQuery magic!  
function disablePopup(popup_id)
{  
    
    $("#backgroundPopup").fadeOut();  
    if (popup_id){
        $("#"+popup_id).fadeOut();  
    }else{
        $("div.popup__popup_container").each(function(){
            $(this).fadeOut();  
        });
    }
    popup_is_loaded = 0;
}  

function centerPopup(popup_id,width, height)
{
    //request data for centering  
    var windowWidth = document.documentElement.clientWidth;  
    var windowHeight = document.documentElement.clientHeight;  
    if(height){
        popupHeight = height;  
    }else{
        popupHeight = $("#"+popup_id).height();  
    }
    if(width){
        popupWidth = width;  
    }else{
        popupWidth = $("#"+popup_id).width();  
    }
    //centering  
    if($.browser.msie && $.browser.version=="6.0"){
        $("#"+popup_id).css({  "position": "absolute",  "top": windowHeight/2-popupHeight/2,  "left": windowWidth/2-popupWidth/2 });  
    }else{
        $("#"+popup_id).css({"top": windowHeight/2-popupHeight/2,  "left": windowWidth/2-popupWidth/2, "height": height });  
        
    }
    if (width){
        $("#"+popup_id).css({ "width": width });  
    }
    if (height ){
        $("#"+popup_id).css({ "height": height  });  
    }
    //only need force for IE6  
    $("#backgroundPopup").css({  
        "height": $(document).height()
    }).css({  
        "width": $(document).width()
    });  
}