   var uid=0;
   var level=0;
   var objlist=new Array();
   
   function oNav() {
      
      function oMenuitem(txt,url) {
         this.txt=txt;
         this.url=url;
         this.addSubmenu=addSubmenu;
         uid++;
         this.uid=uid;
         this.level=0;
         
         function addSubmenu() {
            this.submenu=new oNav();
            this.submenu.level=this.level+1;
            //alert(this.submenu.level);
            return(this.submenu);
         }
      }
      
      var navitems=new Array();
      var itemcount=0;
      
      this.itemcount=itemcount;
      this.navitems=navitems;
      this.addItem=addItem;
      this.draw=draw;
      this.level=0;
      this.showPopup=showPopup;
      
      objlist[objlist.length]=this;
      function addItem(txt,url,submenu) {
         this.navitems[itemcount]=new oMenuitem(txt,url); 
         if (submenu) {
            this.navitems[itemcount].addSubmenu();
         }
         //linklist[itemcount]=url;
         itemcount++;
         return (this.navitems[itemcount-1]);
      }
      
      
      function draw(elid,id,postop,level) {
         if (!id) {
            id=0;
         }
         if (!level) {
            level=0;
         }
         this.postop=postop;
         el=document.getElementById(elid);
         this.containerdiv=document.createElement("div");
         this.containerdiv.id="containerid-"+id;
         this.containerdiv.className="menu-level-"+level;
         if (this.level>0) {
            this.containerdiv.style.display="none";
            this.containerdiv.style.top=this.postop+"px";
            this.containerdiv.style.position="absolute";
         } else {
            this.containerdiv.style.display="block";
         }
         this.containerdiv.style.zIndex=20;
         //this.containerdiv.onmouseout=hideMenu;
         el.appendChild(this.containerdiv);
         for (this.x=0; this.x < this.navitems.length; this.x++) {
            this.itemdiv=document.createElement("div");
            this.itemdiv.className="menuitem";
            if (this.navitems[this.x].url!="") {
               this.itemdiv.onclick=openUrl;
            }
            this.itemdiv.innerHTML=this.navitems[this.x].txt;
            this.itemdiv.id="menuid-"+this.navitems[this.x].uid;
            this.itemdiv.onmouseover=this.showPopup;
            this.containerdiv.appendChild(this.itemdiv);
            if (this.navitems[this.x].submenu) {
               //this.level++;
               this.navitems[this.x].submenu.draw(this.containerdiv.id,this.navitems[this.x].uid,findTop(this.itemdiv),(level+1));
            }
         }
      }
      
      function showPopup(e) {
         if (!e) {
            e=window.event;
         }
         if (!e.target) {
            el=e.srcElement;
         } else {
            el=e.target;
         }
         elid=el.id;
         
         containerid=elid.replace("menuid","containerid");
         if (document.getElementById(containerid)) {
            var container=document.getElementById(containerid);
            hideAll(container.parentNode);
            
            
            if (el.parentNode.id!="containerid-0") {
               toppos=(el.offsetTop-2);
               document.getElementById(containerid).style.top=toppos+"px";
            } else {
               hideAll();
            }
            el.className="menuitem-selected";
            document.getElementById(containerid).style.display="block";
            for (x=0;x<container.childNodes.length;x++) {
               if (container.childNodes[x].id.match("menuid")) {
                  container.childNodes[x].className="menuitem";
               }
            }
         } else {
            hideAll(el.parentNode);
            el.className="menuitem-selected";
         }
      }
   }
   
   function hideAll(topel) {
      //alert(topel.type);
      if ((!topel) || (topel.target) || (topel.srcElement)) {
         topel=document.getElementById("containerid-0");
      }
      
      for (var x=0;x<topel.childNodes.length; x++) {
         if (topel.childNodes[x].id) {
            if (topel.childNodes[x].id.match("containerid") ) {
               topel.childNodes[x].style.display="none";
               if (topel.childNodes[x].hasChildNodes()) {
                  hideAll(topel.childNodes[x]);
               }
            } else if (topel.childNodes[x].id.match("menuid")) {
               topel.childNodes[x].className="menuitem";
            }
         }
      }
   }
   
   function findTop(obj) {
	   var curtop = 0;
	   if (obj.offsetParent) {
	   	curtop = obj.offsetTop
	   	while (obj = obj.offsetParent) {
	   		curtop += obj.offsetTop
	   	}
	   }
	   return curtop;
   }
   
   function openUrl(e) {
      if (!e) {
         e=window.event;
      }
      if (!e.target) {
         el=e.srcElement;
      } else {
         el=e.target;
      }
      
      uid=el.id.split("-")[1];
      //alert(objlist.length);
      for(i=0;i<objlist.length;i++) {
         //alert(objlist[i].navitems);
         for(x=0;x<objlist[i].navitems.length;x++) {
            menuitem=objlist[i].navitems[x];
            if (uid==menuitem.uid) {
               //alert("Going to "+menuitem.url);
               location.href=menuitem.url;
            }
         }
      }
   }
   
   function hideMenu(e) {
      if (!e) {
         e=window.event;
      }
      if (!e.target) {
         el=e.srcElement;
      } else {
         el=e.target;
      }
      elid=el.id;
      if (!(elid.match("menu") || elid.match("container"))) {
         hideAll();
      } 
      //document.getElementById("mainsection").innerHTML=el.id;
   }
   
   document.onmousemove=hideMenu;