var _Xdiv = 0;
function menuFix(i) {
  if (i == _Xdiv) return;
  var sfEls = document.getElementById("header").getElementsByTagName("li");
	sfEls[i].className = "typeselected";
	if (i > 0)	
	{
		sfEls[i-1].className = "";
	}
	sfEls[_Xdiv].className = "";
  sfEls[_Xdiv].style.cursor='pointer';
	sfEls[i].style.cursor='auto';
	_Xdiv = i;
}

var _pos = 0;
window.onload=function()
{
  var h3addul=document.getElementById("sidebar").childNodes;
  SetNode(h3addul);
}
function SetNode(Nodes)
{
  if (Nodes == null) return;
  var n;
  for(var i=0; i<Nodes.length; i++)
  {
    if(Nodes[i].tagName=="H1" || Nodes[i].tagName=="H2") n = Nodes[i]; 
    else if(Nodes[i].tagName=="UL")
    {
      n.son = Nodes[i];
      n.pos = _pos;
      /*if (n.tagName == "H2")
      {
        var p = GetCookie("KF_UA_MENU");
        if (p == null || p != _pos)
        {
          n.className = "jia";
          n.son.style.display  = "none";
          n.son.style.color="red";
        }
      }*/
      n.onclick= function()
      {
        this.className = this.className == ''? 'jia':'';
        if (this.son.style.display == 'block' || this.son.style.display == '')
        {
          this.son.style.display = 'none';
          //SetCookie("KF_UA_MENU", -1);
        }
        else
        {
          this.son.style.display = 'block';
          //SetCookie("KF_UA_MENU", this.pos);
        }
      }
      var cNodes = Nodes[i].childNodes;
      if (cNodes != null)
      {
        for (var j=0; j < cNodes.length; j++)
        {
          SetNode(cNodes[j].childNodes);
        }
      }
    }
    _pos++;
  }
}
function menu(c, url)
{
  //SetCookie("menucode", c);
  window.location.href=url;
}
