// work out which browser type is needed
var ns4 = false;
var ns5plus = false;
var ie = false;
if (document.layers)
	ns4 = true;
else if ((parseInt(navigator.appVersion) >= 5) && (navigator.appName=="Netscape"))
	ns5plus = true;
else if (document.all)
	ie = true;


// make the user confirm their action before proceeding (used when deleting things,  etc)
//function confirm_action (message, urllocation) {
//	if (!confirm (message)) {
//		return false;
//	}
//	else {
//		document.location.href = urllocation;
//	}
//}

// make the user confirm their action before proceeding (used when deleting things,  etc)
// now allows for multiple confirmation messages before the action is taken
function confirm_action (messages, urllocation) {
	if ((typeof (messages) != 'array') && (typeof (messages) != 'object')) {
		temp = new Array ();
		temp[0] = messages;
		messages = temp;		
	}
	for (count = 0; count < messages.length; count++) {
		if ((messages[count] != '') && (!confirm (messages[count])))
			return false;
	}
	document.location.href = urllocation;
}

// record in a hidden field that a form on the page has been updated
function form_changed () {
	document.formChanges.changesMade.value = 'Y';
}

// record in a hidden field that a form on the page has been updated
function go_to (urllocation) {
//	if (document.formChanges.changesMade.value == 'Y')
//		confirm_action ("You have made changes to a form on this page.\nDo you wish to continue without saving?", urllocation);
//#		alert ("You have made changes to the form on this page.\nPlease save this information before continuing.");
//	else
		document.location.href = urllocation;
}

// toggle a checkbox's value
function toggle_checkbox (fieldName, arrayPosition) {
	temp = get_object (fieldName);

	// check to see if javascript thinks this is an object (array) or not
	if (typeof (temp[arrayPosition]) != 'undefined') {
		if (temp[arrayPosition].checked == false)
			temp[arrayPosition].checked = true;
		else
			temp[arrayPosition].checked = false;
	}
	else {
		if (temp.checked == false)
			temp.checked = true;
		else
			temp.checked = false;
	}
	return true;
}

// toggle a checkbox's value
function set_radio_button (fieldName, arrayPosition) {
	temp = get_object (fieldName);

	// check to see if javascript thinks this is an object (array) or not
	if (typeof (temp[arrayPosition]) != 'undefined')
		temp[arrayPosition].checked = true;
	else
		temp.checked = true;

	return true;
}

// display or hide a div
function flip_div (divName) {
	temp = get_object (divName);

	current=(temp.style.display == 'none') ? 'block' : 'none';
	temp.style.display = current;
}

// display a div
function display_div (divName) {
	temp = get_object (divName);

	if (typeof (temp) != 'undefined')
		temp.style.display = 'block';
}

// hide a div
function hide_div (divName) {
	temp = get_object (divName);

	if (typeof (temp) != 'undefined')
		temp.style.display = 'none';
}

// display a parent div
function display_parent_div (divName) {
	temp = get_parent_object (divName);

	temp.style.display = 'block';
}

// hide a parent div
function hide_parent_div (divName) {
	temp = get_parent_object (divName);

	temp.style.display = 'none';
}

// overwrite a div's content
function update_div (divId, content) {
	document.getElementById (divId).innerHTML = content;
}












// 
function get_object (fieldName) {
	var temp;

	if (ie) {
		if (typeof (document.all[fieldName]) != 'undefined')
			temp = document.all[fieldName];
	}
	else if (ns5plus) {
		if (document.getElementById(fieldName) != null)
			temp = document.getElementById(fieldName);
	}
	else if (ns4)
		temp = document.layers[fieldName];

	return temp;
}

// 
function get_parent_object (fieldName) {
	if (ie)
		temp = parent.document.all[fieldName];
	else if (ns5plus)
		temp = parent.document.getElementById(fieldName);
	else if (ns4)
		temp = parent.document.layers[fieldName];

	return temp;
}

// 
function select_all_checkboxes (fieldName) {
	temp = get_object (fieldName);

	if (temp.length) {
		for (count = 0; count < temp.length; count++)
			temp[count].checked = true;
	}
	else
		temp.checked = true;
}

// 
function unselect_all_checkboxes (fieldName) {
	temp = get_object (fieldName);

	if (temp.length) {
		for (count = 0; count < temp.length; count++)
			temp[count].checked = false;
	}
	else
		temp.checked = false;
}

function are_all_checkboxes_selected (fieldName) {
	temp = get_object (fieldName);

	allSelected = true;
	if (temp.length) {
		for (count = 0; count < temp.length; count++) {
			if (temp[count].checked == false)
				allSelected = false;
		}
	}
	else {
		if (temp.checked == false)
			allSelected = false;
	}
	return allSelected;
}

// 
function toggle_all_checkboxes (fieldName) {
	if (are_all_checkboxes_selected (fieldName))
		return unselect_all_checkboxes (fieldName);
	return select_all_checkboxes (fieldName);
}

// 
function update_button_text_based_on_all_checkboxes (fieldName, buttonName, allSelectedText, notAllSelectedText) {
	buttonObject = get_object (buttonName);

	if (are_all_checkboxes_selected (fieldName))
		buttonObject.value = allSelectedText;
	else
		buttonObject.value = notAllSelectedText;
}

// enable an input field
function enable_input (domId) {
	if (typeof (domId) == 'object') {
		domId.disabled = false;
		domId.style.backgroundColor = '#FFFFFF';
	}
	else {
		temp = get_object (domId);
		temp.disabled = false;
		temp.style.backgroundColor = '#FFFFFF';
	}
}

