// menu Option object
function option(id, name, type, url, colSpan, iconName, iconImg, iconOver, iconCol, iconAlt) {
   this.id = id;
   this.name   = name;
   this._type  = type || false;
   this.url    = url;
   this.column = colSpan;
   this.iconName   = iconName;
   this.iconImg    = iconImg;
   this.iconOver   = iconOver;
   this.iconColumn = iconCol;
   this.iconAlt    = iconAlt;
};

// Main Menu object
function mainMenu(objName) {
   this.obj = objName;
   this.options = [];
};

// Adds a new node to the node array
mainMenu.prototype.add = function(id, name, type, url, colSpan, iconName, iconImg, iconOver, iconCol, iconAlt) {
   this.options[this.options.length] = new option(id, name, type, url, colSpan, iconName, iconImg, iconOver, iconCol, iconAlt);
};


function buildMainMenu(){

   var s, delimiter;

   delimiter = '  <tr><td colspan="15"><img src="images/menuDelimiter.gif" alt="menuDelimiter" longdesc="#" width="167" height="4"></td></tr>';
   s = ''; //'<table border="0" cellPadding="0" cellSpacing="0" width="167" style="font-family:verdana;font-size:11px;" summary="Layout - Main manu table.">\n';
   
//index=0;
   for (index=0; index<m.options.length; index++) {
      s += delimiter + '\n';
      var mn = m.options[index];
      // menu line
      s += '  <tr onMouseOver="swapImage(\'' + mn.iconName +'\',\'' + mn.iconOver + '\')';
      if (mn._type) { 
         s += ';showMenus(\'' + mn.url + '\',\'on\',\'\')'; 
      }
      s += '" onMouseOut="restoreImage(\'' + mn.iconName +'\')'; 
      if (mn._type) {
         s += ';killMenus(\'' + mn.url + '\')';
      }
      s += '">\n';
      // menu text option
      s += '    <td align=right colspan="'+mn.column+'">';
      if (mn._type) {
         s += '<a href="#">'; }
      else { 
         s += '<a href="' + mn.url + '">'; }
      s += mn.name + '</a></td>\n';
      // menu image option
      s += '    <td align=left colspan="'+mn.iconColumn+'">';
      if (mn._type) {
         s += '<img src="'+mn.iconImg+'" border="0" alt="'+mn.iconAlt+'" longdesc="#" name="'+mn.iconName+'">'; }
      else { 
         s += '<a href="' + mn.url + '"><img src="'+mn.iconImg+'" border="0" alt="'+mn.iconAlt+'" longdesc="#" name="'+mn.iconName+'"></a>'; }
      s += '</td>\n';
      s += '  </tr>\n';
   }


   s += delimiter + '\n';
//   s += '</table>';
//alert(s);

   document.write(s);
}
