function Menu(parent){
  this.top=document.createElement("DIV");
  this.top.className="top"
  this.id="-1";
  this.type="section"
  parent.appendChild(this.top);

  this.menu=document.createElement("UL");
  this.menu.id="treemenu1"
  this.top.appendChild(this.menu);
  this.highestid=0;

  this.items=new Array();
  this.selected=null;
  this.addItem=function(id,name,parent,type,link,target){
    this.items.push(new MenuItem(id,name,parent,type,link,target,this));
    return this.items[this.items.length-1];
  }

}
function MenuItem(id,name,parent,type,link,target,menu){

  this.id=id;
  this.name=name;
  this.parent=parent;
  this.type=type;
  this.link=link;
  this.target=target;
  this.menu=menu;
  if(this.id>this.menu.highestid)this.menu.highestid=this.id;

  //create top level items
  if(this.parent==-1||this.parent=="_top"){
     this.item=document.createElement("LI")
     this.item.id="item_"+this.id;
     this.select=document.createElement("SPAN");

     this.item.appendChild(this.select);
     this.menu.menu.appendChild(this.item);
     this.parentEle=this.menu.menu;
     if(this.type=="section"){
       this.select.innerHTML=this.name;
       this.item.sub=document.createElement("UL");
       this.item.sub.style.display="none"
       this.item.sub.id="item_"+this.id+"_sub"
       this.item.appendChild(this.item.sub)
       this.item.className="expandable";
       
       this.item.sub.className="subsection";
     }
     else{

       this.select.innerHTML="<A class='menulink' href='../content/"+this.link+"' target='"+((this.target=="internal")?"main":"_blank")+"'>"+this.name+"</A>";
       this.item.className="page";
     }
  }
  else{

     this.item=document.createElement("LI")
     this.item.id="item_"+this.id;

     this.select=document.createElement("SPAN");
     //this.select.innerHTML=this.name;
     this.item.appendChild(this.select);
     document.getElementById("item_"+this.parent+"_sub").appendChild(this.item);
     this.parentEle=document.getElementById("item_"+this.parent+"_sub")
     if(this.type=="section"){
       this.select.innerHTML=this.name;
       this.item.sub=document.createElement("UL");
       this.item.sub.style.display="none"
       this.item.sub.id="item_"+this.id+"_sub"
       this.item.appendChild(this.item.sub)
       this.item.className="closed";
       this.item.sub.className="expandable";
     }
     else{
       this.select.innerHTML="<A class='menulink' href='../content/"+this.link+"' target='"+((this.target=="internal")?"main":"_blank")+"'>"+this.name+"</A>";
       this.item.className="page";
     }
  }




}


