function handleMouseOver(obj,showMenu,subMenu){
	try{
		if(subMenu){
			Menu.highlight(obj)
		}
		else {
			obj.className='barOver'
			if(showMenu){
				Menu.showMenu(obj)
			}
			else {
				Menu.hideMenuAll()
			}
			window.status=obj.innerHTML
		}			
		return true
	}
	catch(e) {
		return menuErrorTrap(e)
	}		
}
	
function handleMouseOut(obj,subMenu){
	try{
		if(subMenu){
			obj.className='menuItem'
		}
		else {
			obj.className='bar'
		}
		window.status=''
		return true
	}
	catch(e) {
		return menuErrorTrap(e)
	}
	Menu.hideMenuAll()		
}

function closeMenu(){
	try{
		Menu.hideMenuAll()
		return true
	}
	catch(e) {
		return menuErrorTrap(e)
	}
}

function menuErrorTrap(e){
	return (e.message.indexOf('Menu')==-1)  //Ignore errors raised by reference to uninitialized Menu
}

function CascadeMenu(topMenubarId,menuMapping){
	var rootMenu=document.getElementById(topMenubarId)
	var menuMapping=menuMapping

	var ua = navigator.userAgent.toLowerCase()
	var ie6 = (ua.indexOf("msie") >= 0 && ua.indexOf("msie 7") == -1)

	//Displays the top level menu
	this.showMenu = function showMenu(obj){
		var menuName=getMenuName(obj)
		var menuId=obj.id
		
		this.hideMenuAll()

		var menu = document.getElementById(menuName)
		var bar = document.getElementById(menuId)
		menu.style.visibility = 'visible'

		var x, y
		var element
		
		y = obj.offsetHeight
		x = 0
		element = obj
		while(element != null) {
			y += element.offsetTop
			x += element.offsetLeft
			element = element.offsetParent
		}
		menu.style.top = (y - 1) + "px"
		menu.style.left = (x - 34) + "px"

		hideCoveredCombos(menu)
	}

	//Changes color of menu item on hover and shows sub-menus (if applicable)
	this.highlight = function highlight(obj){
	
		//Determines Status Text
		function menuStatusText(inner){
			var innerString = new String(inner)
			innerString=innerString.split("<SPAN")[0].replace("&amp;","&")
			return innerString.replace("&radic;","")
		}

//		var parent = document.getElementById(obj.parentNode.id)
//		if(parent.hasChildNodes() == true){  
//			var elements = parent.children
//			if(elements != null) {
//				for(var i=0;i<elements.length;i++){
//					var child = eval(elements[i].id)
//					child.className = "menuItem"
//				}
//			}
//		}
		obj.className="ItemMouseOver"
		window.status = menuStatusText(obj.innerHTML)
		this.showSubMenu(obj)
	}

	//Hides a menu item and its child menu items
	this.hideMenu = function hideMenu(obj){
		if(obj.hasChildNodes()==true){ 
			var child = obj.childNodes
                 
			for(var j =0;j<child.length;j++){
				var menuname=getMenuName(child[j])
				var childMenu = document.getElementById(menuname)

				if(childMenu){
				    if(childMenu.hasChildNodes()==true){
						this.hideMenu(childMenu)
					}
	   				childMenu.style.visibility = 'hidden'
				}
			}
  		}
  		unhideCoveredCombos()
	}

	//Displays sub-menus
	this.showSubMenu = function showSubMenu(obj){
		parentMenu = document.getElementById(obj.parentNode.id)
		this.hideMenu(parentMenu)
		var menuName=getMenuName(obj)
		if(menuName!=undefined){
			menuName=obj.name
		}
		if(menuName != null && menuName!=undefined){
			var menu = eval(menuName)
			menu.style.pixelTop =  obj.offsetTop + document.body.scrollTop
			menu.style.pixelLeft = obj.offsetLeft-202 + document.body.scrollLeft
			menu.style.visibility = "visible"
		}
		hideCoveredCombos(parentMenu,true)
	}

	//Hides entire menu
	this.hideMenuAll = function hideMenuAll(){
		var child=rootMenu.childNodes
		
		for(var i=0;i<child.length;i++){
			var menuname=getMenuName(child[i])
			if(!(menuname==undefined)){
				var menu=document.getElementById(menuname)
				menu.style.visibility='hidden'
			}
		}
		unhideCoveredCombos()
	}
	
	function getMenuName(obj){
		var menuId=obj.id

		for(var i=0;i<menuMapping.length;i++){
			if(menuMapping[i].menu==menuId){
				return menuMapping[i].subMenu;
			}	
		}
	}
	
	this.handleMouseOver=function handleMouseOver(obj,showMenu,subMenu){
		if(subMenu){
			this.highlight(obj)
		}
		else {
			obj.className='barOver'
			if(showMenu){
				this.showMenu(obj)
			}
			else {
				this.hideMenuAll()
			}
			window.status=obj.innerHTML
		}			
		return true
	}
	
	this.handleMouseOut=function handleMouseOut(obj,subMenu){
		if(subMenu){
			obj.className='menuItem'
		}
		else {
			obj.className='bar'
		}
		window.status=''
		return true
	}
	
	//Workaround for a bug in IE that makes
	//visible combos always be in front of menus
	function hideCoveredCombos(obj){
		if(!ie6)
			return;

		var rect1 = obj.getBoundingClientRect()	
		var allcombos=document.getElementsByTagName('select')

		for(var i=0;i<allcombos.length;i++){
			var rect2 = allcombos[i].getBoundingClientRect()
			
			if(rect1.left <= rect2.right && rect1.right >= rect2.left && rect1.top <= rect2.bottom && rect1.bottom >= rect2.top){
				allcombos[i].style.visibility = 'hidden'
			}
		}
	}

	function unhideCoveredCombos(){
		if(!ie6)
			return;

		var allcombos=document.getElementsByTagName('select')

		for(var i=0;i<allcombos.length;i++){
			if(!ancestorHidden(allcombos[i])){
				allcombos[i].style.visibility='visible'
			}
		}
	}
	
	function ancestorHidden(element){
		var parent=element.parentNode
		if(parent!=null){
			if(parent.style!=null){
				if(parent.style.visibility=='hidden'){
					return true
				}
				else {
					return ancestorHidden(parent)
				}
			}
			parent=parent.parentNode
		}
	}
}
