			// ***************************************************************
			// class/library for the menu navigator.
			// ***************************************************************

			function UM_BrowserType()
			{
				if (document.all)
				{
					if (navigator.userAgent.indexOf("Opera") == -1)
						this.type = 1;		// ie6
					else
						this.type = 5;
				}
				else
					if (document.getElementById)
						this.type=2;		// ns6
					else 
						if (document.layers)
							this.type=3;
						else
							this.type = 4;	
			}

			//
			var menuItemHeight = 13;
			var menuItemWidth = 120;
			
			// The following variables are used to build a linear list of all the
			// menu elements, in order to provide a simple numbered id system that
			// provides each element with a unique id.
			//
			// Note that there is no assumed relationship between this id and the 
			// position in the menu tree!
			var menuItemListIndex = 0;
			var menuItemList = new Object;
			
			// The following variables are used to build a linear list of all the
			// menus, in order to provide a simple numbered id system that
			// provides each menu with a unique id.
			//
			// Note that there is no assumed relationship between this id and the 
			// position in the menu tree!
			var menuListIndex = 0;
			var menuList = new Object;
			
			// constructor for a menu item.  Set the fields of the menu item
			// and add it to the menu items linear list.
			function UM_MenuItem(name, page, submenu)
			{
				this.name=name;
				this.page=page;
				this.submenu=submenu;
				this.parentmenu = null;
				
				this.id = menuItemListIndex;
				menuItemList[menuItemListIndex++]=this;
			}
			
			// setparent  method for a menu item.
			// sets the parentmenu value for the item (and if it has one, a submenu)
			// to the specified parent menu
			function UM_MenuItem_SetParent(parent)
			{
				this.parentmenu = parent;
				if (this.submenu)
					this.submenu.parentmenu = parent;
			}
			
			UM_MenuItem.prototype.SetParent = UM_MenuItem_SetParent;

			// constructor for a menu.  Set the fields of the menu
			// and add it to the menus linear list.
			//
			//	Parameters:
			//		ItemList:	Array of UM_MenuItem: items to be part of this menu.
			//		root:		Boolean: true if this is a root-level menu.
			function UM_Menu(ItemList, root)
			{
				this.list=ItemList;
				this.size=ItemList.length;
				this.root = (root ? true : false);
				this.parentmenu = null;
				
				// for each item in the array, set the parent to be this menu.
				for (i = 0; i < ItemList.length; ++i)
					ItemList[i].SetParent(this);
				
				// set the id for this menu.
				this.id=menuListIndex;
				menuList[menuListIndex++]=this;
			}

			// build the top level menu and display it,  
			// building (but not displaying) all submenus.
			function UM_ShowTopMenu(menu)
			{
				var dquot = "\"";
				var menuid = "UMM_" + menu.id;
				var menuseq = menuid + "," + menu.id;
				
				document.writeln("<div class='UM_MenuBarOuter'>");
					document.writeln("<div class='UM_MenuBarBackground'>");
						document.writeln("&nbsp;");
					document.writeln("</div>");
					document.writeln("<div class='UM_MenuBarForeground'>");
				
						document.writeln("");
						document.writeln("<div class='UM_MenuBar' id=" + dquot + menuid + dquot + 
							" onmouseover=\"UMM_EnterMenu(" + menuseq + ")\"" +
							" onmouseout=\"UMM_LeaveMenu(" + menuseq + ")\">");

							for (var i=0; i < menu.size; ++i)
							{
								var idno = menu.list[i].id;
								var id = "UM_" + menu.list[i].id;
								var idseq = id + "," + idno;
								document.writeln("<div class='UM_MenuItem' id=" + dquot + id + dquot + 
									" style='float:left;'" +
									" onmouseover=\"UM_EnterItem(" + idseq + 
									")\" onmouseout=\"UM_LeaveItem(" + idseq + 
									")\" onmousedown=\"UM_ClickItem(" + idseq + 
									")\" onmouseup=\"UM_ActionItem(" + idseq + 
									")\">&nbsp;" + menu.list[i].name + "&nbsp;");
						
									// if the menu item has a submenu, then construct its display div
									// as a child of the current menu item.
									if (menu.list[i].submenu)
									{
										UM_ShowSubMenu(menu.list[i].submenu);
									}

								document.writeln("</div>");
							}
							// document.writeln("");
						document.writeln("</div>");
					// document.writeln("<p>&nbsp;</p>");
					
					document.writeln("</div>");
				document.writeln("</div>");
				//HACK: 
				document.writeln("<br>");
			}
						
			function UM_ShowSubMenu(menu)
			{
				var dquot = "\"";
				var menuid = "UMM_" + menu.id;
				var menuseq = menuid + "," + menu.id;

				document.writeln("");
				document.writeln("<div class='UM_Submenu' id='UMM_" + menu.id + "'" + 
					" onmouseover=\"UMM_EnterMenu(" + menuseq + ")\"" +
					" onmouseout=\"UMM_LeaveMenu(" + menuseq + ")\">");

				var i;
				for (i=0; i < menu.size; ++i)
				{
					var idno = menu.list[i].id;
					var id = "UM_" + menu.list[i].id;
					var idseq = id + "," + idno;
					document.writeln("");
					document.writeln("<div class='UM_MenuItem' id=" + dquot + id + dquot + 
						" onmouseover=\"UM_EnterItem(" + idseq + 
						")\" onmouseout=\"UM_LeaveItem(" + idseq + 
						")\" onmousedown=\"UM_ClickItem(" + idseq + 
						")\" onmouseup=\"UM_ActionItem(" + idseq + 
						")\">&nbsp;" + menu.list[i].name + "&nbsp;</div>");
				}
				document.writeln("");
				document.writeln("</div>\n");
				
				eval("UMM_" + menu.id).className = "UM_Submenu";
			}				
			
			// ***************************************************************
			// event variables to hold state of menu system.
			// ***************************************************************
			var CurrentMenu = null;
			var CurrentMenuId = 0;
			var bInactive = false;
			var bNavigationTriggered = false;
			var timetagInactivate = null
			var Activation = null;
			var ActivationParent = null;

			// ***************************************************************
			// functions to activate or inactivate submenus.
			// ***************************************************************
			function Inactivate(bForce)
			{
				if ((bForce || bInactive) && CurrentMenu)
				{
					var cm;
					for(cm = menuList[CurrentMenuId]; cm.parentmenu != null; cm = cm.parentmenu)
						eval("UMM_" + cm.id).className="UM_Submenu";

					bInactive = false;
					CurrentMenu = null;
					CurrentMenuId = 0;
					Activation=null;
					ActivationParent=null;
				}
			}
			

			// ***************************************************************
			// event functions for a menu item.
			// ***************************************************************
			// a menu item has been hovered.
			//		change its class to the selected class.
			//		then if it has a sub-menu, display the sub-menu.
			function UM_EnterItem(menuItem, id)
			{
				// Immediately inactivate anything active.
				// THIS IS A BUG WHEN THERE ARE SUBMENUS!
				Inactivate(true);
				bInactive = false;
				
				menuItem.className="UM_MenuItemSelected";
				
				if (menuItemList[id].submenu)
				{
					var itemId=menuItemList[id].submenu.id;
					var submenu = eval("UMM_" + itemId);

					// make the selected submenu the active menu;
					bInactive = false;
					CurrentMenu = submenu;
					CurrentMenuId = itemId;
					
					// display the selected submenu and position it properly.
					if (submenu)
					{
						// submenu.style.pixelLeft = menuItem.style.pixelLeft;
						// submenu.style.pixelTop = menuItem.style.pixelTop + 14;
						submenu.className = "UM_SubmenuActive"
					}	
				}
				
				return true;
			}

			// a menu item has been moved away from.
			//		change its class back to the de-selected class.
			//      (if a navigation has been triggered, do NOT change 
			//		the class, as all necessary action will be taken by
			//		the page transition)
			function UM_LeaveItem(menuItem, id)
			{
				if (! bNavigationTriggered)
					menuItem.className="UM_MenuItem";
					
				return true;
			}
			
			function UM_ClickItem(x, id)
			{
				return true;
			}
			
			
			function UM_ActionItem(x, id)
			{
				if (! bNavigationTriggered)
				{
					bNavigationTriggered = true;
					window.navigate(menuItemList[id].page);
					// document.location.replace(menuItemList[id].page);
				}
				return true;
			}

			// ***************************************************************
			// event functions for a menu.
			// ***************************************************************
			
			function UMM_EnterMenu(x, id)
			{
				bInactive=false;
			}
			
			function UMM_LeaveMenu(x, id)
			{
				if (! bNavigationTriggered)
				{
					bInactive = true;
					// Don't inactivate immediately, so that if the user re-enters
					// the menu fast enough, the menu will not disappear.
					setTimeout("Inactivate(false)", 300);
				}
			}

			// ***************************************************************
			// End of the class library
			// ***************************************************************
