function SelectorMenu(id, xOff, yOff)
{
  if (id != null)
  {
    SelectorMenu.init(this);
  }
}
new SelectorMenu(null, null, null);

SelectorMenu.init = function(obj, id, xOff, yOff)
{
  if ((id != null) && (document.getElementById != null))
  {
    obj.id = id;
    obj.docObj = document.getElementById(obj.id);
    obj.xOff = xOff;
    obj.yOff = yOff;

    obj.docObjParent = null;
    obj.parentID = null;

    SelectorMenu.h[obj.id] = obj;
  }
}

SelectorMenu.get = function(id)
{
  return SelectorMenu.h[id];
}

SelectorMenu.h = new Array();
SelectorMenu.sane = (document.getElementById != null);
SelectorMenu.selections = new Array();

SelectorMenu.prototype.show = function(parentID)
{
  var xyOff, el;
  if (SelectorMenu.sane)
  {
    this.parentID = parentID;
    this.docObjParent = document.getElementById(this.parentID);
    xyOff = SelectorMenu.getXYOffset(this.docObjParent);
    el = this.docObj;
    el.style.left = xyOff['x'] + this.xOff+"px";
    el.style.top = xyOff['y']+ this.yOff+"px";
    el.style.visibility = "visible";
    el.style.overflow = "auto";
    el.style.display = "block";
  }
}


SelectorMenu.selectorArray = function(selectorID)
{
  return (SelectorMenu.selections[selectorID] = new Array());
}

SelectorMenu.prototype.hide = function()
{
  var el = this.docObj;
  el.style.visibility = "hidden";
  el.style.overflow = "visible";
  el.style.display = "none";
}

SelectorMenu.getXYOffset = function(obj)
/* Find the XY offset of the HTML item this menu is bound to */
{
  var xyOff = new Array();
  var xyOffParent;
  
  if(obj.offsetParent != null)
  {
    xyOffParent = SelectorMenu.getXYOffset(obj.offsetParent);
  }
  else
  {
    xyOffParent = new Array();
    xyOffParent['x'] = xyOffParent['y'] = 0;
  }
  xyOff['x'] = parseInt(obj.offsetLeft) + xyOffParent['x'];
  xyOff['y'] = parseInt(obj.offsetTop) + xyOffParent['y'];
  return xyOff;
}

SelectorMenu.show = function(id, parentID)
{
  if (SelectorMenu.h[id] != null)
  {
    SelectorMenu.h[id].show(parentID);
  }
}

SelectorMenu.hide = function(id)
{
  if (SelectorMenu.h[id] != null)
  {
    SelectorMenu.h[id].hide();
  }
}