// disable an input
function disable_input (domId) {
	if (typeof (domId) == 'object') {
		domId.disabled = true;
		domId.style.backgroundColor = '#F0F0F0';
	}
	else {
		temp = get_object (domId);
		temp.disabled = true;
		temp.style.backgroundColor = '#F0F0F0';
	}
}

var delayedActionTimerVars = new Array ();

function start_delayed_action (timeoutName, actions, delayMS) {
	eval ("clearTimeout (delayedActionTimerVars[\'" + timeoutName + "\']);");
	eval ("delayedActionTimerVars[\'" + timeoutName + "\'] = setTimeout (\"" + actions + "\", " + delayMS + ");");
}
function cancel_delayed_action (timeoutName) {
	eval ("clearTimeout (delayedActionTimerVars[\'" + timeoutName + "\']);");
}









// limit chars entered into a textarea
function text_limiter_with_counter(field,maxlimit,cntfield) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	
	// otherwise, update 'characters left' counter
	else 
		cntfield.value = maxlimit - field.value.length;
}

function text_limiter_without_counter(field,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
}







function escapeHTML(s,escapeSpacing,tabSize,escapeLineBreaks){

	// default values
	if (escapeSpacing == null)
		escapeSpacing = false;
	if (tabSize == null)
		tabSize = 4;
	if (escapeLineBreaks == null)
		escapeLineBreaks = true;

	s = s.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/\"/g,'&quot;'); //html entities. // & must be replaced first.
	if(escapeSpacing){
		var spaces = '';
		for(var i=0;i<tabSize;i++){
			spaces += ' ';
		}
		s = s.replace(/\t/g,spaces).replace(/\r\n/g,'\n');  //tab to spaces. \r\n to \n
//		md.log('s after tab2space',s)

		var ss = [];
		var s3 = [];
//		md.log('[]',[]);
//		md.log('new Array',new Array());
	//	md.log('ss first',ss);
//		md.log('s3 first',s3);
	//	md.log('s3.length',ss.length);
		for(var i=0, n=s.length, indent=false; i<n; i++){ //indent and double spaces to &nbsp;
			var prev = (i > 0)?s.charAt(i-1):'\n';
			var next = (i + 1 < n)?s.charAt(i+1):'\n';
			var cur = s.charAt(i);

			if(cur=='\n' && next==' '){
				indent = true; //cur space is an indent.
			} else if(indent && cur!=' '){
				indent = false;
			}

			ss.push(
				(cur==' ' && (prev==' ' || next==' ' || indent)) ? '&nbsp;' : cur)
			}
	//	md.log('ss',ss);
		s = ss.join('');
	}

	if(escapeLineBreaks){
		s = s.replace(/\r\n/g,'\n').replace(/\n/g,'<br>\n');
	}

	return s;
}









