$(document).ready(function() {	
		
	var id = $("#dialog");
	//Get the screen height and width
	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});
	
	//set it back to block display
	$(id).css({ 'display':'block', 'width':537, 'height':717});	
	
	//Get the position
	var winH = $(window).height()/2-$(id).height()/2;
	var winW = $(window).width()/2-$(id).width()/2;
	
	//make sure that the top isnt above the window
	if(winH < 0)
		winH=0;
	
	//set the popup window off screen
	//$(id).css('top', 0-$(id).height());
	$(id).css('top', winH);
	//$(id).css('left', 0-$(id).width());
	$(id).css('left', winW);
	$(id).css('opacity','0');
	
	//transition effect	
	$('#mask').css('display','block');
	$('#mask').css('opacity','0');
	$('#mask').fadeTo(2000,0.8);
	
	$(id).fadeTo(2000,1);
	
	//perform the animation
	//$(id).animate( { left:winW }, { queue: false, duration: 3000 } ).animate( { top:winH } , 3000 );
		  
	//Set the popup window to center
	//$(id).css('top',  winH/2-$(id).height()/2);
	//$(id).css('left', winW/2-$(id).width()/2);
	
	//transition effect
	//$(id).fadeIn(2000); 
	
	//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();
	});			
	
});

