var tm = new topmenu();
 //初始化jsmenu数据
  //var channels = new Array(1,2,3,4,5,6,7,1001);
  for(var c=0;c<channel_list.length;c++){
    var channelid = channel_list[c].id;
	 
	var len = eval("category_"+channelid+".length");//取这个频道的所有栏目个数

	tm.add(new menuitem(channelid,0,"<img widht='4' height='13' border=0 src='/images/arrow.gif'> "+channel_list[c].name,"","_blank"));
    for(var i=0;i<len;i++){
	  var _obj = eval("category_"+channelid+"")[i];
	  if( _obj.upid==0) {
         tm.add(new menuitem(_obj.id,channelid,"<img widht='4' height='13' border=0 src='/images/arrow.gif'> "+_obj.name,_obj.href,"_blank"));
	  }
    }
  }
 

function show2(el,id){
   hidden2();
   el.className = "topB";
   document.getElementById("menu2").innerHTML  = tm.getChildNode(id,0,1);
}

function init2(categoryid,checkid){
    document.getElementById("menu2").innerHTML  = tm.getChildNode(categoryid,checkid,1);
	document.getElementById("menu1_"+categoryid).className = "topB";
}

function hidden2(){ 
   document.getElementById("menu2").innerHTML = "";
   var el = document.getElementById("top").childNodes;
   for(var x=0;x<el.length;x++){
        if(el[x].nodeName=="A"){
            el[x].className = "topA";
		}
   }
}

//顶部导航菜单
function topmenu(){
   this.items = new Array();
   this.className = "";
   this.add=function(i){
	 this.items[this.items.length] = new menuitem(i.id,i.upid,i.name,i.href,i.target);
   }
   /*
   //divid 显示的容器
   //startid起始id
   this.create = function(divid,startid){
	 var innerHTML="";
	 var c = 0;
	 innerHTML += "<DIV class="+className+"><UL>"; 
	 for(x=0;x<this.items.length;x++){
	     if(this.items[x].upid == startid){
	         innerHTML += "<LI onmouseover=\"over(this)\" onmouseout=\"out(this)\"><A target='"+this.items[x].target+"' href='"+this.items[x].href+"'>"+this.items[x].name+"</A>"+this.getChildNode(this.items[x].id,4);+"</LI>";
		     c++;
		 }
	 }
	 innerHTML +="</UL></DIV>";
	 if(c==0) innerHTML = "";
	 document.getElementById(divid).innerHTML = innerHTML;
   }
   */
   //取子类
   this.getChildNode=function(id,checkid,max){
        if(max<0) return "";
		var _max = --max;
        var innerHTML = "";
		var c = 0;
	    innerHTML += "<UL>"; 
        for(var i=0;i<this.items.length;i++){
	       if(this.items[i].upid == id){
			  innerHTML += "<LI>";
			  if(checkid==this.items[i].id)
				  innerHTML += "<A target=\""+this.items[i].target+"\" href=\""+this.items[i].href+"\"><B>"; 
			  else 
				  innerHTML += "<A target=\""+this.items[i].target+"\" href=\""+this.items[i].href+"\">";
			  
			  innerHTML += this.items[i].name;
			  
			  if(checkid==this.items[i].id) innerHTML += "</B></A>"; else innerHTML += "</A>";
			  
			  innerHTML += this.getChildNode(this.items[i].id,checkid,_max);//子类
			  
			  innerHTML += "</LI>";
			  c++;
		   }
        }
	    innerHTML +="</UL>";
		if(c==0) innerHTML = "";
		return innerHTML;
   }
}



function show3(divid){
	document.getElementById(divid).style.display='';
}

function hidden3(divid){
	document.getElementById(divid).style.display='none';
}

//级联菜单
function menu(){
   this.items = new Array();
   this.divid;
   this.add=function(i){
	 this.items[this.items.length] = new menuitem(i.id,i.upid,i.name,i.href,i.tagert);
   }

   this.over=function(el){
	//document.getElementById(this.divid).className="show";
    document.getElementById(this.divid).style.display='';
	for (i=0; i<el.childNodes.length; i++)//取所有子节点
	{
		node = el.childNodes[ i ];
		if(node.nodeName=="UL")
		    node.className="show";
	}
   }

   this.out = function(el){
	   for (i=0; i<el.childNodes.length; i++)//取所有子节点
		{
			node = el.childNodes[ i ];
			if(node.nodeName=="UL"){
				node.className="hidden";
			}
		} 
    }



   this.create = function(divid,startid){
	 this.divid = divid;
	 var innerHTML="";
	 var c = 0;
	 innerHTML += "<DIV><UL>"; 
	  
	 for(x=0;x<this.items.length;x++){
	     if(this.items[x].upid == startid){
	         innerHTML += "<LI onmouseover=\""+this.divid+".over(this)\" onmouseout=\""+this.divid+".out(this)\"><A href=\""+this.items[x].href+"\">"+this.items[x].name+"</A>"+this.getChildNode(this.items[x].id,4);+"</LI>";
		     c++;
		 }
	 }
	 innerHTML +="</UL></DIV>";
	 if(c==0) innerHTML = "";

	 document.getElementById(divid).innerHTML = innerHTML;
   }

   this.getChildNode=function(id,max){
        if(max<0) return "";
		var _max = max--;
        var innerHTML = "";
		var c = 0;
	    innerHTML += "<UL class=hidden >"; 
        for(var i=0;i<this.items.length;i++){
	       if(this.items[i].upid == id){
			  innerHTML += "<LI onmouseover=\""+this.divid+".over(this)\" onmouseout=\""+this.divid+".out(this)\">";
			  innerHTML += "<A href=\""+this.items[i].href+"\">"
			  innerHTML += this.items[i].name;
			  innerHTML += "</A>";
			  innerHTML += this.getChildNode(this.items[i].id,_max);//子类
			  innerHTML += "</LI>";
			  c++;
		   }
        }
	    innerHTML +="</UL>";
		if(c==0) innerHTML = "";
		return innerHTML;
   }
   
}