// remove an element from an array given the value of the element you'd like to remove
Array.prototype.remove = function (value){
	for (count = 0; count < this.length; count++) {
		if (this[count] == value)
			this.splice(count, 1);
	}
}





















	var jsMessageManager = Class.create ();
	jsMessageManager.prototype = {
		messageBlocks: new Object (),
		identifier: "jsMessageManager",
		randomIdentifier: undefined,

		// constructor
		initialize: function () {
			// unique identifier
			this.randomIdentifier = Math.round ((Math.random () * 10000000) + 1);
		},

		// generate the domId of a message block holder div
		get_message_block_holder_domId: function () {
			return this.identifier + "_" + this.randomIdentifier + "_messageDivs";
		},

		// generate the domId of a message block div
		get_message_block_domId: function (messageBlockId) {
			return this.identifier + "_" + this.randomIdentifier + "_message_" + messageBlockId;
		},

		// make sure a message block and it's div exist
		ensure_message_block_exists: function (messageBlockId) {
			if ($(this.get_message_block_holder_domId ()) == undefined) {
				// set up the main div that will hold the message divs
				var element_div = document.createElement ("div");
				element_div.setAttribute ("id", this.get_message_block_holder_domId ());
				$("toolsDiv").appendChild (element_div);
			}
			if (this.messageBlocks[messageBlockId] == undefined) {
				this.messageBlocks[messageBlockId] = new messageBlock ();
				var element_div = document.createElement ("div");
				element_div.setAttribute ("id", this.get_message_block_domId (messageBlockId));
				element_div.className = "messageBlock";
				element_div.style.display = "none";
				element_div.style.position = "absolute";
				element_div.style.zIndex = "100";
				element_div.style.padding = "10px";
//				element_div.style.backgroundColor = "#E0E0E0";
//				element_div.style.border = "1px solid black";
				$(this.get_message_block_holder_domId ()).appendChild (element_div);

				gc_popOverManager.define_pop_over (
				this.get_message_block_domId (messageBlockId),
				this.messageBlocks[messageBlockId].placeHolderId,
				this.messageBlocks[messageBlockId].positionInfo,
				this.messageBlocks[messageBlockId].displayEffectType,
				this.messageBlocks[messageBlockId].displayEffectOptions,
				this.messageBlocks[messageBlockId].hideEffectType,
				this.messageBlocks[messageBlockId].hideEffectOptions,
				undefined);
			}
		},

		// see if the specified message block exists or not
		message_block_exists: function (messageBlockId) {
			return this.messageBlocks[messageBlockId] != undefined;
		},


		// add a message to a message block
		add_message: function (messageBlockId, message, messageId) {
			this.ensure_message_block_exists (messageBlockId);
			this.messageBlocks[messageBlockId].add_message (message, messageId);
		},

		// remove the messages from a message block
		reset_messages: function (messageBlockId) {
			this.ensure_message_block_exists (messageBlockId);
			this.messageBlocks[messageBlockId].reset_messages ();
		},



		// anchor a message block to another element in the html dom
		// set it's position info
		// positionInfo =
		// {	xSourcePoint: left, middle, right
		//		ySourcePoint: top, middle, bottom
		//		xDestPoint: left, middle, right
		//		yDestPoint: top, middle, bottom
		//		xPixelOffset: integer
		//		yPixelOffset: integer
		//		xPercentOffset: integer
		//		yPercentOffset: integer }
		set_place_holder: function (messageBlockId, placeHolderId, positionInfo) {
			this.ensure_message_block_exists (messageBlockId);
			this.messageBlocks[messageBlockId].placeHolderId = placeHolderId;
			this.messageBlocks[messageBlockId].positionInfo = positionInfo;
		},

		// set a message in a message block (reset the block first)
		set_message: function (messageBlockId, message, messageId) {
			this.reset_messages (messageBlockId);
			this.ensure_message_block_exists (messageBlockId);
			this.messageBlocks[messageBlockId].add_message (message, messageId);
		},


		// set a message in a message block (reset the block first)
		set_display_effects: function (messageBlockId, displayEffectType, displayEffectOptions, hideEffectType, hideEffectOptions) {
			this.ensure_message_block_exists (messageBlockId);
			this.messageBlocks[messageBlockId].set_display_effects (displayEffectType, displayEffectOptions, hideEffectType, hideEffectOptions);
		},


		// render a message block
		render_message_block: function (messageBlockId) {
//alert ("render " + messageBlockId + " " + this.messageBlocks[messageBlockId].placeHolderId);

			gc_popOverManager.define_pop_over (
				this.get_message_block_domId (messageBlockId),
				this.messageBlocks[messageBlockId].placeHolderId,
				this.messageBlocks[messageBlockId].positionInfo,
				this.messageBlocks[messageBlockId].displayEffectType,
				this.messageBlocks[messageBlockId].displayEffectOptions,
				this.messageBlocks[messageBlockId].hideEffectType,
				this.messageBlocks[messageBlockId].hideEffectOptions,
				undefined);

			this.ensure_message_block_exists (messageBlockId);

			// remove the content from this message block's div
			while ($(this.get_message_block_domId (messageBlockId)).hasChildNodes ())
				$(this.get_message_block_domId (messageBlockId)).removeChild ($(this.get_message_block_domId (messageBlockId)).firstChild);

			var divCount = 0;
			for (var index in this.messageBlocks[messageBlockId].messages) {
				if (divCount++ > 0) {
					var element_div = document.createElement ("div");
					element_div.className = "contentEnd";
					element_div.style.height = "3px";
					element_div.style.width = "1px";
					$(this.get_message_block_domId (messageBlockId)).appendChild (element_div);
				}
				var element_div = document.createElement ("div");
//				element_div.appendChild (document.createTextNode (this.messageBlocks[messageBlockId].messages[index]));
//				element_div.setAttribute ("id", this.identifier + "_" + this.randomIdentifier + "_message_" + messageBlockId);
				$(this.get_message_block_domId (messageBlockId)).appendChild (element_div);
				$(element_div).update (this.messageBlocks[messageBlockId].messages[index]);
			}
		},

		// display a message block
		display_message_block: function (messageBlockId, timeLimitMS, forceShow) {
			this.ensure_message_block_exists (messageBlockId);

			if (this.messageBlocks[messageBlockId].hideTimeout != undefined)
				clearTimeout (this.messageBlocks[messageBlockId].hideTimeout);
			this.render_message_block (messageBlockId);

			if (forceShow != undefined) {
				// change the element's position
				var temp = gc_geometry.determine_relative_position (this.messageBlocks[messageBlockId].placeHolderId, this.get_message_block_domId (messageBlockId), this.messageBlocks[messageBlockId].positionInfo);
				$(this.get_message_block_domId (messageBlockId)).style.left = temp.x + "px";
				$(this.get_message_block_domId (messageBlockId)).style.top = temp.y + "px";

				$(this.get_message_block_domId (messageBlockId)).style.opacity = 1;
				$(this.get_message_block_domId (messageBlockId)).show ();
			}
			else
				gc_popOverManager.display_pop_over (this.get_message_block_domId (messageBlockId));

			if (timeLimitMS != undefined)
				this.messageBlocks[messageBlockId].hideTimeout = setTimeout ("jsMessageManager.hide_message_block ('" + messageBlockId + "');", timeLimitMS);
		},

		reposition_message_block: function (messageBlockId) {
			this.ensure_message_block_exists (messageBlockId);

			// change the element's position
			var temp = gc_geometry.determine_relative_position (this.messageBlocks[messageBlockId].placeHolderId, this.get_message_block_domId (messageBlockId), this.messageBlocks[messageBlockId].positionInfo);
			$(this.get_message_block_domId (messageBlockId)).style.left = temp.x + "px";
			$(this.get_message_block_domId (messageBlockId)).style.top = temp.y + "px";
		},

		// show a single message in a message block
		show_message: function (messageBlockId, message, timeLimitMS, forceShow) {
			this.set_message (messageBlockId, message);
			this.display_message_block (messageBlockId, timeLimitMS, forceShow);
		},


		// hide a message block
		hide_message_block: function (messageBlockId) {
			this.ensure_message_block_exists (messageBlockId);
			this.messageBlocks[messageBlockId].hideTimeout = undefined;
//			$(this.get_message_block_domId (messageBlockId)).hide ();
			gc_popOverManager.hide_pop_over (this.get_message_block_domId (messageBlockId));
		},

		// determine if the given message is being shown or not
		is_message_visible: function (messageBlockId) {
			var domId = this.get_message_block_domId (messageBlockId);
			if ($(domId))
				return $(domId).visible ();
			return false;
		}
	}






	var messageBlock = Class.create ();
	messageBlock.prototype = {
		messages: new Object (),
		messageCount: 0,
		placeHolderId: undefined,
		positionInfo: new Object,
		displayEffectType: "Appear",
		displayEffectOptions: { duration: 0.4 },
		hideEffectType: "Fade",
		hideEffectOptions: { duration: 1 },
		hideTimeout: undefined,

		// constructor
		initialize: function () {
		},

		add_message: function (message, messageId) {
			if (messageId != undefined)
				this.messages[messageId] = message;
			else
				this.messages["unnamed" + this.messageCount] = message;
			this.messageCount++;
			return true;
		},

		reset_messages: function () {
			this.messages = new Object ();
			return true;
		},

		set_display_effects: function (displayEffectType, displayEffectOptions, hideEffectType, hideEffectOptions) {
			if ((displayEffectType != undefined) && (displayEffectType != null))
				this.displayEffectType = displayEffectType;
			if ((displayEffectOptions != undefined) && (displayEffectType != null))
				this.displayEffectOptions = displayEffectOptions;
			if ((hideEffectType != undefined) && (displayEffectType != null))
				this.hideEffectType = hideEffectType;
			if ((hideEffectOptions != undefined) && (displayEffectType != null))
				this.hideEffectOptions = hideEffectOptions;
			return true;
		}
	}

	jsMessageManager = new jsMessageManager ();
















	var jsFormManager = Class.create ();
	jsFormManager.prototype = {
		iframeForms: new Object (),
		identifier: "jsFormManager",
		randomIdentifier: undefined,

		// constructor
		initialize: function () {
			// unique identifier
			this.randomIdentifier = Math.round ((Math.random () * 10000000) + 1);
		},

		// generate the domId of a message block holder div
		get_iframe_domId: function () {
			return this.identifier + "_" + this.randomIdentifier + "_iframes";
		},

		// 
		submit_form: function (formDomId, targetUrl, httpMethod) {
			if ($(formDomId) != null) {

				// make sure the main tools div exists
				if ($(this.get_iframe_domId ()) == undefined) {
					// set up the main div that will hold the message divs
					var element_div = document.createElement ("div");
					element_div.setAttribute ("id", this.get_iframe_domId ());
					$("toolsDiv").appendChild (element_div);
				}




				var id = this.get_iframe_domId () + "_" + formDomId + "_iframe";

				// remove the iframe if it exists
				if ($(id) != null)
					$(id).remove ();

				var div = document.createElement ("div");
				div.innerHTML = '<iframe src="about:blank" style="display: none;" id="' + id + '" name="' + id + '" onLoad="jsFormManager.load_finished (this.id);"></iframe>';
				$(this.get_iframe_domId ()).appendChild (div);

				httpMethod = String (httpMethod);
				httpMethod = httpMethod.toUpperCase ();
				if ((httpMethod != 'GET') && (httpMethod != 'POST'))
					httpMethod = 'POST';

				$(formDomId).setAttribute ("action", targetUrl);
				$(formDomId).setAttribute ("target", id);
				$(formDomId).setAttribute ("method", httpMethod);
				$(formDomId).setAttribute ("enctype", "multipart/form-data");	// firefox
				$(formDomId).setAttribute ("encoding", "multipart/form-data");	// internet explorer
				$(formDomId).submit ();
			}
		},

		load_finished: function (iframeDomId) {
//			var i = $(iframeDomId);
			var i = document.getElementById (iframeDomId);
			if (i.contentDocument)
				var d = i.contentDocument;
			else if (i.contentWindow)
				var d = i.contentWindow.document;
			else
				var d = window.frames[id].document;

			if (d.location.href == "about:blank")
				return;
//			if (typeof(i.onComplete) == 'function')
//				i.onComplete(d.body.innerHTML);

			var xmlDoc = null;
			try {	//Internet Explorer
				xmlDoc = new ActiveXObject ("Microsoft.XMLDOM");
				xmlDoc.async = "false";
//				xmlDoc.loadXML (d.body.innerHTML);
				xmlDoc.loadXML (d.getElementById ('response').value);
			}
			catch (e) {
				var xmlDoc = null;
				try {	// Firefox, Mozilla, Opera, etc.

//					xmlDoc = document.implementation.createDocument ("", "", null);
//					xmlDoc.async = "false";

					parser = new DOMParser ();
//					xmlDoc = parser.parseFromString (d.body.innerHTML, "text/xml");
					xmlDoc = parser.parseFromString (d.getElementById ('response').value, "text/xml");
				}
				catch (e) {
					var xmlDoc = null;
				}
			}

			if (xmlDoc != null) {
//				alert (d.body.innerHTML);
//				alert (d.getElementById ('response'));
				return gc_ajaxManager.process_xml (xmlDoc);
			}
		}
	}

	jsFormManager = new jsFormManager ();











































