// BEGIN: TEMPORARILY PLACED HERE -----------
// NEEDSWORK: Which is the best place to put the following code common to all dialogs?
// make sure we're in the dashboard frame
if(!parent || !parent.commonspot)
{
	alert('This page is part of the CommonSpot dashboard.\n\nTaking you there now...');
	document.location.href = '/commonspot/dashboard/index.html' + document.location.hash; // use hash we have, hoping it's got a url spec...
}

// get local references to objects we need in parent frame
// commonspot object has state, so we need that instance; others are static, but why load them again
var commonspot = window.commonspot || parent.commonspot;
// END: TEMPORARILY PLACED HERE ------------


if(!commonspot.dialog) // commonspot.dialog not built yet
{

	/**
	 * commonspot.dialog: dialog management package
	 */
	commonspot.dialog = {};

	/**
	 * commonspot.dialog.common: common dialog routines
	 */
	commonspot.dialog.common = {};

	/**
	 * commonspot.dialog.server: server-side dialog management, for cf dialogs etc
	 */
	commonspot.dialog.server = {};

	// default min height for scrollable region
	var DEFAULT_MIN_SCROLLABLE_REGION_HEIGHT = 55;

	/*
	 * @param urlParams (string): arguments to pass to loader
	 * @param customVarValues (value object, optional): custom dynamic argument values
	 *
	 * urlParams is everything after the '?', including csModule=whatever.cfm
	 * can include {varName} placeholders to be filled in when this is called
	 * there are two kinds of vars:
	 * 	- standard ones we do always
	 * 		pageID for now, maybe others some day
	 * 	- custom ones whose values are passed in customVarValues value object
	 * 		customVarValues should be in the form {fldName1: fldValue1, fldName2: fldValue2,...}
	 * 		{fldName1} in loaderParamsString will be replaced with fldValue1, etc
	 */
	commonspot.dialog.server.show = function(urlParams, customVarValues)
	{
		// replace any std var placeholders w real values
		if(urlParams.match(/{pageID}/))
		{
			var pageID = commonspot.data.uiState.lview.dsCurrentPage.getCurrentRow().pageid;
			urlParams = urlParams.replace('{pageID}', pageID);
		}

		// replace any custom dynamic arguments with passed values
		for(var fld in customVarValues)
			urlParams = urlParams.replace('{' + fld + '}', customVarValues[fld]);

		// get loader, build url
		var loader = commonspot.clientUI.state.location.getLoaderURL('subsiteurl');
		var url = loader + '?' + urlParams;
		
		commonspot.lightbox.openDialog(url);
	};

	/**
	 * client: client-side dialog management, for spry dialogs etc, generated on the client
	 */
	commonspot.dialog.client = {};

	/*
	 * Open the given url inside a lightbox, doing the same url parameter substitutions as server.show
	 */
	commonspot.dialog.client.show = function(url, customVarValues)
	{
		// replace any std var placeholders w real values
		if(url.match(/{pageID}/))
		{
			var pageID = commonspot.data.uiState.lview.dsCurrentPage.getCurrentRow().pageid;
			url = url.replace('{pageID}', pageID);
		}

		// replace any custom dynamic arguments with passed values
		for(var fld in customVarValues)
			url = url.replace('{' + fld + '}', customVarValues[fld]);
		
		commonspot.lightbox.openDialog(url);
	};

	/**
	 * Generic alert to user.
	 * see commonspot.dialog.client.showHTMLDialog for supported options
	 * msg can be text, or can be an array, in which case it'll be rendered as an html list
	 */
	commonspot.dialog.client.alert = function(msg, options)
	{
		var html;
		if(msg.constructor == String)
			html = msg;
		else // assumed to be an array
		{
			if(msg.length === 1)
				html = msg[0];
			else
			{
				html = "<ul>";
				for(var i = 0; i < msg.length; i++)
					html += "<li>" + msg[i] + "</li>";
				html += "</ul>";
			}
		}
		html = html.replace(/\n/g, '<br />');
		commonspot.dialog.client.showHTMLDialog(html, options, 'alert');
	}

	/**
	 * Generic alert to user.
	 * see commonspot.dialog.client.showHTMLDialog for supported options
	 * msg can be text, or can be an array, in which case it'll be rendered as an html list
	 */
	commonspot.dialog.client.alertDump = function(obj, caption)
	{
		var dumpHTML = commonspot.util.getDumpHTML(obj, caption);
		var style = commonspot.dialog.client.getHTMLDialogDefaultStyles();
		var html = commonspot.dialog.client.getHTMLDialogHTML(dumpHTML, style, "Dump Window " + commonspot.util.toCSDateFormat(new Date));
		var win = window.open("about:blank", "_blank", "width=400,height=300,resizable=1,scrollbars=1");
		win.document.write(html);
		win.document.close();
		var dialogFooter = win.document.getElementById("dialogFooter");
		dialogFooter.parentNode.removeChild(dialogFooter);
	}

	/*
	 * create a lightboxed dlg containing the passed html
	 */
	commonspot.dialog.client.showHTMLDialog = function(html, options, dialogType)
	{
		var options = options || {};
		var defaultOptions =
		{
			title: "CommonSpot Message",
			subtitle: "",
			helpId: "",
			width: 500,
			height: 600,
			style: '',
			useDefaultStyles: true,
			maximize: false,
			hideClose: false,
			hideHelp: true,
			hideReload: true
		};
		commonspot.util.merge(options, defaultOptions);

		dialogType = dialogType || 'dialog';

		var style = options.style;
		if(options.useDefaultStyles)
			style = commonspot.dialog.client.getHTMLDialogDefaultStyles() + style;

		html = commonspot.dialog.client.getHTMLDialogHTML(html, style, options.title, options);

		// openDialog(url, hideClose, name, customOverlayMsg, dialogType, opener, hideHelp)
		var dlgObj = commonspot.lightbox.openDialog("about:blank", options.hideClose, null, commonspot.lightbox.NO_OVERLAY_MSG, dialogType, null, options.hideClose, options.hideReload);
		var lightboxWindow = dlgObj.getWindow();
		lightboxWindow.document.write(html);
		lightboxWindow.document.close();

		commonspot.lightbox.initCurrent
		(
			options.width,
			options.height,
			{
				title: options.title, subtitle: options.subtitle, helpId: options.helpId,
				close: options.close, reload: options.reload, maximize: options.maximize
			},
			'',
			true
		);

		var dt = lightboxWindow.document.getElementById("dialogContainer");
		var w = Math.max(dt.clientWidth + 30, 350);
		var h = Math.max(dt.clientHeight, 70) - ((options.hideClose && !options.customButtons) ? 30 : 0);
		commonspot.lightbox.resizeCurrent(w, h);
		// first wanted this to autosize, to measure it, but now want it full width so close btn is far right
		lightboxWindow.document.getElementById("dialogContainer").style.width = "100%";
		commonspot.dialog.resizeDialogInWindow(lightboxWindow.document, "dialogContainer", 0, 50, 80);
	};

	commonspot.dialog.client.getHTMLDialogDefaultStyles = function()
	{
		var style =
'body {font-family: Verdana,Arial,Helvetica,sans-serif; margin: 0; overflow: scroll; text-decoration: none; font-size: 11px;}\n\
a:active {text-decoration: underline; color: #1D2661;}\n\
a:hover {text-decoration: underline;color: #003366;}\n\
a {color: #1D2661;text-decoration: underline;}\n\
a:visited {	text-decoration: underline;color: #1D2661;}\n\
#content {margin: 15px 11px; overflow: auto; font-size: 11px;}\n\
#innerdialogContainer {background-color:#F0F0F0;border-bottom:1px solid #999999;border-top:1px solid #999999;margin-top:10px;}\n\
#htmlDlgTableCell h2 {font-size: 11px; margin: 15px 0 8px;}\n\
#htmlDlgTableCell h2:first-child {margin-top: 0;}\n\
#htmlDlgTableCell p {margin: 0 0 8px; padding: 0;}\n\
#htmlDlgTableCell ul {margin: 0 0 1em 1em; padding: 0;}\n\
#htmlDlgTableCell li {margin: 5px;}\n\
#htmlDlgTableCell dl {margin: 0 0 1em;}\n\
#htmlDlgTableCell dt {color: #013466; font-weight: bold; margin: 5px 0 0;}\n\
#htmlDlgTableCell dd {margin: 0 0 0 1.5em;}\n\
#dialogContainer #dialogFooter {display: block; font-weight: bold; height: 28px; line-height: 28px; margin: 5px 0 0; padding: 0 1px; text-align: right; font-size: 11px;}\n\
#htmlDlgTableCell .dumpTable caption {font-size: 8pt; font-weight: bold;}\n\
#htmlDlgTableCell .dumpTable td {border: 1px solid #ccc; font-size: 8pt; padding: 1px;}\n\
';
		return style;
	};

	commonspot.dialog.client.getHTMLDialogHTML = function(alertHTML, styleHTML, title, options)
	{
		var btnHTML = '';
		var linkID, linkClass, linkOnClick, linkObj, linkAccessKey, linkText, linkObj;
		var accessKeyHTML = '';
		btnHTML += options.hideClose ? '' : '<a id="closeButton" accesskey="C" href="javascript:;" onclick="top.commonspot.lightbox.closeCurrent()">Close</a>';
		if (options.customButtons)
		{
			for (var i=0; i<options.customButtons.length; i++)
			{
				linkObj = options.customButtons[i];
				linkID = linkObj.id ? linkObj.id : 'okButton';
				linkOnClick = linkObj.onclick ? linkObj.onclick : '';
				linkText = linkObj.linkText ? linkObj.linkText : '';
				if (linkObj.accessKey)
					accessKeyHTML = ' accesskey="' + linkObj.accessKey + '"';
				if (linkOnClick != '' && linkID != '' && linkText != '')
					btnHTML += '<a id="' + linkID + '"' + accessKeyHTML + ' href="javascript:;" onclick="' + linkOnClick + '">' + linkText + '</a>';
			}		
		}
		var html =
			'<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" -->' +
			'<html>' +
			'<head>' +
				'<link href="/commonspot/dashboard/css/dialog.css" rel="stylesheet" type="text/css" id="dialogcss" />' +
				'<style>' + styleHTML + '</style>' +
				(title ? '<title>' + title + '</title>' : '') +
			'</head>' +
			'<body>' +
				'<table id="dialogContainer">' +
					'<tr><td>' +
						'<table id="innerdialogContainer" width="100%">' +
							'<tr>' +
								'<td id="htmlDlgTableCell">' +
									'<div id="content">' + alertHTML + '</div>' +
								'</td>' +
							'</tr>' +
						'</table>' +
					'</td></tr>' +
					'<tr><td>' + 
						'<div id="dialogFooter">' +
							btnHTML +
						'</div>' +
					'</td></tr>'
				'</table>' +		
			'</body>' +
			'</html>';
		return html;
	};

	/**
	 * creates a form on the fly from a passed object representing fields and their values, submits it, then destroys it
	 * @see \cs\devdocs\javascript-function-docs.js
	 */
	commonspot.dialog.postToDialog = function(targetUrl, fields, options)
	{
		fields = fields || {};
		if(options)
		{
			var defaultOptions =
			{
				width: 500, height: 450,
				title: "CommonSpot Dialog", subtitle: "", helpId: "",
				close: true, reload: false, maximize: false
			};
			commonspot.util.merge(options, defaultOptions);
		}
		var dlg = commonspot.lightbox.openDialog("about:blank");
		commonspot.dialog.submitDynamicForm(targetUrl, dlg.getFrameName(), fields);
		if(options)
		{
			commonspot.lightbox.initCurrent
			(
				options.width, options.height,
				{
					title: options.title, subtitle: options.subtitle, helpId: options.helpId,
					close: options.close, reload: options.reload, maximize: options.maximize
				}
			);
		}
		return dlg;
	};

	// creates, submits, and destroys a form from passed fields object
	commonspot.dialog.submitDynamicForm = function(targetUrl, targetWindowName, fields)
	{
		var form = document.createElement("form");
		form.method = "post";
		form.action = targetUrl;
		form.target = targetWindowName;
		for(var fldName in fields)
		{
			var fld = document.createElement("input");
			fld.name = fldName;
			fld.value = fields[fldName];
			form.appendChild(fld);
		}
		document.body.appendChild(form);
		form.submit();
		form.parentNode.removeChild(form);
		return;
	};

	/**
	 * To adjust the dialog box height for FORM dialogs by resizing the content area.
	 * 		Will call the lightbox to get the max space available and will resize the scrollable region if appropriate
	 *		so that the dialog will fit in the given space
	 *
	 *	Input
	 *		minResizeRegionHeight - (optional) minimum height in pixels of the resize area - defaults to 55 pixles
	 *
	 */
	 commonspot.dialog.resizeDialogInWindow = function(document, resizeControlName, heightHeader, heightFooter, minResizeRegionHeight)
	 {
		// DOTO: document argument ignored, don't need it
		var targetWindow = commonspot.lightbox.getCurrentWindow(false); // work with topmost non-alert window
		if(!targetWindow)
			targetWindow = commonspot.lightbox.getCurrentWindow(); // or alert window if there isn't a non-alert one

	 	var DLG_HEADER = heightHeader;
		var DLG_FOOTER = heightFooter;
	 	var finalHeight = 0;

		// if minResizeRegionHeight not defined or not a number default to 55 pixels
		if((!minResizeRegionHeight) || (isNaN(minResizeRegionHeight)))
			var minResizeRegionHeight = DEFAULT_MIN_SCROLLABLE_REGION_HEIGHT;

		// call to the lightbox and get the max size of the window - not lightbox takes into account the lightbox furniture
	 	var returnedMaxHeight = commonspot.lightbox.getMaxSize().height;

		// get the scrollable region height
		if (targetWindow)
			var ctrl = targetWindow.document.getElementById(resizeControlName);
		var sectionHeight = 0;

		if( ctrl )
		{
			ctrl.style.height = '';	// clear out the height
			sectionHeight = ctrl.offsetHeight;
		}

		// Calc the initial height of the lightbox content
		var initialHeight = sectionHeight + DLG_HEADER + DLG_FOOTER;

		if(initialHeight > returnedMaxHeight)
		{
			// resize the scrollable region to fit the dialog into the available space
			var newSectionHeight = returnedMaxHeight - (DLG_HEADER + DLG_FOOTER);

			// Make sure we don't resize below the minium height
			if(newSectionHeight < minResizeRegionHeight)
				newSectionHeight = minResizeRegionHeight;

			// Resize the scrollable region
			if(ctrl)
				ctrl.style.height = newSectionHeight + 'px';

			// calculate the new dialog height;
			finalHeight = newSectionHeight + (DLG_HEADER + DLG_FOOTER);
		}
		else
		{
			// If no height, size to default minimum height. Otherwise, size normally.
			if(sectionHeight == 0)
			{
				finalHeight = minResizeRegionHeight + DLG_HEADER + DLG_FOOTER;
				sectionHeight = minResizeRegionHeight;
			}
			else
				finalHeight = initialHeight;

			// Resize the scrollable region
			if(ctrl)
				ctrl.style.height = sectionHeight + 'px';
		}

		return finalHeight;
	 };

	/*
	 * configureCommandObject
	 */
	commonspot.dialog.configureCommandObject = function(dataSet, commandObj, pageCategory)
	{
		var orderBy							= 'UnDeFiNeD';
		var orderByImage					= 'UnDeFiNeD';		
		var subsiteFilter					= 'UnDeFiNeD';
		var dateFilterType				= 'UnDeFiNeD';
		var dateFilter						= 'UnDeFiNeD';
		var includeChildSubsites		= 'UnDeFiNeD';
		var excludeIndividualOwners	= 'UnDeFiNeD';
		var allowPageGallery				= 'UnDeFiNeD';
		var maxGlobalCustomElements	= 'UnDeFiNeD';
		var maxLocalCustomElements		= 'UnDeFiNeD';
		var maxPages						= 'UnDeFiNeD';
		var maxSimpleForms				= 'UnDeFiNeD';

		// Get data from getUIScalability dataset.
		var rows = dataSet.getData();

		if (typeof pageCategory != 'undefined')
		{
			switch (pageCategory.toUpperCase())
			{
				case 'IMAGEGALLERY':
					break;
				case 'MYCONTENT':
					orderBy						= rows[0]['mycontentdefaultorderby'];
					subsiteFilter				= rows[0]['mycontentdefaultsubsitescope'];
					dateFilterType				= rows[0]['mycontentdefaultdaterestrictiontype'];
					dateFilter					= rows[0]['mycontentdefaultdaterestrictionrange'];
					includeChildSubsites		= rows[0]['mycontentincludechildsubsites'];
					break;
				case 'PAGEFINDER':
					// NEEDSWORK: Mapping needs to be verified.
					commandObj.excludeIndividualOwners = excludeIndividualOwners;
					break;
				case 'PAGEGALLERY':
					allowPageGallery			= rows[0]['pagegalleryallowpagegallery'];
					// NEEDSWORK: Mapping needs to be verified.
					commandObj.allowPageGallery = allowPageGallery;
					break;
				case 'REPORTS':
					orderBy						= rows[0]['reportsdefaultorderby'];
					subsiteFilter				= rows[0]['reportsdefaultsubsitescope'];
					dateFilterType				= rows[0]['reportsdefaultdaterestrictiontype'];
					dateFilter					= rows[0]['reportsdefaultdaterestrictionrange'];
					includeChildSubsites		= rows[0]['reportsincludechildsubsites'];
					break;
				case 'SEARCH':
					orderBy						= rows[0]['finddefaultorderby'];
					subsiteFilter				= rows[0]['finddefaultsubsitescope'];
					dateFilterType				= rows[0]['finddefaultdaterestrictiontype'];
					dateFilter					= rows[0]['finddefaultdaterestrictionrange'];
					includeChildSubsites		= rows[0]['findincludechildsubsites'];
					break;
				case 'IMAGE':
					orderByImage				= rows[0]['findimagedefaultorderby'];
					subsiteFilter				= rows[0]['findimagedefaultsubsitescope'];
					dateFilterType				= rows[0]['findimagedefaultdaterestrictiontype'];
					dateFilter					= rows[0]['findimagedefaultdaterestrictionrange'];
					includeChildSubsites		= rows[0]['findimageincludechildsubsites'];
					break;
				case 'TAXONOMY':
					maxGlobalCustomElements	= parseInt(rows[0]['taxonomydatabrowsermaxglobalcustomelements'], 10);
					maxLocalCustomElements	= parseInt(rows[0]['taxonomydatabrowsermaxlocalcustomelements'], 10);
					maxPages						= parseInt(rows[0]['taxonomydatabrowsermaxpages'], 10);
					maxSimpleForms				= parseInt(rows[0]['taxonomydatabrowsermaxsimpleforms'], 10);

					// NEEDSWORK: Mapping needs to be verified.
					commandObj.maxGlobalCustomElements 	= maxGlobalCustomElements;
					commandObj.maxLocalCustomElements 	= maxLocalCustomElements;
					commandObj.maxPages 						= maxPages;
					commandObj.maxSimpleForms 				= maxSimpleForms;
					break;
				default:
					// If pageCategory unknown, default to Reports.
					orderBy						= rows[0]['reportsdefaultorderby'];
					subsiteFilter				= rows[0]['reportsdefaultsubsitescope'];
					dateFilterType				= rows[0]['reportsdefaultdaterestrictiontype'];
					dateFilter					= rows[0]['reportsdefaultdaterestrictionrange'];
					includeChildSubsites		= rows[0]['reportsincludechildsubsites'];
					break;
			}
		}
		else
		{
			// If pageCategory not specified, default to Reports.
			orderBy						= rows[0]['reportsdefaultorderby'];
			subsiteFilter				= rows[0]['reportsdefaultsubsitescope'];
			dateFilterType				= rows[0]['reportsdefaultdaterestrictiontype'];
			dateFilter					= rows[0]['reportsdefaultdaterestrictionrange'];
			includeChildSubsites		= rows[0]['reportsincludechildsubsites'];
		}

		// No mapping required for the following items.
		commandObj.includeChildSubsites  = includeChildSubsites;
		//commandObj.displayDate 				= 'DateContentLastModified';	// NEEDSWORK ???
		commandObj.limit 						= -1; // Appropriate number of records will be returned.

		// Mapping required between getUIScalability output & pagelist command
		// (e.g. getMyPages) input for the following items:

		// Map SubsiteFilter.
		if (subsiteFilter != 'UnDeFiNeD')
		{
			var locationInfo = commonspot.clientUI.state.location.get();
			var upperStr = subsiteFilter.toUpperCase();

			if (commandObj.subsiteFilter)
			{
				// for the reminders on the My CommonSpot, we force filter to be always from root subsite and include all child subsites ONLY...
				if (upperStr == 'ALL')
				{
					commandObj.subsiteFilter = 1;
					commandObj.subsiteFilterPath = locationInfo.siteurl;
					commandObj.includeChildSubsites = 1;
				}
			}
			else
			{
				switch (upperStr)
				{
					case 'ALL':
						commandObj.subsiteFilter = 1; // The defaultSubsiteScope should be the id of root subsite (i.e. 1) in this case
						commandObj.subsiteFilterPath = locationInfo.siteurl;
						break;
					case 'CURRENT SUBSITE ONLY':
						commandObj.subsiteFilter = locationInfo.subsiteid;
						commandObj.subsiteFilterPath = locationInfo.subsiteurl;
						break;
					default:
						alert('Unknown subsiteFilter value: ' + subsiteFilter + '. \n ' +
								'Allowed values are: All, Current subsite only.');
						break;
				}
			}
		}

		// Map DateFilterType.
		if (dateFilterType != 'UnDeFiNeD')
		{
			switch (dateFilterType)
			{
				case 'No date restrictions':
					commandObj.dateFilterType = '';
					break;
				case 'Last modification date':
				case 'Last major modification date':
				case 'Creation date':
					commandObj.dateFilterType = dateFilterType;
					break;
				default:
					alert('Unknown dateFilterType value: ' + dateFilterType + '. \n ' +
							'Allowed values are: None, No date restrictions, Last modification date, ' +
							'Last major modification date, Creation date.');
					break;
			}
		}

		// Map DateFilter.
		if (dateFilter != 'UnDeFiNeD')
		{
			switch (dateFilter)
			{
				case 'None':
					commandObj.dateFilter = '';
					break;
				case 'This week':
				case 'Last week':
				case 'This month':
				case 'Last month':
				case 'Last 7 days':
				case 'Last 30 days':
				case 'Last 60 days':
				case 'Last 90 days':
				case 'Last 6 months':
				case 'This year':
				case 'Last year':
					commandObj.dateFilter = dateFilter;
					break;
				default:
					alert('Unknown dateFilter value: ' + dateFilter + '. \n ' +
							'Allowed values are: None, This week, Last week, This month, ' +
							'Last month, Last 7 days, Last 30 days, Last 60 days, Last 90 days, ' +
							'Last 6 months, This year, Last year.');
					break;
			}
		}

		// Map OrderBy.
		if (orderBy != 'UnDeFiNeD')
		{
			switch (orderBy)
			{
				case 'Date of last modification':
					commandObj.orderBy = 'DateContentLastModified Desc';
					break;
				case 'Date of last major modification':
					commandObj.orderBy = 'DateContentLastMajorRevision Desc';
					break;
				case 'Date Published':
					commandObj.orderBy = 'PublicReleaseDate Desc';
					break;
				case 'Title':
					commandObj.orderBy = 'Title Desc';
					break;
				default:
					alert('Unknown orderBy value: ' + orderBy + '. \n ' +
							'Allowed values are: Date of last modification, Date of last major modification, ' +
							'Date Published, Title.');
					break;
			}
		}

		// Map OrderBy.
		if (orderByImage != 'UnDeFiNeD')
		{
			switch (orderByImage)
			{
				case 'Creation date':
					commandObj.orderBy_image = 'DateAdded Desc';
					break;
				case 'Last modification date':
					commandObj.orderBy_image = 'DateContentLastModified Desc';
					break;
				case 'File Name':
					commandObj.orderBy_image = 'filename';
					break;
				case 'Subsite':
					commandObj.orderBy_image = 'subsiteurl';
					break;
				case 'Category':
					commandObj.orderBy_image = 'categoryname';
					break;
				case 'Owner':
					commandObj.orderBy_image = 'ownername';
					break;
				case 'Image Type':
					commandObj.orderBy_image = 'icontext';
					break;
				case 'File Size':
					commandObj.orderBy_image = 'filesize';
					break;
				case 'Width':
					commandObj.orderBy_image = 'orgwidth';
					break;
				case 'Height':
					commandObj.orderBy_image = 'orgheight';
					break;					
				default:
					alert('Unknown Image orderBy value: ' + orderByImage + '. \n ' +
							'Allowed values are: Creation date, Last modification date, File name, Subsite, Category, Owner, Image type, File size, Width, Height');
					break;
			}
		}
		return commandObj;
	};		

	/**
	 * Wrapper function to invoke commonspot.lightbox.openDialog() for enabled menu options only.
	 */
	commonspot.dialog.client.openDialog = function(url, obj, customVarValues)
	{
		if ($(obj).hasClassName('disabled'))
			return false;
		return commonspot.dialog.client.show(url, customVarValues);
	};

	/**
	 * Wrapper function to invoke commonspot.dialog.server.show() for enabled menu options only.
	 */
	commonspot.dialog.server.openDialog =  function(url, obj, customVarValues)
	{
		if ($(obj).hasClassName('disabled'))
			return false;
		return commonspot.dialog.server.show(url, customVarValues);
	};

} // commonspot.dialog not built yet
