MG.namespace("MG.util.Modal");
MG.util.Modal = (function() {
	function hideModal() {
		$("#modal_content").empty().dialog("close").dialog("destroy");
	}
	
	/**
	 * Shows a message in the modal box
	 * @param {String} message
	 * @param {String} title
	 */
	function showMessageInAModal(message, title, override) {
		gel("modal_content").innerHTML = message;
		
		var opts = {
			closeOnEscape : true,
			title : title,
			modal : true
		};
		
		if(typeof override == 'object') {
			opts = $.extend(opts, override);
		}
		
		$("#modal_content").dialog(opts);
	}
	
	/**
	 * Shows a saving modal
	 */
	function showSaving() {
		showMessageInAModal(
			'<div style="text-align:center;"><img src="images/3.0/busy.gif" /></div>',
			'One moment please...',
			{
				closeOnEscape : false,
				minHeight		: 50
			}
		);
	}
	
	return {
		hideModal			: hideModal,
		showMessageInAModal : showMessageInAModal,
		showSaving			: showSaving
	};
})();
