// $Header: /usr/local/cvsroot/district/web/lib/top_nav_menu.js,v 4.43.2.1 2007/11/08 20:57:40 jpd Exp $CMECF.namespace("MainMenu");// Functions from YAHOO.CMECF.util.Event = YAHOO.util.Event;CMECF.util.Dom = YAHOO.util.Dom;CMECF.util.Connect = YAHOO.util.Connect;CMECF.widget.Panel = YAHOO.widget.Panel;CMECF.widget.Module = YAHOO.widget.Module;CMECF.MainMenu.Menu = YAHOO.widget.Menu;CMECF.MainMenu.MenuItem = YAHOO.widget.MenuItem;CMECF.MainMenu.MenuBar = YAHOO.widget.MenuBar;CMECF.MainMenu.MenuBarItem = YAHOO.widget.MenuBarItem;CMECF.MainMenu.OverlayManager = new YAHOO.widget.OverlayManager();// Override YAHOO default images.CMECF.MainMenu.MenuItem.prototype.COLLAPSED_SUBMENU_INDICATOR_TEXT = ">";CMECF.MainMenu.MenuItem.prototype.EXPANDED_SUBMENU_INDICATOR_TEXT = ">";CMECF.MainMenu.MenuItem.prototype.DISABLED_SUBMENU_INDICATOR_TEXT = "X";CMECF.MainMenu.MenuBarItem.prototype.COLLAPSED_SUBMENU_INDICATOR_TEXT = "v";CMECF.MainMenu.MenuBarItem.prototype.EXPANDED_SUBMENU_INDICATOR_TEXT = "v";CMECF.MainMenu.MenuBarItem.prototype.DISABLED_SUBMENU_INDICATOR_TEXT = "X";CMECF.MainMenu.hideSubmenus = function() {	if (CMECF.MainMenu.TopMenu.activeItem) {		var oSubmenu = CMECF.MainMenu.TopMenu.activeItem.cfg.getProperty("submenu");		if (oSubmenu) {			oSubmenu.hide();		}	}	CMECF.MainMenu.focusOnFirstItem();};CMECF.MainMenu.focusOnMainMenuItem = function (menuObject) {	var oActiveItem = menuObject.parent.activeItem;	// Hide any other submenus this might be visible	if (oActiveItem && oActiveItem != menuObject) {		menuObject.parent.clearActiveItem();	}	// Select and focus the current MenuItem instance	menuObject.cfg.setProperty("selected", true);	menuObject.focus();	// Show the submenu for this instance	var oSubmenu = menuObject.cfg.getProperty("submenu");	if (oSubmenu) {		oSubmenu.show();	}};CMECF.MainMenu.addMainMenuItem = function (menubar_item, object_name, hot_key_code) {	if (object_name) {		menubar_item.cfg.setProperty('submenu', { id: object_name, itemdata: CMECF.MainMenu.oMenuData[object_name], useClass: "cmecfsubmenu1"});	}	if ( ! CMECF.MainMenu.hotkeys) {		CMECF.MainMenu.hotkeys = new Object();	}	if (hot_key_code) {		CMECF.MainMenu.hotkeys[hot_key_code] = menubar_item;	}};CMECF.MainMenu.preloadMenuImages = function () {	// pre-loading images	CMECF.MainMenu.onImgArray = new Array();	CMECF.MainMenu.onImgArray["helpImage"] = new Image();	CMECF.MainMenu.onImgArray["helpImage"].src = "/graphics/menubar-help-hover.gif";	CMECF.MainMenu.offImgArray = new Array();	CMECF.MainMenu.offImgArray["helpImage"] = new Image();	CMECF.MainMenu.offImgArray["helpImage"].src = "/graphics/menubar-help-out.gif";};CMECF.MainMenu.imageOn = function (image) {	if(CMECF.MainMenu.imageHoverTimeout) window.clearTimeout(CMECF.MainMenu.imageHoverTimeout);	CMECF.MainMenu.imageHoverTimeout = window.setTimeout("document.images['"+image+"'].src = CMECF.MainMenu.onImgArray['"+image+"'].src", 300);	return true;};CMECF.MainMenu.imageOff = function (image) {	if(document.images[image].src != CMECF.MainMenu.onImgArray[image].src)		window.clearTimeout(CMECF.MainMenu.imageHoverTimeout);	else		document.images[image].src = CMECF.MainMenu.offImgArray[image].src;	return true;};CMECF.MainMenu.hotKeys = function (v, checkKeyCode) {	var code = v.keyCode;	if (code == 27) {		CMECF.MainMenu.hideSubmenus();		CMECF.MainMenu.TopMenu.clearActiveItem();		window.setTimeout(CMECF.MainMenu.focusOnFirstItem, 0);		return false;	}	else if (v.altKey && CMECF.MainMenu.hotkeys[code]) {		CMECF.MainMenu.focusOnMainMenuItem(CMECF.MainMenu.hotkeys[code]);		return false;	}	return true;};CMECF.MainMenu.focusOnFirstItem = function () {	var firstForm = document.forms[0];	if (firstForm) {		for (var elementIndex = 0; elementIndex < firstForm.elements.length; elementIndex++) {			var formElement = firstForm.elements[elementIndex];			if (formElement.type != 'hidden') {				formElement.focus();				return 1;			}		}	}	var content = document.getElementById('cmecfMainContent');	if (content) {		// Avoid Firefox error when focusing on something with autocomplete on or unset.		if (content.setAttribute) {			content.setAttribute('autocomplete', 'off');		}		if (content.focus) {			content.focus();		}	}};CMECF.MainMenu.renderMainMenu = function (top_object) {	// Hide the menu if this was inside a pop-up.	try {		if (self.opener && self.opener.CMECF) {			document.getElementById('cmecfLogo').style.display='none';			document.getElementById('helpImage').style.display='none';			document.getElementById('topmenu').style.display='none';			document.getElementById('cmecfMainContent').style.height='100%';			return false;		}	} catch(e) {}	top_object.render();	top_object.show();	CMECF.MainMenu.setMainContentSize();	CMECF.util.Event.addListener(window, "resize", CMECF.MainMenu.setMainContentSize);	CMECF.util.Event.addListener(document, "keydown", CMECF.MainMenu.hotKeys);	CMECF.MainMenu.preloadMenuImages();};CMECF.MainMenu.contentScrolled = function (v) {	CMECF.MainMenu.mainContentScroll.value = CMECF.MainMenu.mainContent.scrollTop;};  	   	   	 CMECF.MainMenu.setContentScroll = function (v) {	if (CMECF.MainMenu.mainContentScroll.value > 0) {		CMECF.MainMenu.mainContent.scrollTop = CMECF.MainMenu.mainContentScroll.value;	}	CMECF.util.Event.addListener(CMECF.MainMenu.mainContent, "scroll", CMECF.MainMenu.contentScrolled);};CMECF.MainMenu.setMainContentSize = function() {	if (!CMECF.MainMenu.mainContent) {		CMECF.MainMenu.mainContent = document.getElementById('cmecfMainContent');	}	if (CMECF.MainMenu.mainContent) {		var topmenu = document.getElementById('topmenu');		var windowHeight = CMECF.MainMenu.getWindowHeight();		var barHeight = topmenu.offsetHeight;		// One pixel fewer, just for good measure. Sometimes the browser will let you shift the page up and down otherwise.		CMECF.MainMenu.mainContent.style.height = (windowHeight - barHeight - 1);		CMECF.MainMenu.mainContentScroll = document.getElementById('cmecfMainContentScroll');		if (navigator.appVersion.indexOf("MSIE")==-1) {			CMECF.util.Event.addListener(window, "load", CMECF.MainMenu.setContentScroll);		}		else {			// IE will already run this function after loading.			CMECF.MainMenu.setContentScroll();		}	}	else {		window.setTimeout(CMECF.MainMenu.setMainContentSize, 10);	}};CMECF.MainMenu.getWindowHeight = function() {	if (typeof(window.innerWidth) == 'number') {		return window.innerHeight;	}	if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {		return document.documentElement.clientHeight;  // IE 6, compliant	}	if (document.body && (document.body.clientWidth || document.body.clientHeight)) {		return document.body.clientHeight; // IE 4	}	return 600;};// Help functionsCMECF.MainMenu.courtInformationPanel;CMECF.MainMenu.showCourtInformation = function() {	if (!CMECF.MainMenu.courtInformationPanel) {		CMECF.MainMenu.courtInformationPanel = new CMECF.widget.Panel("thiscourtinformation", {			width:"400px",			fixedcenter:true,			constraintoviewport:true,			close:true,			visible:false,			draggable:true		});		CMECF.MainMenu.courtInformationPanel.setHeader("Court Summary");		CMECF.MainMenu.courtInformationPanel.setBody(CMECF.MainMenu.courtInformation);		CMECF.MainMenu.courtInformationPanel.render(document.body);	}	CMECF.MainMenu.courtInformationPanel.show();};CMECF.MainMenu.helpPanel;CMECF.MainMenu.showHelpPage = function(alternateHelp) {	if (!CMECF.MainMenu.helpPanel) {		CMECF.MainMenu.helpPanel = new CMECF.widget.Panel("helpPage", {			width:"400px",			height:"400px",			fixedcenter:true,			constraintoviewport:true,			close:true,			visible:false,			draggable:true		});		CMECF.MainMenu.helpPanel.setHeader("Help");		CMECF.MainMenu.helpPanel.setBody("<h3>Getting help text.</h3>");		CMECF.MainMenu.helpPanel.render(document.body);		if (alternateHelp) {			document.cookie = "HELP=" + alternateHelp;		} else {			document.cookie = "HELP=" + document.location;		}		var number = Math.random();		CMECF.util.Connect.asyncRequest("GET", "chelp.pl?number=" + number, { success:CMECF.MainMenu.updateHelpPage });	}	CMECF.MainMenu.helpPanel.show();};CMECF.MainMenu.updateHelpPage = function(o) {	var response = o.responseText;	if (CMECF.MainMenu.helpPanel) {		CMECF.MainMenu.helpPanel.setBody(response);		CMECF.MainMenu.helpPanel.body.style.height = "365px";	}};CMECF.MainMenu.searchPanel;CMECF.MainMenu.searchPrompt = function() {	if (!CMECF.MainMenu.searchPanel) {		CMECF.MainMenu.searchPanel = new CMECF.widget.Panel("search", {			width:"400px",			context:['cmecfMainContent','tr','tr'],			constraintoviewport:true,			close:true,			visible:false,			draggable:true		});		CMECF.MainMenu.searchPanel.setHeader("Search Menus and Events");		CMECF.MainMenu.searchPanel.setBody(CMECF.MainMenu.searchPage);		CMECF.MainMenu.searchPanel.render(document.body);	}	CMECF.MainMenu.searchPanel.show();	window.setTimeout("document.getElementById('searchTerm').focus();",0);};
