// cancel error notifications due to problems b4 page is loaded
//function stopError() {
//	return true;
//	}
//window.onerror = stopError;

// Global variables:
	
	var bOverMenu = 0; // boolean - on when mouse is over a menu
	var nGMenu // integer - the menu that the mouse is over
	var nGSubMenu // integer - the submenu that the mouse is over
	var bCancHSM = 0

	// This deterimines the number of menus on the web site,
	// and the number of sub-menus for each of the main menus.
	// The main menu # is zero-based, the rest are one-based.

	var nGTotalMenus = 6  // zero-based

	var nGMenu0Items = 2 // zero-based
	var nGMenu1Items = 4 //
	var nGMenu2Items = 6 //
	var nGMenu3Items = 1 //
	var nGMenu4Items = 3 //
	var nGMenu5Items = 2 //
	var nGMenu6Items = 1 //

	var nGMenu1_0Items = 1 // zero-based
	var nGMenu1_1Items = 1 //
	var nGMenu1_2Items = 1 //
	var nGMenu1_3Items = 1 //
	var nGMenu1_4Items = 1 //

	var nGMenu2_0Items = 3 //
	var nGMenu2_1Items = 0 //
	var nGMenu2_2Items = 0 //
	var nGMenu2_3Items = 0 //
	var nGMenu2_4Items = 1 //
	var nGMenu2_5Items = 4 //
	var nGMenu2_6Items = 4 //

	var nGMenu4_2Items = 1 //

	var nGMenu0Subs = 0 // one-based
	var nGMenu1Subs = 5 //
	var nGMenu2Subs = 7 //
	var nGMenu3Subs = 0 //
	var nGMenu4Subs = 1 //
	var nGMenu5Subs = 0 //
	var nGMenu6Subs = 0 //

function highlight(nMenu, nItem, nSub) {
	// function highlight()
	// purpose: Used only in Netscape, it changes the color of a menu item when moused over
	// Inputs:  nMenu - The main menu that the item to be highlighted is a part of.
	//			nItem - The item being highlighted
	//			nSub - If the item is in a submenu, this is the ID of it. May be null
	// outputs: none
	
	// affirm mouseover global flag
	bOverMenu = 1;
	// determine whether the item we're highlighting is in a submenu
	if (nSub == null) {
		// if there is no submenu:
		// unhighlight all other items in the menu
		unHighlight(nMenu);
		// set or reset the global current menu variable to the current menu
		nGMenu = nMenu
		// do the highlighting
		document.layers[nMenu].layers['pull' + nMenu + '_' + nItem + 'on'].visibility='show';
	} else {
		// is this is a submenu item:
		// unhighlight all other items in the submenu
		unHighlightSub(nMenu, nItem);
		// do the highlighting
		document.layers['subpull'+nMenu+'_'+nItem].layers['pull'+nMenu+'_'+nItem+'_'+nSub+'on'].visibility='visible';
	}
}

function unHighlight(nMenu) {
	// function unHighlight()
	// purpose: Netscape only: returns all items in a menu to its mouseout state.
	// Inputs:  nMenu - the ID of the menu that we're unhighlighting
	// outputs: none
	
	//make sure its netscape; IE would return an error because layers are not supported.
	if (ns4) {
		// setting up for a loop - this determines the number of sublayers (menuitems) in the menu
		var itemCt=document.layers[nMenu].layers.length - 1;
		var h // counter variable
		// loop start
		for (h=0; h<=itemCt; h=h+1) {
			// The netscape highlights are accomplished by appearing a new layer with the 
			// correct contents on top of the old layer, hiding it. All layers, whether old
			// or new, are sublayers of the main menu. The top layers contain the text 'on' 
			// in their names, so to avoid hiding the bottom layers, we only hide layers that
			// contain the text 'on' in them.
			if (document.layers[nMenu].layers[h].name.indexOf('on') != -1) {
				document.layers[nMenu].layers[h].visibility = "hide";
			}
		}
	} else if (ie4) {
		document.all["onDiv"+nMenu+'_0'].className='test';
		document.all["AonDiv"+nMenu+'_0'].className='menuanchor';
	}
		
}



function unHighlightSub(nMenu, nItem) {
	// function: unHighlightSub()
	// this function is nearly identical to unHighlight(), and comments about this can be
	// read there. 
	if (ns4) {
		var itemCt=document.layers['subpull'+nMenu+'_'+nItem].layers.length - 1;
		var h 
		for (h=0; h<=itemCt; h=h+1) {
			if (document.layers['subpull'+nMenu+'_'+nItem].layers[h].name.indexOf('on') != -1) {
				document.layers['subpull'+nMenu+'_'+nItem].layers[h].visibility = "hide";
			}
		}
	}
}

function hideMenu(c, csm) {

	// function:hideMenu()
	// purpose: hide a menu after an interval
	// inputs:	c - the menu being hidden
	//			csm - the submenu being hidden (may be null)
	// outputs:	none

	// set the current menu global variable to the menu being hidden
	nGMenu = c;
	// turn the mouse-over-a-menu flag off
	bOverMenu = 0;
	// call the function that actually does the hiding after an interval in milliseconds
	window.setTimeout("hideMenu2(nGMenu)", 10);
	// do the same for a submenu, if indicated	
	if (csm != null) {
		hideSubMenus(1)
		hideSubMenus(2)
		hideSubMenus(4)

	}
}

