jQuery(document).ready(function() {	
		
	var id = jQuery("#dialog");
	//Get the screen height and width
	var maskHeight = jQuery(document).height(1919);
	var maskWidth = jQuery(window).width(1080);

	//Set heigth and width to mask to fill up the whole screen
	jQuery('#mask').css({'width':maskWidth,'height':1919});
	
	//set it back to block display
	jQuery(id).css({ 'display':'block', 'width':800 });	
	
	//Get the position
	var winH = jQuery(window).height()/2-jQuery(id).height()/2;
	var winW = jQuery(window).width()/2-jQuery(id).width()/2;
	
	//make sure that the top isnt above the window
	if(winH < 0)
		winH=0;
	
	//set the popup window off screen
	jQuery(id).css('top', 0-jQuery(id).height());
	jQuery(id).css('left', 0-jQuery(id).width());
	
	//transition effect	
	jQuery('#mask').css('display','block');
	jQuery('#mask').css('opacity','0');
	jQuery('#mask').fadeTo(2000,0.8);
	
	//perform the animation
	jQuery(id).animate( { left:winW }, { queue: false, duration: 3000 } ).animate( { top:winH } , 3000 );
		  
	//Set the popup window to center
	jQuery(id).css('top',  winH/2-jQuery(id).height()/2);
	jQuery(id).css('left', winW/2-jQuery(id).width()/2);
	
	//transition effect
	jQuery(id).fadeIn(2000); 
	
	//if close button is clicked
	jQuery('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		jQuery('#mask').hide();
		jQuery('.window').hide();
	});		
	
	//if mask is clicked
	jQuery('#mask').click(function () {
		jQuery(this).hide();
		jQuery('.window').hide();
	});			
	
});
