$(document).ready(function() {	

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
									  						  
		$('body').css({'overflow':'hidden'});
		
		//Cancel the link behavior
		e.preventDefault();
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		//var maskHeight = $(document).height();
		//var maskWidth = $(window).width();
	
		//Set height and width to mask to fill up the whole screen
		$('#mask').css({'width':'200%','height':'200%'});
		
		//transition effect		
		$('#mask').fadeIn(500);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css({'position':'fixed','top':winH/2-250,'left':winW/2-250});
	
		//transition effect
		$(id).fadeIn(600); 
		
		
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
										
		$('body').css({'overflow':'auto'});	
		
		//Cancel the link behavior
		e.preventDefault();
		$('#mask, .window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
							   
		$('body').css({'overflow':'auto'});					   
							   
		$(this).hide();
		$('.window').hide();
	});			
	
});
