/* * * This file contains all necessary scripts for the intranet and is included in the master template. * All functions in this script are available to all intranet pages.  * * @author Erick Ovando * */ /* BEGIN HEADER FUNCTIONS *//* Begin Window Shade */var menuSize = document.all?220:220; // Height or Width of menuvar menuWidth = 945; // Width of Menu (Top only)var headerHeight = 2; //  Represents the bottom of the header -- the menu will need to slide downward from here (only valid for top menus)var slideSpeed = document.all?20:50; // Higher = quicker slidevar slideTimer = 2; // Lower = quicker slidevar menuPosition = "top"; // "top" OR "left"var scrollOffset = false;  // Changes the menu origin as the page scrollsvar menuStartPos = false; //headerHeight-menuSize;var wsMenu=false;var slideInProgress = false;	var startScrollPos = false; // Determines where then menu scroll startsvar menuPos = false; // Menu Positioning/* Menu Initialization */function initializeSlideMenu(openClose){	// Determine if the window has been scrolled, and reset the menu origin	scrollOffset = document.documentElement?document.documentElement.scrollTop:window.pageYOffset;	menuStartPos = headerHeight-menuSize-scrollOffset;		if(slideInProgress){		return;	}		if(!wsMenu) {		wsMenu = document.getElementById('wsMenuDIV');		if(menuPosition == "top") {			wsMenu.style.width = menuWidth + 'px';			wsMenu.style.top = menuStartPos + "px"; 			wsMenu.style.left = '0px';				wsMenu.style.height = menuSize + 'px';					} else { 			wsMenu.style.left = "-" + menuSize + 'px';			wsMenu.style.top = '0px';			wsMenu.style.width = menuSize + 'px';		}	}		if(menuPosition == "top") {		// Use the set width of the page/menu		wsMenu.style.width = menuWidth + 'px';		// Convert the top into a number		menuPos = wsMenu.style.top.replace(/[^0-9\-]/g,'')/1;				} else {		// Use the entire height of the window		wsMenu.style.height = document.documentElement?document.documentElement.clientHeight + 'px':document.body.clientHeight + 'px';		// Convert the left into a number		menuPos = wsMenu.style.left.replace(/[^0-9\-]/g,'')/1;	}		// Make the menu visible	wsMenu.style.display='block';	// And set the scroll origin	if(menuPosition == "top") {		startScrollPos = document.documentElement?document.documentElement.scrollTop+headerHeight-scrollOffset:document.body.scrollTop+headerHeight-scrollOffset;	} else {		startScrollPos = document.documentElement?document.documentElement.scrollLeft:document.body.scrollLeft;	}		// Next, determine which behavior to use: a specific Open, a specific Close, or a Toggle of the current state	if (openClose=="open"){		if(menuPos<(0+startScrollPos)) {			// Then the menu is closed; open it			slideMenu(slideSpeed);			} else {			// It's not supposed to close; leave it open				return;		}	} 		if (openClose=="close"){		if(menuPos<(0+startScrollPos)) {			// Then it's already closed; leave it closed			return;		} else {			// Close it and turn off the menu highlight			slideMenu(slideSpeed*-1);			rolloverClassChange("null");		}	} 		if (openClose=="toggle"){		if(menuPos<(0+startScrollPos)) {			// Open it			slideMenu(slideSpeed);			} else {			// Close it			slideMenu(slideSpeed*-1);			rolloverClassChange("null");		}		}		window.onresize = resizeMenu;}/* Slide Function */function slideMenu(slideSpeed) {		menuPos = "";	slideInProgress =true;		if(menuPosition == "top") {		menuPos = wsMenu.style.top.replace(/[^0-9\-]/g,'')/1;	} else {		menuPos = wsMenu.style.left.replace(/[^0-9\-]/g,'')/1;	}			menuPos+=slideSpeed;	okToSlide = true;		if(slideSpeed<0) {		if(menuPos < ((menuSize*-1) + startScrollPos)) {			menuPos = (menuSize*-1) + startScrollPos;				okToSlide=false;		}	}		if(slideSpeed>0) {		if(menuPos > (0 + startScrollPos)) {			menuPos = 0 + startScrollPos;			okToSlide = false;		}				}		if(menuPosition == "top") {		wsMenu.style.top = menuPos + 'px';	} else {		wsMenu.style.left = menuPos + startScrollPos + 'px';	}		if(okToSlide) {		setTimeout('slideMenu(' + slideSpeed + ')',slideTimer); 	} else {		slideInProgress = false;	}	}/* Menu Resizing (For Window Resize) */function resizeMenu() {	if(menuPosition == "top") {			wsMenu.style.width = menuWidth + 'px';	} else {		if(document.documentElement.clientHeight) {			wsMenu.style.height = document.documentElement.clientHeight + 'px';		} else if(document.body.clientHeight) {			wsMenu.style.height = document.body.clientHeight + 'px';		}			}}/* Keyboard Trigger for Menu */function keyboardShowMenu() {		initializeSlideMenu("toggle");	return false;	}/* Key Trap for Keyboard Trigger */function menuKeyboardEvent(e) {		if(document.all) {		return;	}		if(e.keyCode==112) {		initializeSlideMenu("toggle");		return false;	}			}	if(!document.all) {	document.documentElement.onkeypress = menuKeyboardEvent;} else {	document.documentElement.onhelp  = keyboardShowMenu;}/* Mouse Event Monitor for Menu */function checkForMouseOut(e) {		try {		// Make sure the event has been captured		if (!e) {			var e = window.event;		}		// Figure out which element the user started in		var startPoint = (window.event) ? e.srcElement : e.target;		// Next, figure out which element the user ended in		var endPoint = (e.relatedTarget) ? e.relatedTarget : e.toElement;				// Now, iterate to determine if the main DIV is somewhere in the 		// ending node's hierarchy and decide if it's time to declare the mouseout		while (endPoint.id !== "wsMenuDIV" && endPoint.id !=="main_nav"){			if (endPoint.nodeName && endPoint.nodeName!=="BODY"){				// You're still somewhere in the hierarchy and we need to move up				endPoint = endPoint.parentNode;			}	else {				// You are outside the main DIV, so the script will fire.				initializeSlideMenu("close");				break;			}				}	}			catch (err){		// The user has probably scrolled off the menu or page in a way that		// defeats the mouseout -- such as off the top or onto a new window --		// so close the menu anyway.		initializeSlideMenu("close");	}	}/* Menu Highlighting */function rolloverClassChange(element) {// This script eliminates the flicker in IE when a user mouses between menu items in the shade	// This is an array of all menus in the shade (by ID)var menuItem= new Array();	menuItem[0] = "about_er";menuItem[1] = "government";menuItem[2] = "departments";menuItem[3] = "community_news";menuItem[4] = "community_centers";menuItem[5] = "other_links";	// Turn the hover state off for all menus except the calling menu	for (var i=0; i<menuItem.length; i++){		if (menuItem[i] == element){			document.getElementById(menuItem[i]).className="menu_list_hover";		} else {			document.getElementById(menuItem[i]).className="menu_list";		}	}}/* End Window Shade *//* END HEADER FUNCTIONS */