/* ***************************************************************************** * MenuScripts.js * Client-side JavaScript for DHTML Menu System - Script File * * Description: This file contains the core functions for the DHTML menus.  It *   is not intended to be editable by the average user.  See MenuContent.js *   for regular site updates. * * Version: 2.2 * Date: 4.14.2003 * Author: Steve Kratowicz *  * ****************************************************************************//* ***************************************************************************** * Browser Detect * ****************************************************************************/var blnDOM = (document.getElementById) ? true : false;var blnIE = (document.all) ? true : false;var blnNS6 = (navigator.vendor == 'Netscape7' || navigator.vendor == 'Netscape6' || navigator.product == 'Gecko')? true : false;if (window.parent)	var blnNS4 = (parent.document.layers) ? true : false;/* ***************************************************************************** * Global Variables * ****************************************************************************/// Document load booleanvar blnLoaded = false;// Top-level Menu Container Object Arrayvar aryTopMenuContainers = new Array();// Currently Selected Menu Objectsvar objTopMenuOn = null;var objTopItemOn = null;var objLowerMenuOn = null;var objLowerItemOn = null;// Item Count at top levelvar intMenuCount;// Timer IDvar intTimerID = 0;/* ***************************************************************************** * Event Handlers * ****************************************************************************/// Call to onload and onresize initializationwindow.onload = function(){ setTimeout('init()', 10) };// Call to NS4 resize bug fixif (blnNS4) window.onresize = reDraw;/* ***************************************************************************** * MenuContainer Class - Outer Container for Individual Menu Items * ****************************************************************************/function MenuContainer (	intID,	intLeft,	intTop,	intWidth,	intHeight,	intItemCount,	strBorderColor){	var objTopContainer = (blnNS4) ? window : document.body;	this.ID = intID;	this.Top = intTop;	this.Left = intLeft;	this.Layer = createLayer(		objTopContainer,		'container_' + intID,		-800,		intTop,		intWidth,		intHeight,		0,		0,		true);	setBackgroundColor(this.Layer, strBorderColor);	this.Layer.onmouseover = stopTimer;	this.Layer.onmouseout = MenuOut;}/* ***************************************************************************** * MenuItem Class - Individual Items in a Menu * ****************************************************************************/function MenuItem (intParentID, intID, blnTopLevel, blnFirstItem){	// Get the Template Menu Object	var objMenu = blnTopLevel ? TopMenu : LowerMenu;	// Set High-level Properties	this.ID = 'Item' + intParentID + '_' + intID;	this.IsTop = blnTopLevel;	this.IsFirst = blnFirstItem;	// Set Properties from Template Object	for (var strKey in objMenu)		this[strKey] = objMenu[strKey];		// Define additional Properties	this.Container = null;	this.ChildContainer = null;	this.Link = null;	this.URL = '';	this.Text = '';	this.StringOff = '';	this.StringOn = '';	this.Left = 0;	this.Top = 0;	this.Width = 0;	this.Height = 0;}MenuItem.prototype.CreateLayer = function(){	if ((blnDOM || blnIE) && !this.IsFirst) {		if (this.IsHorizontal)			this.Width += this.SeparatorWidth;		else			this.Height += this.SeparatorWidth;	}	this.Layer = createLayer(		this.Container.Layer,		'item_' + this.ID,		this.Left,		this.Top,		this.Width,		this.Height,		true);	if (blnDOM || blnIE) {		this.Layer.style.cursor = (blnNS6) ? 'pointer' : 'hand';		if (!this.IsFirst){			if (this.IsHorizontal)				this.Layer.style.borderLeft = this.SeparatorWidth + 'px solid ' + this.BorderColor;			else				this.Layer.style.borderTop = this.SeparatorWidth + 'px solid ' + this.BorderColor;		}	}	setBackgroundColor (this.Layer, this.BgColor)	this.Layer.Item = this;		this.Layer.onmouseover = itemOn;	this.Layer.onclick = itemClick;}MenuItem.prototype.Fill = function(){	if (blnDOM){		var objAnchor = document.createElement("a");		with(objAnchor) {			href = this.URL;			with(style) {				font = this.FontWeight + ' ' + this.FontSize + 'px ' + this.FontFamily;				color = this.FontColor;				textDecoration = this.TextDecoration;			}			innerHTML = this.Text;		}		this.Layer.appendChild(objAnchor);		this.Link = objAnchor;	}	else {		this.MakeContentString();		insertContent(this.Layer, this.StringOff);	}		with ((blnNS4) ? this.Layer : this.Layer.style) {		color = this.FontColor;		paddingLeft = this.PaddingLeft;		paddingTop = this.PaddingTop;		paddingBottom = 20;	}}/* ***************************************************************************** * Menu Content String Functions * ****************************************************************************/MenuItem.prototype.MakeContentString = function (){	var strTemp;		strTemp =		'<a href="' + this.URL +		'" class="' + this.LinkCssClass +		'">' + this.Text + '</a>';	this.StringOff = strTemp;	strTemp =		'<a href="' + this.URL +		'" class="' + this.LinkCssClassOn +		'">' + this.Text + '</a>';	this.StringOn = strTemp;}Object.prototype.debug = function(){	var strTemp = '';	for (var strKey in this) {			strTemp += (strKey + ' : ' + this[strKey] + '<br>');	}	var objLayer = document.createElement("div");			with(objLayer)		{			id = 'test';			with(style)			{				position = 'absolute';				visibility = 'visible';				left = '100px';				top = '100px';				width = '800px';			}		}	document.body.appendChild(objLayer);	objLayer.innerHTML = strTemp;}/* ***************************************************************************** * Initialization Function * ****************************************************************************/function init(){	// Find Number of Top-level Menus in the Menu Arrays	for (var i=1; i<10; i++)		if (validateObject('aryMenu' + i)) intMenuCount = i;	// Build the Menus	setTimeout('buildMenus(1)', 10);}/* ***************************************************************************** * BuildMenus - Called from Init function to build Menu Objects and Layers * ****************************************************************************/function buildMenus(i){	// Local Vars	var objLowerMenuContainer;	var objLowerMenuItem;	var aryLowerItems;	var strItemOff;	var strItemOn;	var intItemCount;	// Find the current Menu Array	var aryTop = eval('aryMenu' + i); 		// Top Menu Positioning	var intTopMenuLeft = aryTop[0][0];	var intTopMenuTop = aryTop[0][1];		// Menu Sizing	var intTopItemWidth = (aryTop[0][2]) ? aryTop[0][2] : TopMenu.DefaultWidth;	var intTopItemHeight = (aryTop[0][3]) ? aryTop[0][3] : TopMenu.DefaultHeight;	var intLowerItemWidth = LowerMenu.DefaultWidth;	var intLowerItemHeight = LowerMenu.DefaultHeight;	// Set aryTopItems to be Lower-dimension of Content Array	var aryTopItems = aryTop[1];		// Get the Width and height of the Top-level Container	var intItemsTotalWidth = intTopItemWidth;	intItemsTotalWidth += 2 * TopMenu.BorderWidth;		var intItemsTotalHeight = 0;	for (var j=0; j<aryTopItems.length; j++)		intItemsTotalHeight += (aryTopItems[j][2]) ? aryTopItems[j][2] : intTopItemHeight;	intItemsTotalHeight += (aryTopItems.length -1) * TopMenu.SeparatorWidth;	intItemsTotalHeight += 2 * TopMenu.BorderWidth;	// Create Top-level Container Menus	aryTopMenuContainers[i] = new MenuContainer(		i,		intTopMenuLeft,		intTopMenuTop,		intItemsTotalWidth,		intItemsTotalHeight,		aryTopItems.length,		TopMenu.BorderColor	);	// Set the Starting Current Top Item X and Y Position	var intTopItemCurrentX = TopMenu.BorderWidth;	var intTopItemCurrentY = TopMenu.BorderWidth;		// Iterate through items in Top-level Menu	for (var j=0; j<aryTopItems.length; j++) {				// Instantiate the MenuItem Class (Top-level)		var objTopMenuItem = new MenuItem(i, j, true, (j==0));				// Set Properties to Top-level MenuItem Object		with (objTopMenuItem) {			Left = intTopItemCurrentX;			Top = intTopItemCurrentY;			Width = intTopItemWidth;			Height = intTopItemHeight;			Text = aryTopItems[j][0];			URL = aryTopItems[j][1];			Container = aryTopMenuContainers[i];		}		// Create the Top-level MenuItem's Layer		objTopMenuItem.CreateLayer();			// Insert Content into Item		objTopMenuItem.Fill();				// If Lower-level Menu Exists for this Item		if (validateObject('aryMenu' + i + '_' + (j+1))) {					// Find Menu Top and Left			intLowerMenuLeft = intTopMenuLeft + intItemsTotalWidth - TopMenu.BorderWidth;			intLowerMenuTop = intTopMenuTop + intTopItemCurrentY - ((j==0) ? TopMenu.BorderWidth : TopMenu.SeparatorWidth);			// Set aryLowerItems to point to Lower level array			aryLowerItems = eval('aryMenu' + i + '_' + (j+1));				// Get the width and Height of the Lower-level Container			intItemsTotalWidth = intLowerItemWidth;			intItemsTotalWidth += 2 * LowerMenu.BorderWidth;			intItemsTotalHeight = 0;			for (var k=0; k<aryLowerItems.length; k++)				intItemsTotalHeight += intLowerItemHeight;			intItemsTotalHeight += (aryLowerItems.length -1) * LowerMenu.SeparatorWidth;			intItemsTotalHeight += 2 * LowerMenu.BorderWidth;			// Create the MenuContainer			objLowerMenuContainer = new MenuContainer (				i + '_' + j,				intLowerMenuLeft,				intLowerMenuTop,				intItemsTotalWidth,				intItemsTotalHeight,				aryLowerItems.length,				LowerMenu.BorderColor);					// Set the Starting Current Lower Item X and Y Position			intLowerItemCurrentX = LowerMenu.BorderWidth;			intLowerItemCurrentY = LowerMenu.BorderWidth;			for (var k=0; k<aryLowerItems.length; k++) {							// Instantiate the MenuItem Class (Lower-level)				objLowerMenuItem = new MenuItem(i + '_' + j, k, false, (k==0));								// Set Properties to Top-level MenuItem Object				with (objLowerMenuItem) {					Left = intLowerItemCurrentX;					Top = intLowerItemCurrentY;					Width = intLowerItemWidth;					Height = intLowerItemHeight;					Text = aryLowerItems[k][0];					URL = aryLowerItems[k][1];					Container = objLowerMenuContainer;				}						// Create the Top-level MenuItem's Layer				objLowerMenuItem.CreateLayer();							// Insert Content into Item				objLowerMenuItem.Fill();						// Increase Current Lower Item Y Position				intLowerItemCurrentY += intLowerItemHeight + ((blnNS4 || k>0) ? LowerMenu.SeparatorWidth : 0);						}// End k Loop						// After Items are created, hide layer and move onto screen			showOrHide (objLowerMenuContainer.Layer, 'hidden');			positionLayer(objLowerMenuContainer.Layer, objLowerMenuContainer.Left, objLowerMenuContainer.Top);						// Set the ChildContainer for the Item that References this Menu			objTopMenuItem.ChildContainer = objLowerMenuContainer;		}//End if (Lower Level Exists)		// Increase Current Top Item Y Position		intTopItemCurrentY += (aryTopItems[j][2]) ? aryTopItems[j][2] : intTopItemHeight;		if (blnNS4 || j>0)			intTopItemCurrentY += TopMenu.SeparatorWidth;	}//End j Loop		// After Items are created, hide layer and move onto screen	showOrHide (aryTopMenuContainers[i].Layer, 'hidden');	positionLayer(aryTopMenuContainers[i].Layer, aryTopMenuContainers[i].Left, aryTopMenuContainers[i].Top);	// Iterate i	i++;	// Repeat as directed	if (i <= intMenuCount)		setTimeout('buildMenus(' + i + ');', 5);	// If finished, set blnLoaded true and display	else {		blnLoaded = true;	}}/* ***************************************************************************** * Show/Hide and Timer Functions * ****************************************************************************/// MenuOver() function - Sets visibility on for a Menu layer and registers it// as the currently selected menu.function MenuOver (intMenuID){	if (!blnLoaded) return;	HideMenu();	objTopMenuOn = aryTopMenuContainers[intMenuID];	showOrHide (objTopMenuOn.Layer, 'visible');}// MenuOut() function - begins timer to hide menufunction MenuOut () {	intTimerID = setTimeout('HideMenu();', 500);}// HideMenu() function - Sets visibility off for the currently selected menu.function HideMenu (){	if (objTopMenuOn != null) {		showOrHide(objTopMenuOn.Layer, 'hidden');		objMenuTopOn = null;		//onHide();	}	if (objTopItemOn != null) {		setBackgroundColor(objTopItemOn.Layer, objTopItemOn.BgColor);		if (objTopItemOn.Link)			objTopItemOn.Link.style.color = objTopItemOn.FontColor;		else if (blnNS4)			insertContent(objTopItemOn.Layer, objTopItemOn.StringOff);					objTopItemOn = null;	}	if (objLowerMenuOn != null) {		showOrHide(objLowerMenuOn.Layer, 'hidden');		objLowerMenuOn = null;	}	stopTimer();}// stopTimer() function - stops timer for menu hidefunction stopTimer () {	if (intTimerID) { clearTimeout(intTimerID); clearTimeout(intTimerID - 1); }}// Called by Mouseover of a Menu Itemfunction itemOn(){	var objItem;	if (blnDOM && this.tagName != 'DIV')		return;	objItem = this.Item;	setBackgroundColor(this, objItem.BgColorOn);		// If it is a Top-level Menu Item	if (objItem.IsTop) {		// If a Top Menu Item is On		if (objTopItemOn != null)		setItemState(objTopItemOn, false);				// Set new Top Menu Item On		objTopItemOn = objItem;		setItemState(objTopItemOn, true);				// If a Lower-level Menu Container is On		if (objLowerMenuOn != null) {			showOrHide(objLowerMenuOn.Layer, 'hidden');			objLowerMenuOn = null;		}				// If a Lower-level Menu Item is On		if (objLowerItemOn != null) {			setItemState(objLowerItemOn, false);			objLowerItemOn = null;		}				// If a ChildContainer exists, turn it on		if (objItem.ChildContainer != null) {			objLowerMenuOn = this.Item.ChildContainer;			showOrHide(objLowerMenuOn.Layer, 'visible');		}	}	// If it is a Lower-level Menu Item	else {			// If a Lower Menu Item is On		if (objLowerItemOn != null)			setItemState(objLowerItemOn, false);		// Set new Lower Menu Item On		objLowerItemOn = objItem;		setItemState(objLowerItemOn, true);	}}function setItemState(objItem, blnOn){	var strItemString = (blnOn) ? objItem.StringOn : objItem.StringOff;	var strBgColor = (blnOn) ? objItem.BgColorOn : objItem.BgColor;		if (objItem.Link)		objItem.Link.style.color = (blnOn) ? objItem.FontColorOn : objItem.FontColor;	else if (blnNS4)		insertContent(objItem.Layer, strItemString);	setBackgroundColor(objItem.Layer, strBgColor);}function itemClick(){	if (blnDOM && this.tagName != 'DIV')		return;	location = this.Item.URL;	return false;} /* ***************************************************************************** * DHTML Utility Functions * ****************************************************************************/// showOrHide() - sets visibility on or off for a layer objectfunction showOrHide (obj,vis){	if (blnIE || blnDOM) obj.style.visibility = vis;	else if (blnNS4) obj.visibility = ((vis == "visible") ? "show" : "hide");}// setBackgroundColor - set the background color of a layerfunction setBackgroundColor (objLayer, strColor){	if (blnNS4) objLayer.bgColor = strColor;	else objLayer.style.backgroundColor = strColor;}// positionLayer - move layer to a given X, Y positionfunction positionLayer (objLayer, xPos, yPos) {	if (blnDOM||blnIE) {		objLayer.style.left = xPos + "px";		objLayer.style.top = yPos + "px";	}	else		objLayer.moveTo(xPos, yPos);}// insertContent() - puts content into an existing HTML DIV/Layerfunction insertContent(objLayer, strContent){	if (blnIE || blnDOM) objLayer.innerHTML = strContent;	else if (blnNS4)	{		objLayer.document.write(strContent);		objLayer.document.close();	}}/* ***************************************************************************** * createLayer - The primary Layer Creation function * ****************************************************************************/function createLayer (	objContainer,	strId,	intLeft,	intTop,	intWidth,	intHeight,	blnVis){	var objLayer = null;	var strVis;	if (blnNS4)		strVis = (blnVis) ? 'inherit' : 'hide';	else		strVis = (blnVis) ? 'inherit' : 'hidden';	var strClip = '0px '		+ intWidth + 'px '		+ intHeight + 'px '		+ '0px';	if (blnDOM)	{		objLayer = document.createElement("div");		with(objLayer)		{			id = strId;			with(style)			{				position = 'absolute';				visibility = strVis;				left = intLeft + 'px';				top = intTop + 'px';				width = intWidth + 'px';				height = intHeight + 'px';				if (intHeight != 'auto' && intWidth != 'auto')					clip = 'rect(' + strClip + ')';			}		}		objContainer.appendChild(objLayer);	}		else if (blnIE)	{		var strHTML = '<div id="' + strID			+ '" style="position:absolute; visibility:' + strVis + ';"></div>';		objContainer.insertAdjacentHTML('BeforeEnd', strHTML);		objLayer = document.all[strId];		with(objLayer.style)		{			left = intLeft + 'px';			top = intTop + 'px';			width = intWidth + 'px';			if (intHeight != 'auto' && intWidth != 'auto')				clip = 'rect(' + strClip + ')';		}	}		else if (blnNS4)	{		objLayer = new Layer (intWidth, objContainer);		with(objLayer)		{			name = strId;			visibility = strVis;			top = intTop;			left = intLeft;			width = intWidth;			if (intWidth != 'auto')				clip.width = intWidth;			if (intHeight != 'auto')				clip.height = intHeight;		}	}		return objLayer;}/* ***************************************************************************** * Core JavaScript Utilities * ****************************************************************************/// validateObject - checks to ensure that a variable name represents an objectfunction validateObject(strName){	return (typeof eval("window." + strName) == "object");}/* ***************************************************************************** * Browser-specific bug fixes * ****************************************************************************/// Netscape 4 Resize Fixif (blnNS4){      	origWidth = innerWidth;	origHeight = innerHeight;   	}function reDraw(){	if (innerWidth != origWidth || innerHeight != origHeight) location.reload();}