//State of 0 means its invisible
var state = 0;
//popUp function
function popUp(form){
	
	if(state==0){
		$("#background").css({  
			"opacity": "0.7"  
			}); 
		$("#background").fadeIn("slow");
		$(form).fadeIn("slow");
		state=1; 
	}
}
function closeUp(){
	if(state==1){
		$("#background").fadeOut("slow"); 
		$(".popUp").fadeOut("slow");
		state=0;
	}
}
//center function
function center(form){
	var winHeight = document.documentElement.clientHeight;
	var winWidth = document.documentElement.clientWidth;
	var popHeight = $(form).height();
	var popWidth = $(form).width();
	$(form).css({
		"position": "absolute",
		"top": winHeight/2-popHeight/2,
		"left": winWidth/2-popWidth/2
	})
	$("#background").css({  
		 "height": winHeight  
		});  
}
$(document).ready(function(){
	$(".form").click(function(){
		
		center('#'+this.name);
		popUp('#'+this.name);
	});
	$("#background").click(function(){
		closeUp();
	})
	$(".close").click(function(){
		closeUp();
	})
//end of program
})