function findPosX(obj){
  var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      if(obj.offsetParent.style.position=='absolute')
        break;
      curleft += obj.offsetLeft
      obj = obj.offsetParent;
    }
  }
  return curleft;
}

function findPosY(obj){
  var curtop = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curtop += obj.offsetTop
      obj = obj.offsetParent;
    }
  }
  return curtop;
}

startList = function()
{
  var ml=document.getElementsByName("menu");
  for(var i=0; i<ml.length; i++)
  {
    var node=ml[i];
    node.onmouseover=function()
    {
      zz=this.childNodes;
      for(j=0;j<zz.length;++j)
      {
        node=zz[j]
        if(node.className=="rmenu" || node.className=="dmenu")
        {
          node.style.visibility="visible";
          if(node.className=="rmenu")
          {
            var yoffs=(findPosY(this)-this.offsetTop)-(findPosY(node)-node.offsetTop);

var ox=findPosX(this);
//alert(ox);
            node.style.left=ox+this.offsetWidth;

//            node.style.left=this.offsetLeft+this.offsetWidth;
            node.style.top=this.offsetTop+yoffs;
          }
          else
          {
            node.style.left=findPosX(this);
            node.style.top=findPosY(this)+this.offsetHeight;
          }
        }
      }
    }
    node.onmouseout=function()
    {
      zz=this.childNodes;
      for(j=0;j<zz.length;++j)
      {
        node=zz[j]
        if(node.className=="rmenu" || node.className=="dmenu")
          node.style.visibility="hidden";
      }
    }
  }
}
window.onload=startList;

