
function popup_habanero(tasto_apri,tasto_chiudi,div_pop){

		//SETTING UP OUR POPUP
		//0 means disabled; 1 means enabled;
		var popupStatus = 0;
			
			//var tasto_apri = "#button";
			//var tasto_chiudi = "#popupContactClose";
			//var div_pop = "#popupContact";
			//var "#backgroundPopup" = "#backgroundPopup";
		
		//loading popup with jQuery magic!
		function loadPopup(){
			//loads popup only if it is disabled
			if(popupStatus==0){
				$("#backgroundPopup").css({
					"opacity": "0.7"
				});
				$("#backgroundPopup").fadeIn("slow");
				$(div_pop).fadeIn("slow");
				popupStatus = 1;
				
			}
		}
		
		//disabling popup with jQuery magic!
		function disablePopup(){
			//disables popup only if it is enabled
			if(popupStatus==1){
				$("#backgroundPopup").fadeOut("slow");
				$(div_pop).fadeOut("slow");
				popupStatus = 0;
			}
		}
		
		//centering popup
		function centerPopup(){
			//request data for centering
			var windowWidth = document.documentElement.clientWidth;
			var windowHeight = document.documentElement.clientHeight;
			var popupHeight = $(div_pop).height();
			var popupWidth = $(div_pop).width();
			//centering
			$(div_pop).css({
				"position": "absolute",
				"top": windowHeight/2-popupHeight/2,
				"left": windowWidth/2-popupWidth/2
			});
			//only need force for IE6
			
			$("#backgroundPopup").css({
				"height": windowHeight
			});
			
		}
		
		
		//CONTROLLING EVENTS IN jQuery
		$(document).ready(function(){
	
			//LOADING POPUP
		
			//verifica se esiste il div backgroundPopup altrimenti lo creo
			if (document.getElementById("backgroundPopup") == null) {
		
				var sfondo_popup = document.createElement('div');
				document.body.appendChild(sfondo_popup);
				sfondo_popup.setAttribute('id', "backgroundPopup");
		
				$("#backgroundPopup").css({
					"display": "none",
					"position": "fixed",
					"_position": "absolute", /* hack for internet explorer 6*/
					"height": "100%",
					"width": "100%",
					"top": "0",
					"left": "0",
					"background": "#000000",
					"border": "1px solid #cecece",
					"z-index": "99"
				});
			}

			$(tasto_chiudi).css({
				"display": "block"
			});

			$(div_pop).css({
				"display": "none",
				"position": "fixed",
				"_position": "absolute", /* hack for internet explorer 6*/
				"z-index": "100"
			});

	
	
			//Click the button event!
			$(tasto_apri).click(function(){
				//centering with css
				centerPopup();
				//load popup
				loadPopup();
			});
						
			//CLOSING POPUP
			//Click the x event!
			$(tasto_chiudi).click(function(){
				disablePopup();
			});
			//Click out event!
			$("#backgroundPopup").click(function(){
				disablePopup();
			});
			//Press Escape event!
			$(document).keypress(function(e){
				if(e.keyCode==27 && popupStatus==1){
					disablePopup();
				}
			});
		
		});
		
}
