var menu={

collapseMenu:function(node)
{
  if (!document.getElementById) return false;
  if (!document.getElementById("menuproduct")) return false;
  if (!node) node = document.getElementById("menuproduct");

  if (node.childNodes.length > 0)
  {
    //alert(node.childNodes.length) ;
    for (var i=0; i<node.childNodes.length; i++)
    {
      var child = node.childNodes[i];
      if (child.nodeName == "UL")
      {
        /*
        if (child.style.display != "block")
          child.style.display = "none";
        */
        //alert(child.className) ;
        if (child.className != "classshow")
          child.className = "classhide";
      }
      menu.collapseMenu(child);
    }
  }
},

prepareMenu:function()
{
  if (!document.getElementById || !document.getElementsByTagName) return false;
  if (!document.getElementById("menuproduct")) return false;

  var links = document.getElementById("menuproduct").getElementsByTagName("a");

  //alert(links.length) ;
  for (var i=0; i<links.length; i++)
  {
  	if (links[i].parentNode.getElementsByTagName("UL"))
	{
		links[i].onclick = function()
		{
			//alert('x') ;
			//alert(this.parentNode.getElementsByTagName("UL")[0].id) ;
		/*
		  alert(i + "-" + links[i].href + "-" + this.parentNode.getElementsByTagName("UL")[0].className + "-" + this.parentNode.getElementsByTagName("UL").className) ;*/		  
        menu.toggleMenu(this.parentNode.getElementsByTagName("UL")[0], this.href);
		  return false;
		}
	}
  }
},

prepareMenuHover:function()
{
  if (!document.getElementById || !document.getElementsByTagName) return false;
  if (!document.getElementById("menuproduct")) return false;

  var links = document.getElementById("menuproduct").getElementsByTagName("li");

  //alert(links.length) ;
  for (var i=0; i<links.length; i++)
  {
    if (links[i].id && links[i].id.substring(0,3)=="li2")// && links[i].id == "li2_299")
	{
		ullist = links[i].getElementsByTagName("ul");		
		if (ullist && ullist.length>0)
		{
			if (ullist[0].id == "ul2_299")
				alert(ullist.length + "-" + ullist[0] + "-" + ullist[0].id) ;
			//return ;
			ullist[0].onclick = function()
			{
				alert('x') ;
			  //alert(i + "-" + this.href + "-" + this.parentNode.getElementsByTagName("UL")[0].className + "-" + this.parentNode.getElementsByTagName("UL").className) ;
			  //menu.toggleMenu(this.parentNode.getElementsByTagName("UL")[0], this.href);
			  return false;
			}
			//alert(ullist[0].id) ;
			/*
			if (ullist[0].className.search(/classhide/) == -1)
				ullist[0].className += " classhide" ;
			links[i].onmouseover=function() {
				ullist = this.getElementsByTagName("ul");
				ullist[0].className=ullist[0].className.replace(/classhide/g, "classshow");
			}
			links[i].onmouseout=function() {
				ullist = this.getElementsByTagName("ul");
				ullist[0].className=ullist[0].className.replace(/classshow/g, "classhide");
			}
			*/
		}
	}
  }
},

preselectMenu:function(menuid)
{	
//menuid = "ul1_100" ;
  node = document.getElementById(menuid);
  if (node)
  {
	  if (node.className.search(/classhide/) != -1)
		node.className=node.className.replace(/classhide/g, "classshow");
	  else
	  	node.className += " classshow" ;
  }
},

toggleMenu:function(node, link)
{
	if (!document.getElementById) return false;
	if (!link) return false;
	if (!node) location.href = link.href;
	
	menu.hideallmenusamelevel(node) ;
	
	if (node.className == "classhide")
	{
		node.className = "classshow";
	} 
	else 
	{
		node.className = "classhide";  
	}
},

hideonemenu:function(node)
{
if (!document.getElementById) return false;
if (!node) return false;

node.className = "classhide";
},


hideallmenu:function(currentnode)
{
  var links = document.getElementById("menuproduct").getElementsByTagName("a");
  //alert(links.length) ;
  for (var i=0; i<links.length; i++)
  {    
     if (links[i].parentNode.getElementsByTagName("UL")[0] != currentnode)
     {
        menu.hideonemenu(links[i].parentNode.getElementsByTagName("UL")[0]) ;
     }
  }
},

hideallmenusamelevel:function(currentnode)
{
	var links = document.getElementById("menuproduct").getElementsByTagName("a");
	//alert(links.length) ;
	
	var currentlevel = currentnode.id.split("ul")[1].split("_")[0] ;
	//var part3 = part2.split("_")[0] ;
	//var part4 = part2.split("_")[1] ;
	//alert(part2) ;// + "-" + part3 + "-" + part4) ;
	str = "" ;
	for (var i=0; i<links.length; i++)
	{
	 oneul    = links[i].parentNode.getElementsByTagName("UL")[0] ;
	 if (oneul)
	 {
		 str = str + "+" + i ;
		 //alert(i + "-" + oneul) ;
		 //return ;
		 oneid = oneul.id ;
		 onelevel = oneul.id.split("ul")[1].split("_")[0] ;
		 //if (links[i].parentNode.getElementsByTagName("UL")[0] != currentnode)
		 if (onelevel == currentlevel && oneul != currentnode)
		 {
			menu.hideonemenu(links[i].parentNode.getElementsByTagName("UL")[0]) ;
		 }
	 }
	}
	
	//alert(str) ;
}

//end menu
}

addLoadEvent(menu.collapseMenu);
addLoadEvent(menu.prepareMenu);
//addLoadEvent(menu.prepareMenuHover);
//addLoadEvent(menu.preselectMenu);