var jsOverviewManager2 = Class.create ();
jsOverviewManager2.prototype = {

	url_tickIcon: '',
	url_noticeIcon: '',
	url_deleteIcon: '',
	url_loading: '',

	currentPopoverDomIds: new Array (),
	popoverTimeouts: new Array (),
	nameSpaces: new Array (),
	popOverNameSpaces: new Array (),

	// constructor
	initialize: function (url_tickIcon, url_noticeIcon, url_deleteIcon, url_loading) {
		this.url_tickIcon = url_tickIcon;
		this.url_noticeIcon = url_noticeIcon;
		this.url_deleteIcon = url_deleteIcon;
		this.url_loading = url_loading;

		setTimeout ("jsOverviewManager2.check_enable_page ();", 4000);
		this.cancel_popover_hide_timeout ('helo');
		return true;
	},

	register_name_space: function (nameSpace, disablePage, hideOnMouseOut, clearNameSpacesOnShow, clearNameSpacesOnHide) {

		if (clearNameSpacesOnShow == undefined)
			clearNameSpacesOnShow = [nameSpace];
//		if (!this.is_array (clearNameSpacesOnShow))
//			clearNameSpacesOnShow = [clearNameSpacesOnShow];

		if (clearNameSpacesOnHide == undefined)
			clearNameSpacesOnHide = [nameSpace];
//		if (!this.is_array (clearNameSpacesOnHide))
//			clearNameSpacesOnHide = [clearNameSpacesOnHide];

		this.nameSpaces[nameSpace] = {	nameSpace: nameSpace,
										disablePage: disablePage,
										hideOnMouseOut: hideOnMouseOut,
										clearNameSpacesOnShow: clearNameSpacesOnShow,
										clearNameSpacesOnHide: clearNameSpacesOnHide};
	},

	remember_dom_id_name_space: function (linkDomId, nameSpace) {
		this.popOverNameSpaces[linkDomId] = nameSpace;
		return true;
	},

	get_name_space: function (nameSpace) {
		if (this.nameSpaces[nameSpace] != undefined)
			return this.nameSpaces[nameSpace];
		else
			return {	nameSpace: 'default',
						disablePage: true,
						hideOnMouseOut: false,
						clearNameSpacesOnShow: [nameSpace],
						clearNameSpacesOnHide: [nameSpace] };
	},









	watch_popover_link: function (linkDomId, placeHolderDomId, popoverDomId, popoverUri, positionInfo, popoverWidth, popoverTitle, nameSpace) {
		nameSpaceInfo = this.get_name_space (nameSpace);
		nameSpace = nameSpaceInfo.nameSpace;
		this.remember_dom_id_name_space (popoverDomId, nameSpace);

		if (($(linkDomId) != null) && ($(placeHolderDomId) != null)) {
			$(linkDomId).observe ('click', function (event) {

				for (count = 0; count < nameSpaceInfo.clearNameSpacesOnShow.length; count++) {
					tempNameSpace = nameSpaceInfo.clearNameSpacesOnShow[count];
					if (jsOverviewManager2.currentPopoverDomIds[tempNameSpace] != popoverDomId) {
						jsMessageManager.hide_message_block (jsOverviewManager2.currentPopoverDomIds[tempNameSpace]);
						jsOverviewManager2.currentPopoverDomIds[tempNameSpace] = 0;
					}
				}
				jsOverviewManager2.currentPopoverDomIds[nameSpace] = popoverDomId;

				if (nameSpaceInfo.disablePage)
					jsOverviewManager2.disable_page ();


				var popOverHtml = '';
				popOverHtml = popOverHtml + '<div id="' + popoverDomId + '" class="popOver" style="width: ' + popoverWidth + ';">';
				if (popoverTitle != '')
					popOverHtml = popOverHtml + '<div id="' + popoverDomId + '_title" class="title">' + popoverTitle + '</div>';
				popOverHtml = popOverHtml + '<img src="' + jsOverviewManager2.url_deleteIcon + '" title="Close" onClick="jsOverviewManager2.hide_popover (\'' + popoverDomId + '\');" class="close">';
				popOverHtml = popOverHtml + '<div class="contentEnd"></div>';
				popOverHtml = popOverHtml + '<div id="' + popoverDomId + '_content"><span class="formSubtitle">Please wait</span><br /><br /><img id="' + popoverDomId + '_pleaseWait" src="' + jsOverviewManager2.url_loading + '"></div>';
				popOverHtml = popOverHtml + '</div>';

				jsMessageManager.set_place_holder (popoverDomId, placeHolderDomId, positionInfo);
				jsMessageManager.set_display_effects (popoverDomId, "Appear", { duration: 0.4 }, "DropOut", { duration: 0.5 });
//				jsMessageManager.reset_messages (popoverDomId);
				jsMessageManager.show_message (popoverDomId, popOverHtml);

				if (nameSpaceInfo.hideOnMouseOut) {
					eval ('var temp = function () { jsOverviewManager2.cancel_popover_hide_timeout ("' + popoverDomId + '");};');
					$(popoverDomId).onmouseover = temp;
					eval ('var temp = function () { jsOverviewManager2.hide_popover_delayed ("' + popoverDomId + '");};');
					$(popoverDomId).onmouseout = temp;
				}

				$(popoverDomId + "_pleaseWait").src = jsOverviewManager2.url_loading;

				gc_ajaxManager.request (popoverUri,
					{	method: 'get'}
					, 'popover');
			});
		}
	},

	watch_popover_link_non_ajax: function (linkDomId, placeHolderDomId, popoverDomId, positionInfo, popoverWidth, popoverTitle, content, nameSpace, javascriptToRunAfterwards) {
		var nameSpaceInfo = this.get_name_space (nameSpace);
		nameSpace = nameSpaceInfo.nameSpace;
		this.remember_dom_id_name_space (popoverDomId, nameSpace);

		if (($(linkDomId) != null) && ($(placeHolderDomId) != null)) {
			$(linkDomId).observe ('click', function (event) {

				for (count = 0; count < nameSpaceInfo.clearNameSpacesOnShow.length; count++) {
					tempNameSpace = nameSpaceInfo.clearNameSpacesOnShow[count];
					if (jsOverviewManager2.currentPopoverDomIds[tempNameSpace] != popoverDomId) {
						jsMessageManager.hide_message_block (jsOverviewManager2.currentPopoverDomIds[tempNameSpace]);
						jsOverviewManager2.currentPopoverDomIds[tempNameSpace] = 0;
					}
				}
				jsOverviewManager2.currentPopoverDomIds[nameSpace] = popoverDomId;

				if (nameSpaceInfo.disablePage)
					jsOverviewManager2.disable_page ();

				var popOverHtml = '';
//				popOverHtml = popOverHtml + '<div id="' + popoverDomId + '" class="popOver" style="width: ' + popoverWidth + ';" onMouseOver="jsOverviewManager2.cancel_popover_hide_timeout (\'' + popoverDomId + '\');" onMouseOut="jsOverviewManager2.hide_popover_delayed (\'' + popoverDomId + '\');">';
				popOverHtml = popOverHtml + '<div id="' + popoverDomId + '" class="popOver" style="width: ' + popoverWidth + ';">';
				if (popoverTitle != '')
					popOverHtml = popOverHtml + '<div id="' + popoverDomId + '_title" class="title">' + popoverTitle + '</div>';
				popOverHtml = popOverHtml + '<img src="' + jsOverviewManager2.url_deleteIcon + '" title="Close" onClick="jsOverviewManager2.hide_popover (\'' + popoverDomId + '\');" class="close">';
				popOverHtml = popOverHtml + '<div class="contentEnd"></div>';
				popOverHtml = popOverHtml + '<div style="text-align: left;">' + content + '</div>';
				popOverHtml = popOverHtml + '</div>';

				jsMessageManager.set_place_holder (popoverDomId, placeHolderDomId, positionInfo);
				jsMessageManager.set_display_effects (popoverDomId, "Appear", { duration: 0.4 }, "DropOut", { duration: 0.5 });
//				jsMessageManager.reset_messages (popoverDomId);
				jsMessageManager.show_message (popoverDomId, popOverHtml);

				if (nameSpaceInfo.hideOnMouseOut) {
					eval ('var temp = function () { jsOverviewManager2.cancel_popover_hide_timeout ("' + popoverDomId + '");};');
					$(popoverDomId).onmouseover = temp;
					eval ('var temp = function () { jsOverviewManager2.hide_popover_delayed ("' + popoverDomId + '");};');
					$(popoverDomId).onmouseout = temp;
				}

				if (javascriptToRunAfterwards != undefined)
					eval (javascriptToRunAfterwards);
			});
		}
	},

	watch_link: function (linkDomId, linkUri) {
		if ($(linkDomId) != null) {
			$(linkDomId).observe ('click', function (event) {
				document.location.href = linkUri;
			});
		}

		var linkDomId2 = linkDomId + '_left';
		if ($(linkDomId2) != null) {
			$(linkDomId2).observe ('click', function (event) {
				document.location.href = linkUri;
			});
		}
	},

	create_popover_non_ajax: function (placeHolderDomId, popoverDomId, positionInfo, popoverWidth, popoverTitle, content, nameSpace, addCloseX) {
		var nameSpaceInfo = this.get_name_space (nameSpace);
		nameSpace = nameSpaceInfo.nameSpace;
		this.remember_dom_id_name_space (popoverDomId, nameSpace);

		for (count = 0; count < nameSpaceInfo.clearNameSpacesOnShow.length; count++) {
			tempNameSpace = nameSpaceInfo.clearNameSpacesOnShow[count];
			if (jsOverviewManager2.currentPopoverDomIds[tempNameSpace] != popoverDomId) {
				jsMessageManager.hide_message_block (jsOverviewManager2.currentPopoverDomIds[tempNameSpace]);
				jsOverviewManager2.currentPopoverDomIds[tempNameSpace] = 0;
			}
		}
		jsOverviewManager2.currentPopoverDomIds[nameSpace] = popoverDomId;

		if (nameSpaceInfo.disablePage)
			jsOverviewManager2.disable_page ();

		var popOverHtml = '';
//		popOverHtml = popOverHtml + '<div id="' + popoverDomId + '" class="popOver" style="width: ' + popoverWidth + ';" onMouseOver="jsOverviewManager2.cancel_popover_hide_timeout (\'' + popoverDomId + '\');" onMouseOut="jsOverviewManager2.hide_popover_delayed (\'' + popoverDomId + '\');">';
		popOverHtml = popOverHtml + '<div id="' + popoverDomId + '" class="popOver" style="width: ' + popoverWidth + ';">';
		if (popoverTitle != '')
			popOverHtml = popOverHtml + '<div id="' + popoverDomId + '_title" class="title">' + popoverTitle + '</div>';
		if (addCloseX != '')
			popOverHtml = popOverHtml + '<img src="' + jsOverviewManager2.url_deleteIcon + '" title="Close" onClick="jsOverviewManager2.hide_popover (\'' + popoverDomId + '\');" class="close">';
		if ((popoverTitle != '') || (addCloseX != ''))
			popOverHtml = popOverHtml + '<div class="contentEnd"></div>';
		popOverHtml = popOverHtml + '<div style="text-align: left;">' + content + '</div>';
		popOverHtml = popOverHtml + '</div>';

		jsMessageManager.set_place_holder (popoverDomId, placeHolderDomId, positionInfo);
		jsMessageManager.set_display_effects (popoverDomId, "Appear", { duration: 0.4 }, "DropOut", { duration: 0.5 });
//		jsMessageManager.reset_messages (popoverDomId);
		jsMessageManager.show_message (popoverDomId, popOverHtml);

		if (nameSpaceInfo.hideOnMouseOut) {
			eval ('var temp = function () { jsOverviewManager2.cancel_popover_hide_timeout ("' + popoverDomId + '");};');
			$(popoverDomId).onmouseover = temp;
			eval ('var temp = function () { jsOverviewManager2.hide_popover_delayed ("' + popoverDomId + '");};');
			$(popoverDomId).onmouseout = temp;
		}
	},

	cancel_popover_hide_timeout: function (popoverDomId) {
//		alert ('cancel_popover_hide_timeout: "' + popoverDomId + '"');
		if (typeof (this.popoverTimeouts[popoverDomId]) != undefined)
			clearTimeout (this.popoverTimeouts[popoverDomId]);
		this.popoverTimeouts[popoverDomId] = undefined;
	},

	hide_popover_delayed: function (popoverDomId) {
//		alert ('hide_popover_delayed: "' + popoverDomId + '"');
		this.popoverTimeouts[popoverDomId] = setTimeout ("jsOverviewManager2.hide_popover ('" + popoverDomId + "');", 400);
	},

	hide_popover: function (popoverDomId) {
//		alert ('hide_popover: "' + popoverDomId + '"');
		nameSpace = this.popOverNameSpaces[popoverDomId];
		nameSpaceInfo = this.get_name_space (nameSpace);

		var hidThisPopover = false;
		for (count = 0; count < nameSpaceInfo.clearNameSpacesOnHide.length; count++) {
			tempNameSpace = nameSpaceInfo.clearNameSpacesOnHide[count];
//alert (tempNameSpace);
//gc_var_dump (nameSpaceInfo.clearNameSpacesOnHide);
			this.cancel_popover_hide_timeout (jsOverviewManager2.currentPopoverDomIds[tempNameSpace]);
			jsMessageManager.hide_message_block (jsOverviewManager2.currentPopoverDomIds[tempNameSpace]);
			jsOverviewManager2.currentPopoverDomIds[tempNameSpace] = 0;

			if (jsOverviewManager2.currentPopoverDomIds[tempNameSpace] == popoverDomId)
				hidThisPopover = true;
		}

		// if this popover wasn't hidden because it's namespace wasn't hidden
		// then hide it itself
		if (!hidThisPopover) {
			this.cancel_popover_hide_timeout (popoverDomId);
			jsMessageManager.hide_message_block (popoverDomId);
		}

		if (nameSpaceInfo.disablePage)
			jsOverviewManager2.enable_page ();
	},






















	disable_page: function () {
		if ($("pageDimmer") == undefined) {
			var element_div = document.createElement ("div");
			element_div.setAttribute ("id", "pageDimmer");
			element_div.style.position = "absolute";
			element_div.style.left = "0px";
			element_div.style.top = "0px";
			element_div.style.zIndex = 50;
			element_div.style.display = "none";
			element_div.style.backgroundColor = "black";
			element_div.style.opacity = "0.23";
			element_div.style.filter = "alpha(opacity=25)";
			$("toolsDiv").appendChild (element_div);
		}
		pageDimensions = gc_geometry.find_total_page_dimensions ();
		$("pageDimmer").style.width = pageDimensions.width;
		$("pageDimmer").style.height = pageDimensions.height;
		$("pageDimmer").show ();
	},

	enable_page: function () {
		if ($("pageDimmer") != null)
			$("pageDimmer").hide ();
	},

	is_page_disabled: function () {
		if ($("pageDimmer") == null)
			return false;
		return $("pageDimmer").visible ();
	},

	check_enable_page: function (nameSpace) {
/**
		nameSpaceInfo = this.get_name_space (nameSpace);
		nameSpace = nameSpaceInfo.nameSpace;

		if ($("pageDimmer") != undefined) {
			if ((this.currentPopoverDomIds[nameSpace] == 0) && ($("pageDimmer").visible ()))
				this.enable_page ();
			else if ((this.currentPopoverDomIds[nameSpace] != 0) && (!$("pageDimmer").visible ()))
				this.disable_page ();
		}
		setTimeout ("jsOverviewManager2.check_enable_page (" + nameSpace + ");", 4000);
/**/
	},



	is_array: function (obj) {
		if ((obj != undefined) && (obj.constructor.toString ().indexOf ("Array") == -1))
			return false;
		else
			return true;
	}
}







