function Menu(levels)
{
  this.url = new String(document.location);
  this.levels = new Array();

  levels = (levels) ? levels : 5;

  this.setLevels = function(levels)
  {
    for (i=1; i<=levels; i++)
    {
      var regex = new RegExp("\w{0,3}\.?linguistics.buffalo.edu(/([A-Z_-]+)){" + i + "}","i");
      var match = this.url.match(regex);

      if (match)
      {
        var level = new Obj(match[2]);

        if (level.id)
          this.levels.push(level);
      }
      else
        break;
    }
  }

  this.expandLevels = function()
  {
    for (i=0; i<this.levels.length; i++)
    {
      this.levels[i].style.display = "block";
    }
  }

  this.getLevels = function()
  {
    return this.levels;
  }

  this.expand = function(name)
  {
    var obj = new Obj(name);
    lists = obj.parentNode.parentNode.getElementsByTagName("ul");

    for (i=0; i<lists.length; i++)
      lists[i].style.display = "none";

    this.expandLevels();
    obj.style.display = "block";
  }

  this.setLevels(levels); 
}

function Obj(name)
{
  return document.getElementById(name);
} 