function hideMenu2(d) {

	// function:hideMenu2()
	// purpose: hide all menus
	// inputs:	d - a possible exception
	// outputs:	none
	if ( bOverMenu==1) return;

	var totalMenus // local variable, set to nGTotalMenus, for looping
	totalMenus = nGTotalMenus
 	var hm, uhl // counter variables
		// start the loop. We're actually hiding all the menus, in case one is hanging around
		for (hm=0; hm<=totalMenus; hm++){
			// hideMenu2 can be called by the main hidemenu function, or by the showmenu function.
			// its behavior varies based on the function that calls it. The way it knows which
			// function called it is by the bOVerMenu global. When off (called by hidemenu), it
			// wants to hide all the menus, regardless. When on, it hides all the menus except the
			// one indicated by d.
			if (!bOverMenu || hm != d) {
				// unhighlight all the items in the menu
				unHighlight(hm);
				// finally, we hide the menu itself, in three different ways for three browsers
				if (ns4) { document.layers[hm].visibility = "hide"; }
    			else if (ie4 &&	document.all["pull"+hm].style.visibility != "hidden") {
					// in IE, we also need to make sure all the menu items aren't highlighted
					var sLocItems
					// create a loop based on the global vars defined up top
					sLocItems = eval("nGMenu"+hm+"Items")
					for (uhl=0; uhl<=sLocItems; uhl++) {
						// unhighlight
						document.all["onDiv"+hm+'_'+uhl].className='test';
						document.all["AonDiv"+hm+'_'+uhl].className='menuanchor';
					}
					// hide the menu
					document.all["pull"+hm].style.visibility = "hidden"; 
				}
			}
		}
				// hide all its submenus (they're so pesky)
				bCancHSM = 0;
				hideSubMenus(d);

	}


function quickHide(SubMenu, SubSubMenu) {
	if(SubSubMenu == null) return
	if (ie4) document.all["pull"+SubMenu+"-"+SubSubMenu].style.visibility = "hidden";
	else if (ns4) document.layers['subpull'+SubMenu+'_'+SubSubMenu].visibility = "hidden";
}

function hideSubMenus(sd, smd) {
	// function:hideSubMenus()
	// purpose:	similar in funtion to hidemenu2() - comments can be read there.
	if (bCancHSM == 1) return(0)
	if (sd == 'undefined' || sd == null) return(0)
	bCancHSM = 1
	var nSubs
	nSubs = eval('nGMenu' + sd + 'Subs')
	if (nSubs) {
		var sdi, sdsi, locSMI
		for (sdi=0; sdi<nSubs; sdi++){
			if (!bOverMenu || sd!=nGMenu || sdi!=nGSubMenu) {
				if (ie4 && document.all["pull"+sd+"-"+sdi].style.visibility != "hidden") { 
					document.all["pull"+sd+"-"+sdi].style.visibility = "hidden";
					locSMI = eval("nGMenu"+sd+"_"+sdi+"Items")
					for(sdsi=0;sdsi<=locSMI;sdsi++) {
						document.all["onSDiv"+sd+'_'+sdi+'_'+sdsi].className='test';
						document.all["ASonDiv"+sd+'_'+sdi+'_'+sdsi].className='menuanchor';
					}
				}
				else if (ns4) document.layers['subpull'+sd+'_'+sdi].visibility = "hidden";
			}
		}	
	}
}

function showMenuTop(m) {
	hideSubMenus(m)
if (ie4){
/// UnHighlights all menu items
  for (hm=0; hm<=4; hm++){
   nItems = eval("nGMenu"+hm+"Items")
     for (i=0;i<=nItems;i++){
	document.all["onDiv"+hm+'_'+i].className='test';
	document.all["AonDiv"+hm+'_'+i].className='menuanchor';
     }
  }
 }
	showMenu(m)
}

function showMenu(m, sm){
	// function:showMenu()
	// purpose: displays a menu
	// inputs:	m - ID of the menu being displayed
	//			sm - ID of the submenu being displayed (may be null)
	// outputs: none
	bCancHSM = 0;
	if (nGMenu == m) {
		bCancHSM = 1;
	} else {
		hideSubMenus(nGMenu)
		nGMenu = m	// set the global menu var to the current menu
	}
	// this function can be used to display a menu or a submenu
	// if a submenu is not specified (null), it runs the code to display a main menu
	if (sm == null) {
		// hide all of the submenus first - I would do a loop looking for subs in all 6 main
		// menus, but to make it easier I'm just running the function on the two menus I know
		// have submenus.
			hideSubMenus(1)
			hideSubMenus(2)
			hideSubMenus(4)

//			nGSubMenu = null	// set the global submenu var to null
			// hide all menus except the one we want to display

			var iLoc
				for(iLoc=0;iLoc<=nGTotalMenus;iLoc++) {
					if(iLoc!=m){
						if (ns4) { document.layers[iLoc].visibility = "hide"; }
		    			else if (ie4) {document.all["pull"+iLoc].style.visibility = "hidden"; }
					}
				}

			
//			if (ns4) window.setTimeout("hideMenu2(nGMenu);", 10)
//			else if (ie4) hideMenu2(nGMenu);
			bOverMenu = 1 // we're over a menu, turn on the mouse over flag
		// turn the menu on
		if (ng5) document.getElementById('pull'+m).style.visibility = "visible"; 
		else if (ns4) document.layers["pull"+m].visibility = "show"; 
		else if (ie4) document.all["pull"+m].style.visibility = "visible";
	} else {
		// this is if we're displaying a submenu
		// reset all submenus by temporarily turning off mouseover variable and running hidesubmenus
		bCancHSM = 1
		if (nGSubMenu != sm) bCancHSM=0;
		nGSubMenu=sm
		bOverMenu=0
		bCancHSM=0


		window.setTimeout("hideSubMenus(nGMenu)", 10);
				
		bOverMenu = 1	// turn mouseover variable back on

		// turn on the submenu
		if (ns4) document.layers['subpull'+m+'_'+sm].visibility = "visible";
		else if (ie4) document.all["pull"+m+"-"+sm].style.visibility = "visible";
	}
}

