// RY 9/7/07 These need to be divided into functional categories/files

if( !ILR.Util ) {
	/**
	 * Various utility functions.
	 * @namespace ILR
	 * @class Util
	 */
	ILR.Util = {
		/**
		 * Gets the URL query string.
		 * @method getQueryString
		 * @param {String} url The full URL
		 * @return {String} The query string in the URL (everything after and including ?)
		 */
		getQueryString:function(url) {
			if( !url ) {
				url = document.URL;
			}
			
			return url.substring(url.indexOf("?"), url.length);
		},
		
		/**
		 * Parses a query string and returns an associative array of
		 * key-value pairs.
		 * @method parseQueryString
		 * @param {String} query The query string
		 * @return {Object} The associative array of key-value pairs
		 */
		parseQueryString:function(query) {
			if( !query ) {
				query = document.location.search;
			}
			
			queryObj = {};
			
			query = query.replace("?", "");
			query = query.split("&");
			
			var keyValue;
			for( var i = 0; i < query.length; ++i ) {
				keyValue = query[i].split("=");
				queryObj[keyValue[0]] = keyValue[1];
			}
			
			return queryObj;
		},
		
		/**
		 * Gets the file name from a path.
		 * @method fileName
		 * @param {String} path The path
		 * @return {String} The file name
		 */
		fileName:function(path) {
			path = path.replace("/", "\\");
	
			return path.substr(path.lastIndexOf("\\"), path.length).replace("\\", "");
		},
		
		/** 
		 * Create a popup window
		 * @method makePopup
		 * @param {String} url
		 * @param {String} name
		 * @param {Number} width
		 * @param {Number} height
		 */
		makePopup : function(url, name, props) {
			
			// Defaults are also max values
 			var defaultWidth = 600,
				defaultHeight = 600,
				name = name || 'newwindow',
				props = props || {};

			// Default property values
			props.width = props.width || defaultWidth;
			props.height = props.height || defaultHeight;
			
			// Enforced values
			props.resizable = 'yes';
			props.location = 'no';
			props.menubar = 'no';
			props.scrollbars = 'yes';
			props.toolbar = 'no';						
			props.width = props.width > defaultWidth ?  defaultWidth : props.width;
			props.height = props.width > defaultHeight ?  defaultHeight : props.height;
		
			// return 
			window.open(url, name, props);

		}
	
	}
}