var onmenu = false;
var hideItem = null;
var currentMenu = false;


function debug(line)
{
   // document.getElementById('debug').innerHTML = line + '<br />' + document.getElementById('debug').innerHTML;
}

function hidethesemenus()
{

    for(var i=0;i<arguments.length;i++)
    {
        if (document.getElementById(arguments[i]))
        {
            document.getElementById(arguments[i]).style.display = "none";
        }
    }


}

	        function $() {
                var elements = new Array();

                  for (var i = 0; i < arguments.length; i++) {
                    var element = arguments[i];
                    if (typeof element == 'string')
                      element = document.getElementById(element);

                    if (arguments.length == 1)
                      return element;

                    elements.push(element);
                  }

                  return elements;
                }
	    
	        function showmenu(oElement)
	        {
	            if ($(oElement))
	            {
	                onmenu = true;
	                hideItem = null;
	                $(oElement).style.display = "";
	            }
	            
	        }
	        
	        function hideAllMenus(oElement)
	        {
	            for(x=0;x<oElement.childNodes.length;x++)
	            {
	                var cNode = oElement.childNodes[x];
	                if (cNode.tagName == "LI")
	                {
	                    cNode.className = cNode.className.replace("selected","");
	                    for(y=0;y<cNode.childNodes.length;y++)
	                    {
	                        var liNode = cNode.childNodes[y];
	                        if (liNode.tagName == "UL")
	                        {
	                            liNode.style.display = "none";
	                            //hideAllMenus(liNode);
	                        }
	                    }
	                }
	            }
	        
	        
	        }
	        
	        function showSubMenu(oElement)
	        {
	            onmenu = true;
	            currentMenu = oElement;
	            var parentNode = oElement.parentNode;
                hideAllMenus(parentNode);	      
                oElement.className = "selected";
	                 
	            for(x=0;x<oElement.childNodes.length;x++)
	            {
	                //alert(x + "=" + oElement.childNodes[x].tagName);
	                if (oElement.childNodes[x].tagName == "UL")
	                {
	                    oElement.childNodes[x].style.display = "";
	                    //alert(oElement.innerHTML);
	                }
	            }

	            
	        }
	        
	        
	        function hidemyRootMenu(oElement)
	        {
	            currentMenu = false;
	            hidemenu($(oElement))
	        }
	        
	        
	        
	        
	        function hidemenu(oElement)
	        {
	            if ($(oElement))
	            {

	                    onmenu = false;
	                    //$(oElement).style.display = "none";
	                    debug('called hide menu on Element ' + $(oElement).id);
	                    debug('currently on Element ' + currentMenu.id);
	                    if(hideItem)
	                    {
	                        if (hideItem.id != $(oElement).id)
	                        {
	                            hideItem = $(oElement)
	                            setTimeout('hmenu()',4000);
	                        }	                    
	                    }
	                    else
	                    {
	                       hideItem = $(oElement)
	                       setTimeout('hmenu()',4000);
	                    }


	                
	            }
	            
	        }
	        
	        function hmenu()
	        {
	            if (onmenu == false)
	            {
	                if (!currentMenu)
	                {
                       hideItem.style.display = "none";
	                   debug('hiding ' + hideItem.id);	  
	                }
	                else
	                {
	                    ulparent = currentMenu.parentNode;
	                    while (ulparent.getAttribute("isRoot") != "1")
	                    {
	                        ulparent = ulparent.parentNode;
	                    }
	                    //if (ulparent.id != hideItem.id)
	                   // {
	                    	hideItem.style.display = "none";
	                        debug('hiding ' + hideItem.id);	    
	                   // }
	                
	                
	                }
	                


	            }
	        
	        
	        }
	    