align_elements = function (elementNamesArray, forceAlign, message) {
	var previousYOffset = 0;
	var maxHeight = 0;
	var inspectedElements = new Array ();
	var wereVisible = new Array ();

	// find out which ones were originally shown and show them anyway
	for (var count = 0; count < elementNamesArray.length; count++) {
		var liElementName = elementNamesArray[count];
		if ($(liElementName)) {
			wereVisible[count] = $(liElementName).visible ();
			$(liElementName).show ();
			$(liElementName).setStyle ({'height': 'auto'});
		}
	}

	for (var count = 0; count < elementNamesArray.length; count++) {
		var liElementName = elementNamesArray[count];

		if ($(liElementName)) {

			// see if this item has a different y offset to the previous items
			var temp = Position.cumulativeOffset ($(liElementName));

			var yOffset = parseInt (temp[1]);

			if ((yOffset != previousYOffset) && (inspectedElements.length > 0) && (!forceAlign)) {

				// adjust the height of each of the items in the row
				if ((inspectedElements.length > 1)) {
					for (var count2 = 0; count2 < inspectedElements.length; count2++)
						$(inspectedElements[count2]).setStyle ( { "height" : maxHeight + "px" } );
				}

				// start the list of inspected elements off again
				var previousYOffset = 0;
				var maxHeight = 0;
				var inspectedElements = new Array ();

				// the row above this element has changed,  re-calculate it's offset
				var temp = Position.cumulativeOffset ($(liElementName));
				var yOffset = parseInt (temp[1]);
			}

			// record the height of the current item
			var temp = $(liElementName).getDimensions ();
			var height = parseInt (temp.height);
			if (height > maxHeight)
				maxHeight = height;
			inspectedElements[inspectedElements.length] = liElementName;

//if (liElementName == 'descriptionBlockDiningGeneric')
//				alert (yOffset + " " + message + " " + height);

			previousYOffset = yOffset;
		}
	}

	// if there are any elements that were left over
	if (inspectedElements.length > 0) {
		// adjust the height of each of the items in the row
		for (var count2 = 0; count2 < inspectedElements.length; count2++)
			$(inspectedElements[count2]).setStyle ( { "height" : maxHeight + "px" } );
	}

	// return each element back to it's original show/hide status
	for (var count = 0; count < elementNamesArray.length; count++) {
		var liElementName = elementNamesArray[count];
		if ($(liElementName)) {
			if (!wereVisible[count])
				$(liElementName).hide ();
		}
	}

	return true;
}

