//menu bar class
function menuBar(aTextSize, aWidth){
  this.menuElements = new Array();
  this.count = 0;
  this.menuWidth = aWidth;
  this.textSize = aTextSize;
}

function menuBar_addElement(theElement){
  this.menuElements[this.count] = theElement;
  this.count++;
}
menuBar.prototype.addElement = menuBar_addElement;

function menuBar_print(activeList){
  document.write("<table width=" + this.menuWidth + " border=0 cellpadding=3 cellspacing=3>");
  for(this.i=0;this.i<this.count;this.i++){
    this.menuElements[this.i].print(this.textSize, this.menuWidth, activeList);
  }
  document.write("</table>");
}
menuBar.prototype.print = menuBar_print;

function menuBar_printLocation(activeList, homeP){
  document.write("<table width=\"100%\" border=0 bgcolor=\"#1E2160\" celpadding=3 cellspacing=3><tr><td>");
  document.write("<font face=\"arial\" size=3 color=\"#FFFFFF\">");
  document.write("You are Here : <a href=\"" + homeP + "\">Home</a>>");
  for(this.x=0;this.x<this.menuElements.length;this.x++){
    for(this.y=0;this.y<activeList.length;this.y++){
      if(this.menuElements[this.x].pageID == activeList[this.y]){
        this.menuElements[this.x].printLocation(activeList);
      }
    }
  }
  document.write("</font></td></tr></table>");
}
menuBar.prototype.printLocation = menuBar_printLocation;

//menu buton class
function menuButton(aURL, aTitle, aPageID){
  this.theURL = aURL;
  this.theTitle = aTitle;
  this.isCurrent = new Boolean(false);
  this.pageID = aPageID;
  this.inSub = new Boolean(false);
}

function menuButton_print(textSize, elementWidth, activeList){
  for(this.k=0;this.k<activeList.length;this.k++){
    if(activeList[this.k]==this.pageID){
      this.isCurrent = true;
    }
  }
  document.write("<tr bgcolor=\"#1E2160\"><td>");
  if(this.isCurrent==true){
    document.write("<font face=\"arial\" color=\"#FFFFFF\" size = " + textSize + ">");
    if(this.inSub == true){
      document.write("- ");
    }
    document.write(this.theTitle);
  }else{
    document.write("<font face=\"arial\" size = " + textSize + ">");
    if(this.inSub == true){
      document.write("- ");
    }
    document.write("<a href=\"" + this.theURL + "\">");
    document.write(this.theTitle);
    document.write("</a>");
  }
  document.write("</font></td></tr>");
}
menuButton.prototype.print = menuButton_print;


function menuButton_printLocation(activeList){
  document.write(this.theTitle);
}
menuButton.prototype.printLocation = menuButton_printLocation;


//menuSubMenu class
function menuSubMenu(aURL, aTitle, aSectionID){
  this.theURL = aURL;
  this.theTitle = aTitle;
  this.subMenuElements = new Array();
  this.count = 0;
  this.isCurrent = new Boolean(false);
  this.pageID=aSectionID;
  this.inSub = new Boolean(false);
}

function menuSubMenu_addElement(theElement){
  this.subMenuElements[this.count] = theElement;
  this.subMenuElements[this.count].inSub = true;
  this.count++;
}
menuSubMenu.prototype.addElement = menuSubMenu_addElement;

function menuSubMenu_print(textSize, elementWidth, activeList){
  for(this.k=0;this.k<activeList.length;this.k++){
    if(activeList[this.k] == this.pageID){
      this.isCurrent = true;
    }
  }
  document.write("<tr bgcolor=\"#1E2160\"><td>");
  if(this.isCurrent==true){
   //make a title
    document.write("<font face=\"arial\" color=\"#FFFFFF\" size = " + textSize + ">");
    document.write("- " + this.theTitle);
    document.write("</font></td></tr><tr><td align=\"right\">");
    //print the sub menu
    document.write("<table width=" + (elementWidth - 20) + " border=0 cellpadding=3 cellspacing=3>");
    for(this.i=0;this.i<this.count;this.i++){
      this.subMenuElements[this.i].print(textSize-1, elementWidth-20, activeList);
    }
    document.write("</table>");
    document.write("</td></tr>");
    document.write("<tr><td height=5></td></tr>")
  }else{
    document.write("<font face=\"arial\" size = " + textSize + ">");
    document.write("<a href=\"" + this.theURL + "\">");
    document.write("+ " + this.theTitle);
    document.write("</a>");
    document.write("</font>");
    document.write("</td></tr>");
  }
}
menuSubMenu.prototype.print = menuSubMenu_print;

function menuSubMenu_printLocation(activeList){
  document.write("<a href=\"" + this.theURL + "\">" + this.theTitle + "</a>>");
  for(this. x=0;this.x<this.subMenuElements.length;this.x++){
    for(this.y=0;this.y<activeList.length;this.y++){
      if(this.subMenuElements[this.x].pageID == activeList[this.y]){
        this.subMenuElements[this.x].printLocation(activeList);
      }
    }
  }
}
menuSubMenu.prototype.printLocation = menuSubMenu_printLocation;


