var IE = (!(navigator.appName == "Netscape"));
var NewNetscape = ((!IE) && (parseInt(navigator.appVersion) > 4));

function TBaseClass_addChild(child)
{
  this.children[this.children.length++] = child;
  child.setParent(this);
  return child;
}

function TBaseClass_getChildren()
{
  return this.children;
}

function TBaseClass()
{
  this.children = new Array();
  this.addChild = TBaseClass_addChild;
  this.getChildren = TBaseClass_getChildren;
  return this;
}

function TMenu_draw()
{
   var txt = '';
   var children = this.getChildren();
   for (var i = 0; i < children.length; i++)
   {
      txt += children[i].getContents();
   }
   this.obj.innerHTML = txt;
}

function TMenu(div)
{
  this.inheritFrom = TBaseClass;
  this.inheritFrom();
  this.obj = document.getElementById(div);
  this.draw = TMenu_draw;
  return this;
}

function TMenuItem_setParent(parent)
{
  this.parentmenu = parent;
}

function TMenuItem_getContents()
{
   var temp = this.txt;
   if (this.expanded)
   {
      var children = this.getChildren();
      for (var i = 0; i < children.length; i++)
      {
         temp += children[i].getContents();
      }      
   }
   return temp;
}

function TMenuItem_toggle()
{
   this.expanded = (!this.expanded);
   if (this.expanded)
      this.txt = this.txt.replace('plus', 'minus');
   else
      this.txt = this.txt.replace('minus', 'plus');
   this.parentmenu.draw();
   return false;
}

function TMenuItem_expand()
{
   this.expanded = true;
   this.txt = this.txt.replace('plus', 'minus');
   if (this.parentmenu.expanded != null) this.parentmenu.expand();
}
function TMenuItem_select()
{
   this.txt = this.txt.replace('<TH>', '<TH CLASS = "SELECTED">');
   this.expand();
}

function TMenuItem_draw()
{
   this.parentmenu.draw();
}

function TMenuItem(txt)
{
  this.inheritFrom = TBaseClass;
  this.inheritFrom();
  this.parentmenu = null;
  this.txt = txt;
  this.expanded = false;
  this.txt = this.txt.replace('minus', 'plus');
  this.getContents = TMenuItem_getContents;
  this.setParent = TMenuItem_setParent;
  this.toggle = TMenuItem_toggle;
  this.expand = TMenuItem_expand;
  this.select = TMenuItem_select;
  this.draw = TMenuItem_draw;
  return this;
}