path=new Array(10);
path[0]=0;
path[1]=-1;
path[2]=-1;
path[3]=-1;
path[4]=-1;
path[5]=-1;
path[6]=-1;
path[7]=-1;
path[8]=-1;
path[9]=-1;

linkStyle="0";
hintStyle="1";

function tree(bodyTag,nodeType,homeURL,homeText,extraLeft,extraRight,sub,size) {
  this.bodyTag=bodyTag;
  this.nodeType=nodeType;
  this.homeURL=homeURL;
  this.homeText=homeText;
  this.extraLeft=extraLeft;
  this.extraRight=extraRight;
  this.sub=sub;
  this.size=size;
}

function subnode(image,URL,text,sub,size) {
  this.image=image;
  this.URL=URL;
  this.text=text;
  this.sub=sub;
  this.size=size;
}

function viewTree(console) {
  var i;
  /*console.write("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD VALIGN=TOP>");
  if (path[0]!=-1) console.write("<A HREF=\"javascript:top.click(0,-1)\"><IMG SRC=\"images/minus.gif\" BORDER=0></A>");
  else console.write("<A HREF=\"javascript:top.click(0,0)\"><IMG SRC=\"images/plus.gif\" BORDER=0></A>");
  if (root.nodeType==0) console.write("<A HREF=\""+root.homeURL+"\" STYLE=\"text-decoration:none; font-size: 10pt;\" TARGET=\"ViewFrame\"><IMG SRC=\"images/home.gif\" BORDER=0></A></TD><TD WIDTH=100%><A HREF=\""+root.homeURL+"\" STYLE=\"text-decoration:none; font-size: 10pt;\" TARGET=\"ViewFrame\">"+root.extraLeft+root.homeText+root.extraRight+"</A><BR>\n");
  else console.write("<A HREF=\""+root.homeURL+"\" TARGET=\"ViewFrame\"><IMG SRC=\"images/home.gif\" BORDER=0 ALT=\""+root.homeText+"\"></A><BR>\n");
  console.write("</TD></TR></TABLE>");*/
  if (path[0]!=-1) for(i=0;i<root.size;i++) {
    viewSubtree(console,root.sub[i],1,i);
  }
}

function viewSubtree(console,tree,level,j) {
  var i;
  console.write("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=><TR><TD VALIGN=TOP>");
  for(i=0;i<level;i++) console.write("&nbsp;&nbsp;");
  if (tree.sub!=null)
    if (path[level]==j) console.write("<A HREF=\"javascript:top.click("+level+",-1)\"><IMG SRC=\"images/minus.gif\" BORDER=0></A>");
    else console.write("<A HREF=\"javascript:top.click("+level+","+j+")\"><IMG SRC=\"images/plus.gif\" BORDER=0></A>");
  else
    console.write("<IMG SRC=\"images/empty.gif\" BORDER=0>");
  if (root.nodeType==0) console.write("<A HREF=\""+tree.URL+"\" STYLE=\"text-decoration:none; font-size: 10pt;\" TARGET=\"ViewFrame\"><IMG SRC=\""+tree.image+"\"c BORDER=0></A></TD><TD WIDTH=100%><A HREF=\""+tree.URL+"\" STYLE=\"text-decoration:none; font-size: 10pt;\" TARGET=\"ViewFrame\">"+root.extraLeft+tree.text+root.extraRight+"</A><BR>\n");
  else console.write("<A HREF=\""+tree.URL+"\" TARGET=\"ViewFrame\"><IMG SRC=\""+tree.image+"\"c BORDER=0 ALT=\""+tree.text+"\"></A><BR>\n");
  console.write("</TD></TR></TABLE>");
  if (path[level]==j) if (tree.sub!=null) {
    for(i=0;i<tree.size;i++) {
      viewSubtree(console,tree.sub[i],level+1,i)
    }
  }
}

function refresh() {
  console=top.TreeFrame.document;
  console.open();
  console.write(root.bodyTag);
  viewTree(console);
  console.close();
}

function click(level,val) {
  var i;
  path[level]=val;
  if (val==-1) for(i=level;i<10;i++) path[i]=-1;
  refresh();
}

