
jQuery(document).ready(function () {

	// if user clicked on button, the overlay layer or the dialogbox, close the dialog	
	jQuery('#dialog-overlay').click(function () {		
		jQuery('#dialog-overlay, #dialog-box').hide();		
		return false;
	});
	
	// if user resize the window, call the same function again
	// to make sure the overlay fills the screen and dialogbox aligned to center	
	jQuery(window).resize(function () {
		
		//only do it if the dialog box is not hidden
		if (!jQuery('#dialog-box').is(':hidden')) popup();		
	});	
	
	
});

//Popup dialog
function popup(message) {
		
	// get the screen height and width  
	var maskHeight = jQuery(document).height();  
	var maskWidth = jQuery(window).width();
	
	// calculate the values for center alignment
	
	//alert(maskHeight+"****"+jQuery('#dialog-box').height());
	var dialogTop =  50;//((maskHeight) - (jQuery('#dialog-box').height()))/2;  
	var dialogLeft = (maskWidth/2) - (jQuery('#dialog-box').width()/2); 
	
	// assign values to the overlay and dialog box
	jQuery('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();
	jQuery('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();
	
	// display the message
	jQuery('#dialog-message').html(message);
	
}