vertically_center_elements = function (elementNamesArray) {

	for (var count = 0; count < elementNamesArray.length; count++) {
		var element = $(elementNamesArray[count]);
		if ($(element)) {
			var parentElement = element.ancestors ().first ();

			var heightElement = parseInt (element.getStyle ('height'));
			var heightParentElement = parseInt (parentElement.getStyle ('height'));
			var newHeight = String (parseInt ((heightParentElement - heightElement) / 2));

			element.setStyle ( { "marginTop": newHeight + "px" });
		}

	}

	return true;
}











function register_page_view_with_google2 (url) {
//	alert (url);
//	return;
	try {
		var pageTracker = _gat._getTracker("UA-698294-1");
		pageTracker._trackPageview (url);
	} catch(err) {}
}








jQuery ().ready (function () {
	observe_nav_popovers ();
	return true;
});

// observe the nav links which have popover content,
// create the popover when the mouse is moved over them
observe_nav_popovers = function () {
	navPopoverShowTimeouts = new Array ();
	if ((typeof (jsOverviewManager2) == 'undefined') || (typeof (jsOverviewManager2) == 'function'))
		jsOverviewManager2 = new jsOverviewManager2 ();
	jsOverviewManager2.register_name_space ('linkNavPopover', false, true, ['linkNavPopover'], []);

	jQuery (".jsNavLink").bind ("mouseenter", function () {
		var id = jQuery (this).attr ('id').replace (/[^0-9]+/, '');
		var content = jQuery ("#template_navLinkPopoverContent" + id).html ();
		if (content) {
			var popoverDomId = 'popover_navLink' + id;

			// find out the popover's width from the jsWidthXYZ css class of the template
			var width = 680;
			var classes = jQuery ("#template_navLinkPopoverContent" + id).attr ('class').split(' ');
			for (var count = 0; count < classes.length; count++) {
				if (classes[count].substr (0, 'jsWidth'.length) == 'jsWidth') {
					var tempWidth = classes[count].substr ('jsWidth'.length);
					if (tempWidth > 0)
						width = tempWidth;
				}
			}

//			jsOverviewManager2.create_popover_non_ajax (jQuery (this).attr ('id'), popoverDomId, { xSourcePoint: 'left', xDestPoint: 'left', ySourcePoint: 'bottom', yDestPoint: 'top', xPixelOffset: 0, yPixelOffset: 0 }, width, '', content, 'linkNavPopover', false);
			var temp = function (domId, popoverDomId, options, width, content, namespace) {
				var temp2 = function () {
					jsOverviewManager2.create_popover_non_ajax (domId, popoverDomId, options, width, '', content, 'linkNavPopover', false);
				}
				navPopoverShowTimeouts[popoverDomId] = setTimeout (temp2, 400);
			};
			temp (jQuery (this).attr ('id'), popoverDomId, { xSourcePoint: 'left', xDestPoint: 'left', ySourcePoint: 'bottom', yDestPoint: 'top', xPixelOffset: 0, yPixelOffset: 0 }, width, content, 'linkNavPopover');
		}
	});

	jQuery (".jsNavLink").bind ("mouseleave", function () {
		var id = jQuery (this).attr ('id').replace (/[^0-9]+/, '');
		var content = jQuery ("#template_navLinkPopoverContent" + id).html ();
		if (content) {
			var popoverDomId = 'popover_navLink' + id;

			clearTimeout (navPopoverShowTimeouts[popoverDomId]);
		}
	});

	jQuery (".jsNavLink").map (function () {
		var id = jQuery (this).attr ('id').replace (/[^0-9]+/, '');
		var content = jQuery ("#template_navLinkPopoverContent" + id).html ();
		if (content) {
			var popoverDomId = 'popover_navLink' + id;

			eval ('var temp = function () { jsOverviewManager2.cancel_popover_hide_timeout ("' + popoverDomId + '");};');
			$(jQuery (this).attr ('id')).onmouseover = temp;
			eval ('var temp = function () { jsOverviewManager2.hide_popover_delayed ("' + popoverDomId + '");};');
			$(jQuery (this).attr ('id')).onmouseout = temp;
		}
	});
}