/*	**************************************************************************************
	The following are taken from www.quirksmode.org
	authored by Peter-Paul Koch
	************************************************************************************ */
	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
	
	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

///////////////////CascadedDropdown Menu/////////////////
 //Date : 08/09/2001               						//
 //Version : 1.0        								//
 //Author Mr.Arun N Kumar	                            //
 //EMail: n_arunk@hotmail.com							//		
 /////////////////////////////////////////////////////////
 // Modifications on this code is not recomended
 // Suggestions are welcome

 /* *************************************************************************************
	modified 7/24/2006 by Theodore Snider for cross-browser compatability
    ************************************************************************************ */
	var isIE = true;
	var isOp = false;
	
	function InitMenu() {
		// if no children, then html is not set up properly, so exit with an "error" condition
		if (!document.getElementById("menuBar").hasChildNodes) { return false; }
		
		// determine navigator vendor
		isIE = (navigator.appName.indexOf("Microsoft") != -1);
		isOp = (navigator.appName.indexOf("Opera") != -1);
		
		// begin by getting the first menu
		var bar = document.getElementById("menuBar").firstChild;
		
		while (bar != null) {
			if (bar.nodeType == 1)	{	// an element node; only want to process document element nodes
										// -Mozilla-based browswers seem to interperet in a strict XML fashion
										// 	and treat everything, even whitespace, as child nodes.  Grr.
				// adjust width of top elements for non-IE browsers
				if ((bar.className == "Bar") && !(isIE)) { bar.style.width = "130px"; }
				
				var menu = document.getElementById(bar.getAttribute("menu"));
				menu.style.visibility = "hidden";
				bar.onmouseover = new Function("ShowMenu(document.getElementById(\""+bar.getAttribute("id")+"\"))");
				var menuItem = menu.firstChild;
				
				while (menuItem != null) {
					if (menuItem.nodeType == 1) {	// again, only want element (type 1) nodes
						//turn menu items into links or non-IE browsers won't pick them up
						var cmdNcr = document.createElement("a");
						cmdNcr.href = "#";
						if(menuItem.getAttribute("cmd") != null) {
							//menuItem.onclick = new Function("Do(document.getElementById(\""+menuItem.getAttribute("id")+"\"))"); 
							cmdNcr.onclick = new Function("Do(document.getElementById(\""+menuItem.getAttribute("id")+"\"))"); 
						} 
						
						menuItem.onmouseover = new Function("highlight(document.getElementById(\""+menuItem.getAttribute("id")+"\"))");
						cmdNcr.onmouseover = new Function("this.parentNode.onmouseover();");
						
						//copy all the children
						var eachChild = menuItem.firstChild;
						while (eachChild != null) {
							cmdNcr.appendChild(eachChild);
							eachChild = eachChild.nextSibling;
						}
						menuItem.appendChild(cmdNcr);
						
						//append the triangle to indicate submenus
						if(document.getElementById(menuItem.getAttribute("menu")) != null) { 
							var tempSpan;
							tempSpan = document.createElement("img");
							tempSpan.src = "/images/submenu.gif"
							tempSpan.style.marginLeft = "3px"
							//tempSpan = document.createElement("span");
							menuItem.appendChild(tempSpan);
							//tempSpan.setAttribute("id", menuItem.getAttribute("id")+"_Arrow");
							//tempSpan.className = "Arrow";
							//tempSpan.appendChild(document.createTextNode("4"));
							
							FindSubMenu(menuItem.getAttribute("menu"));
						}
					}
					menuItem = menuItem.nextSibling;
				} 
			}
			bar = bar.nextSibling;
		}
		
		return true;
	}
	
	function FindSubMenu(subMenu) {
		var menu = document.getElementById(subMenu);
		menu.style.visibility = "hidden";
		
		var menuItem = menu.firstChild;
		
		while (menuItem != null) {
			if (menuItem.nodeType == 1)	{	// an element node; only want to process document element nodes
										// -Mozilla-based browswers seem to interperet in a strict XML fashion
										// 	and treat everything, even whitespace, as child nodes.
				//Turn each menu item into a link or non-IE browsers won't pick up the needed events.
				var cmdNcr = document.createElement("a");
				cmdNcr.href = "#";
				if(menuItem.getAttribute("cmd") != null) {
					//menuItem.onclick = new Function("Do(document.getElementById(\""+menuItem.getAttribute("id")+"\"))"); 
					cmdNcr.onclick = new Function("Do(document.getElementById(\""+menuItem.getAttribute("id")+"\"))"); 
				} 
				
				menuItem.onmouseover = new Function("highlight(document.getElementById(\""+menuItem.getAttribute("id")+"\"))");
				cmdNcr.onmouseover = new Function("this.parentNode.onmouseover();");
				
				//copy all the children
				var eachChild = menuItem.firstChild;
				while (eachChild != null) {
					cmdNcr.appendChild(eachChild);
					eachChild = eachChild.nextSibling;
				}
				menuItem.appendChild(cmdNcr);
				
				//append the little arrow thingy if for submenus
				if(menuItem.menu!= null) {
					var tempSpan;
					tempSpan = document.createElement("img");
					tempSpan.src = "/images/submenu.gif"
					tempSpan.style.marginLeft = "3px"
					//tempSpan = document.createElement("span");
					menuItem.appendChild(tempSpan);
					//tempSpan.setAttribute("id", menuItem.getAttribute("id")+"_Arrow");
					//tempSpan.className = "Arrow";
					//tempSpan.appendChild(document.createTextNode(" 4"));
					
					FindSubMenu(menuItem.menu);
				 }
			}
			menuItem = menuItem.nextSibling;
		}  
	} 

	function ShowMenu(obj) {
		HideMenu(document.getElementById("menuBar"));
		
		var menu = document.getElementById(obj.getAttribute("menu"));
		var bar = obj;
		bar.setAttribute("class", "barOver");
		menu.style.visibility = "visible";
		if (isIE) { //IE browser
			menu.style.pixelTop =  obj.getBoundingClientRect().top + obj.offsetHeight + Bdy.scrollTop;
			menu.style.pixelLeft = obj.getBoundingClientRect().left + Bdy.scrollLeft;
		} else if (isOp) { //Opera
			var eltHeight = parseFloat(document.defaultView.getComputedStyle(obj, null).getPropertyValue("height"));
			//var eltLeft = parseFloat(document.defaultView.getComputedStyle(obj, null).getPropertyValue("left"));
			//var eltTop = parseFloat(document.defaultView.getComputedStyle(obj, null).getPropertyValue("top"));
			menu.style.top = findPosY(obj) + eltHeight + document.getElementById("Bdy").scrollTop +"px";
			menu.style.left = findPosX(obj) + document.getElementById("Bdy").scrollLeft +"px";
		} else { //Everybody else
			menu.style.top = document.getBoxObjectFor(obj).y + obj.offsetHeight + document.getElementById("Bdy").scrollTop +"px";
			menu.style.left = document.getBoxObjectFor(obj).x + document.getElementById("Bdy").scrollLeft +"px";
		}
	}
   
	function highlight(obj) {
		var PElement = obj.parentNode;
		if(PElement.hasChildNodes() == true) {
			var TE = PElement.firstChild;
			while (TE != null) {
				if (TE.nodeType == 1) {
					TE.className = "menuItem";
				}
				TE = TE.nextSibling;
			}
		} 
		ShowSubMenu(obj);
		obj.className = "ItemMouseOver";
		window.defaultStatus = obj.getAttribute("title");
	}
   
	function Do(obj) {
		var cmd = obj.getAttribute("cmd");
		//window.navigate(cmd);
		window.location = cmd;
	}
   
	function HideMenu(obj) {
		if(obj.hasChildNodes()==true) {  
			var child = obj.firstChild;
			
			while (child != null) {
				if (child.nodeType == 1) {	// an element node; only want to process document element nodes
										// -Mozilla-based browswers seem to interperet in a strict XML fashion
										// 	and treat everything, even whitespace, as child nodes.
					if (child.className == "barOver") {
						child.className = "Bar";
					} else if (child.className == "ItemMouseOver") {
						child.className = "menuItem";
					}
					
					if(child.getAttribute("menu") != null) {
						var childMenu = document.getElementById(child.getAttribute("menu"));
						HideMenu(childMenu);
						childMenu.style.visibility = "hidden";
					}
				}
				child = child.nextSibling;
			}
		}
	}

	function ShowSubMenu(obj)
	{
		PMenu = obj.parentNode;
		HideMenu(PMenu);
		if(obj.getAttribute("menu") != null)
		{
			var menu = document.getElementById(obj.getAttribute("menu"));
			menu.style.visibility = "visible";
			if (isIE) {
				menu.style.pixelTop =  obj.getBoundingClientRect().top + Bdy.scrollTop;
				menu.style.pixelLeft = obj.getBoundingClientRect().right + Bdy.scrollLeft;
				if(menu.getBoundingClientRect().right > window.screen.availWidth ) {
					menu.style.pixelLeft = obj.getBoundingClientRect().left - menu.offsetWidth;
				}
			} else if (isOp) {
				menu.style.top =  findPosY(obj) + document.getElementById("Bdy").scrollTop +"px";
				menu.style.left = findPosX(obj) + obj.offsetWidth + document.getElementById("Bdy").scrollLeft +"px";
				if((document.getBoxObjectFor(menu).x + menu.offsetWidth) > window.screen.availWidth ) {
					menu.style.left = findPosX(obj) - menu.offsetWidth +"px";
				}
			} else {
				menu.style.top =  document.getBoxObjectFor(obj).y + document.getElementById("Bdy").scrollTop +"px";
				menu.style.left = document.getBoxObjectFor(obj).x + obj.offsetWidth + document.getElementById("Bdy").scrollLeft +"px";
				if((document.getBoxObjectFor(menu).x + menu.offsetWidth) > window.screen.availWidth ) {
					menu.style.left = document.getBoxObjectFor(obj).x - menu.offsetWidth +"px";
				}
			}
		}
	} 

