/* combine : /javascript/desktop/common/jdw_Modal.js*/
/* Facade to provide a simplified interface to display modal windows. */

var jdwModalOptions = {};

var jdwModal = function() {
	return {
	
		/*  Displays a modal window using the provided data.
		 *  ---------------------------------------------------------------
		 *	
		 *	data : 		A String of data to be displayed.
		 *			
		 *	options:	Object containing named options as appropriate.
		 *			
		 *	Available options are:
		 *	----------------------
		 *	continueUrl:	when continue button is clicked the modal will close and navigate to this URL. If not specified button will be hidden.
		 *	continueText:	the text displayed on the continue button default is 'Continue'.
		 *	closeText:		the text displayed on the close button. Default is 'Close'.
		 *  fromBack:		
		 *  hideClose:		hides the close button if true
		 *  closeButtonHeader: determines if we have a close button in the header
		 *  closeButtonFooter:		show a close button in the footer
		 * 	onSuccess: callback function
		 *  onClose:				function to call when the modal closes.
		 */	 		 
		displayModalFromData : function(data,options) {		
			var fromBack = false;
		 	var hideClose = false;
		 	if(options.fromBack) {
		 		fromBack = true;
		 		hideClose = true;
		 	}
			if(options && options.onClose) {
				jdwModalOptions.onClose = options.onClose;
			}
			openModalJQ(data,null,fromBack,hideClose,false,options); 		
		},
		
		/**  Displays a modal window retrieving the data from the given URL.
		 *  ---------------------------------------------------------------
		 *	
		 *	url : 		The url providing the data to display within the modal.  This can
		 *				also be a simple string to display in the modal.
		 *			
		 *	options:	Object containing named options as appropriate.
		 *			
		 *	Available options are:
		 *	----------------------
		 *	continueUrl:			when continue button is clicked the modal will close and navigate to this URL. If not specified button will be hidden.
		 *	continueText:			the text displayed on the continue button default is 'Continue'.
		 *	closeText:				the text displayed on the close button. Default is 'Close'.
		 *	backText:				the text displayed on the back button. Default is 'Back'.	
		 *	buttons:				an HTML snippet specifying the buttons that will appear (overrides all other options to do with buttons).		
		 *	hideBack:				force hiding of the back button.
		 *	hideClose:				force hiding of the close button.
		 * 	hideHeader:				hide the top panel where the title goes.
		 *  hideFooter:				hide the bottom panel where the buttons are.
		 *  onClose:				function to call when the modal closes.
		 *  width:					the width of the modal
		 *  height:					the height of the modal
		 *  closeButtonHeader:		show a header with a close button
		 *  closeButtonFooter:		show a close button in the footer
		 *  scrollbars:				show scrollbars on the modal
		 *  triggerData :			class name of a div for the updating overlay to cover
		 */	 
		displayModalFromUrl : function(url,options) {		
						
			var fromBack = (options ? options.fromBack : false);
			var hideClose = (options ? options.hideClose : false);
			var scrollbars = (options ? options.scrollbars : false);
					
			if(options && options.onClose) {
				jdwModalOptions.onClose = options.onClose;
			}
			
			var successCallback = function(data) {
				openModalJQ(data,url,fromBack,hideClose,scrollbars,options); 
			};
			
			var errorCallback = function(data) {
				if (data.status == 0) {
					openModalJQ('An unexpected error has occurred.  Please close this box and try again.',url,fromBack,hideClose,false,options); 
				}
			}
						
			performAjaxRequest(url,options.beforeSendFunction,null,null,null,successCallback,errorCallback,'GET',options.triggerData);	
		}
	}
}();/* complete : /javascript/desktop/common/jdw_Modal.js*/


