$(document).ready(function(event)
{
	var popupStatus = 0;
	centerPopup();
	$("#thumb").click(function(){
		loadPopup();
	});
	$("#backgroundPopup").click(function(){  
		disablePopup();  
	});
	$("#popupContactClose").click(function(){  
		disablePopup();  
	});
	
	function loadPopup()
	{
		if(popupStatus==0)
		{
			$("#backgroundPopup").fadeIn("slow");
			$("#popupContact").fadeIn("slow");
			popupStatus = 1;
		}
	}
	
	function centerPopup()
	{  
		//request data for centering  
		var windowWidth = document.documentElement.clientWidth;  
		var windowHeight = document.documentElement.clientHeight;  
		var popupHeight = $("#popupContact").height();  
		var popupWidth = $("#popupContact").width();  
		//centering  
		$("#popupContact").animate(
		{  
			position: "absolute",  
			top: windowHeight/2-popupHeight/2,  
			left: windowWidth/2-popupWidth/2  
		});  
	}
	
	function disablePopup()
	{
		if(popupStatus==1)
		{
			$("#backgroundPopup").fadeOut("slow");
			$("#popupContact").fadeOut("slow");
		}
		popupStatus = 0;
	}
});
