//0 means disabled; 1 means enabled;  
var popupStatus = 0;  

function loadPopup(){  
  //loads popup only if it is disabled  
  if(popupStatus==0){  
    jQuery("#backgroundPopup").css({  
  	  "opacity": "0.7"  
    });  
    jQuery("#backgroundPopup").fadeIn("slow");  
    jQuery("#popup").fadeIn("slow");  
    popupStatus = 1;  
  }  
}

function disablePopup(){  
  //disables popup only if it is enabled  
  if(popupStatus==1){  
	jQuery("#backgroundPopup").fadeOut("slow");  
	jQuery("#popup").fadeOut("slow");  
	popupStatus = 0;
  }
}  

function centerPopup(){  
  //request data for centering  
  var windowWidth = document.documentElement.clientWidth;  
  var windowHeight = document.documentElement.clientHeight;  
  var popupHeight = jQuery("#popup").height();  
  var popupWidth = jQuery("#popup").width();  
  //centering  
  jQuery("#popup").css({  
	"position": "fixed",  
	"top": windowHeight/2-popupHeight/2,  
	"left": windowWidth/2-popupWidth/2  
  });  
  jQuery("#backgroundPopup").css({  
	"height": windowHeight  
  });  

}
