function Menu(id,x) {
  var div=document.createElement("div");
  div.id=id;
  div.style.zIndex=2000;
  div.style.position="absolute";
  div.style.visibility="hidden";
  div.style.display="none";
  div.style.width=170;
  div.style.top=150;
  div.style.left=x;
  div.style.background="#ffffff";
  div.style.border="1px solid #909090";
  div.style.padding=2;
  div.setAttribute("items",0);
  div.onmouseover=function() {
    if (timers[this.id]) clearTimeout(timers[this.id]);
  }
  div.onmouseout=function() {
    var cmd="killmenu('"+this.id+"')";
    timers[this.id]=setTimeout(cmd,150);
  }
  document.body.appendChild(div);
  var shdiv=document.createElement("div");
  shdiv.className="menushadow";
  shdiv.style.top=150;
  shdiv.style.left=x;
  shdiv.style.height=6;
  shdiv.style.zIndex=1999;
  this.div=div;
  this.shdiv=shdiv;
  document.body.appendChild(shdiv);
  this.additem=function(title,url) {
    var div=document.createElement("div");
    div.className="menuitem";
    div.innerHTML=title;
    div.setAttribute("url",url);
	div.setAttribute("target","_self");
    this.div.setAttribute("items",parseInt(this.div.getAttribute("items"))+1);
    this.shdiv.style.height=parseInt(this.shdiv.style.height)+17;
    div.onmouseover=function() {
      this.style.color="#ffffff";
      this.style.background="#a32323";
    }
    div.onmouseout=function() {
      this.style.color="#404040";
      this.style.background="#ffffff";
    }
    div.onclick=function() {
      var url=this.getAttribute("url");
      var target=this.getAttribute("target");
      if (url && target) window.open(url,target);
    }
    this.div.appendChild(div);
  }
  this.show=function() {
    this.div.style.display="block";
    this.div.style.visibility="visible";
    this.shdiv.style.display="block";
    this.shdiv.style.visibility="visible";
  }
  this.hide=function() {
    this.div.style.display="none";
    this.div.style.visibility="hidden";
    this.shdiv.style.display="none";
    this.shdiv.style.visibility="hidden";
  }
  menus[id]=this;
  return this;
}
function killmenu(id) {
  if (menus[id]) menus[id].hide();
}
