$(document).ready(function() {	

		id = "#dialog";
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect	
		$(id).fadeOut(0); 
		$('#mask').fadeIn(2000).css('display','block');	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//alert((winW/2)-(750/2)-(15));
		//$(id).width()/2)
		//$(id).height()
		//Set the popup window to center
		$(id).css('top',  winH/2-200);
		$(id).css('left', ((winW/2)-357));
	
		//transition effect
		$(id).fadeIn(2000); 

		$('#dialog').addClass('window');
	
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			


	
	$('#dialog').delay(5000).fadeOut(1000 , function() {
		$('#dialog').css('display','none');
		$('#mask').fadeOut(500);
	  });
	  
	
	
	
});


