
	var popupStatus = 0;
	
	function callPop(id)
		{
	  //loading popup with jQuery magic!
//loads popup only if it is disabled
			if(popupStatus==0){
				$("#backgroundPopup").css({"opacity": "0.7"});					
			   $("#backgroundPopup").fadeIn("slow");
				$("#popUp").fadeIn("slow");
				popupStatus = 1;
				changeElementContent($('#popUp'), id); 
    		}
		}
		
		function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popUp").fadeOut("slow");
popupStatus = 0;
}
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){

     //CLOSING POPUP
    //Click the x event!
    $("#popupContactClose").click(function(){
        disablePopup();
    });
    //Click out event!
    $("#backgroundPopup").click(function(){
        disablePopup();
    });
    //Press Escape event!
    $(document).keypress(function(e){
        if(e.keyCode==27 && popupStatus==1){
            disablePopup();
        }
    });

});
