
// initialize a few variables (don't change these unless you're sure about it.)
var indicator = new indicatorObj("indicator.gif", "spacer.gif", 8, 8);
var indNum = 0;
var itemSeperation = 4;
var menusLoaded = false;
var leftSpace = (screen.availWidth - 800)/2;


// ---------------------------------------------------------------------------------------------------------------------------------------------------
// CUSTOMIZABLE AREA
// ---------------------------------------------------------------------------------------------------------------------------------------------------


// ------------------------------------------------
// define Menus
// ------------------------------------------------
//
//  (menuId, menuLevel, top, left, width, bgcolor, rightmost)
//
//  parameters:
//    menuId = name of menu
//    menuLevel = heirarchical level (0=top, 1=submenu)
//    top = y coordinate of top left corner of menu (relative to top of window, in pixels)
//    left = x coordinate of top left corner of menu (relative to left side of window, in pixels)
//    width = width of menu (pixels)
//    bgcolor = background color of menu (hexadecimal)
//    rightmost = position of menu (rightmost menu = 1, all others = 0(optional))
//
   // samples:
   // menusList["aMenu"] = new createMenuObj("aMenu", 0, top, left, width, "#bgcolor", rightmost);
   // menusList["aSubMenu"] = new createMenuObj("aSubMenu", 1, top, left, width, bgcolor);
   // 
   // the entries below are shown with names like "firstSubMenuOfFirstMenu", but these should
   // be customized to reflect the content of the menus. The names should not have spaces, slashes
   // or other special characters and they must be entered accurately from instance to instance.
//alert(leftSpace);
var menusList = new Array();
menusList["firstMenuName"] = new createMenuObj("firstMenuName", 0, 115, leftSpace + 133, 160, "#FF6600", 0);

menusList["secondMenuName"] = new createMenuObj("secondMenuName", 0, 115, leftSpace + 266, 200, "#FF6600", 0);

menusList["thirdMenuName"] = new createMenuObj("thirdMenuName", 0, 115, leftSpace + 433, 120, "#FF6600", 0);

menusList["fourthMenuName"] = new createMenuObj("fourthMenuName", 0, 115, leftSpace + 573, 200, "#FF6600", 0);
menusList["firstSubMenuOfFourthMenu"] = new createMenuObj("firstSubMenuOfFourthMenu", 1, 130, leftSpace + 453, 120, "#FF6600");






// ------------------------------------------------
// define Menu Items
// ------------------------------------------------
//
// (sepType, text, URL, showSub)
//
// parameters:
//   sepType = show a separator  line (1=no, 2=yes)
//   text = text to appear in menu (treated as standard html text
//   URL = target of link (use "#" if item spawns a submenu)
//         to open a link in the external page frameset, use the following syntax for the URL parameter:
//              "JavaScript: void openExtFrames('location')"
//   showSub = menuId of submenu (optional)
//
   // There must be an array for each of the menus defined above. The menu name must match exactly.
   // The text for each of the menu items is "Menu Item", but should be customized to reflect what
   // you want to see in the menu, like "News" or "Project Status".


with (menusList["firstMenuName"])
{ items[0] = new createMenuItem(2, "Aims and Objectives", "objectives.asp");
  items[1] = new createMenuItem(2, "Code of Ethics", "ethics.asp");
}

with (menusList["secondMenuName"])
{ items[0] = new createMenuItem(2, "Our Contact Information", "contact.asp");
  items[1] = new createMenuItem(2, "Submit Request or Feedback", "feedback.asp");
}

with (menusList["thirdMenuName"])
{ items[0] = new createMenuItem(2, "Our Services", "services.asp");
  items[1] = new createMenuItem(2, "Types of Client", "clients.asp");
}

with (menusList["fourthMenuName"])
{ items[0] = new createMenuItem(2, "Trucks Sales and Rental", "#", "firstSubMenuOfFourthMenu");
  items[1] = new createMenuItem(2, "Safety Equipment Accessories", "accessories.asp");
}

with (menusList["firstSubMenuOfFourthMenu"])
{ items[0] = new createMenuItem(2, "Truck Rental", "rental.asp");
  items[1] = new createMenuItem(2, "Truck Sales", "sales.asp");
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------
// END OF CUSTOMIZABLE AREA
// ---------------------------------------------------------------------------------------------------------------------------------------------------



function createMenuObj(menuId, menuLevel, top, left, width, bgcolor, rightmost)
{ this.menuId = menuId;
// default menuLevel = 0
  if (!menuLevel || menuLevel == "")
    this.menuLevel = 0;
  else
    this.menuLevel = menuLevel;
// default top = 79
  if (!top || top == "")
    this.top = 79;
  else
    this.top = top;
// default left = 100
  if (!left || left == "")
    this.left = 100;
  else
    this.left = left;
// default width = 125
  if (!width || width == "")
    this.width = 125;
  else
    this.width = width;
// default bgcolor = white
  if (!bgcolor || bgcolor == "")
    this.bgcolor = "#FFFFFF";
  else
    this.bgcolor = bgcolor;
// default rightmost = 0
  if (!rightmost || rightmost == "")
    this.rightmost = 0;
  else
    this.rightmost = rightmost;
  this.items = new Array();
}

function createMenuItem(sepType, text, URL, showSub)
{ this.sepType = sepType;
  this.text = text;
  this.URL = URL;
  this.showSub = showSub;
}

createMenuObj.prototype.genMenu = function()
{ if (this.menuLevel == 0)
    genTopMenu(this.width, this.menuId, this.bgcolor, this.items, this.rightmost)
  else
    genSubMenu(this.width, this.menuId, this.bgcolor, this.items)
}
/*original code
function genTopMenu(width, menuId, bgcolor, items, rightmost)
{ var contentWidth = width - 2 - (2 * indicator.width);
  var textOut = "";

// layer declaration
  textOut += '<div id="' + menuId + '" class="dropdown"><table width="' + width + 'px" border="0" cellspacing="0" cellpadding="0" vspace="0" hspace="0">\n\n';

// top table row (above text)
  textOut += '<tr><td width="2px" rowspan="' + (items.length * 2) + '" background="' + image_folder + 'menu_vert.gif"><img src="' + image_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td>';
  textOut += '<td bgcolor="' + bgcolor + '" width="' + indicator.width + 'px"><img src="' + image_folder + 'spacer.gif" width="' + indicator.width + '" height="6" alt="" border="0"></td>';
  textOut += '<td bgcolor="' + bgcolor + '" width="' + contentWidth + 'px"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="6" alt="" border="0"></td>';
  if (rightmost == 1)
     textOut += '<td bgcolor="#FFFFFF" width="' + indicator.width + 'px"><img src="' + image_folder + 'menu_tr.gif" width="' + indicator.width + '" height="6" alt="" border="0"></td>';
  else
     textOut += '<td bgcolor="' + bgcolor + '" width="' + indicator.width + 'px"><img src="' + image_folder + 'spacer.gif" width="' + indicator.width + '" height="6" alt="" border="0"></td>';  
  textOut += '</tr>\n\n';

// item rows
  for (i = 0; i < items.length; i++)
  { textOut += '<tr valign="top" bgcolor="' + bgcolor + '">';
    if (items[i].URL == 2)
      textOut += showHeader(contentWidth, items[i].text);
    else
    { textOut += showItem1(contentWidth, items[i].URL, items[i].text) + 'clearCurrent2(\'' + items[i].showSub + '\');';
      textOut += showItem2(items[i].showSub, items[i].URL, items[i].text);

      textOut += '<td width="' + indicator.width + 'px" valign="middle">';
      if (items[i].showSub)
        textOut += '<a href="#" onMouseover="changeImage(\'ind' + indNum + '\', \'ind_on\'); clearCurrent2(\'' + items[i].showSub + '\'); showMenu(\'' + items[i].showSub + '\');" onMouseout="changeImage(\'ind' + indNum + '\', \'ind_off\'); initCheckMenu();" onClick="return false;"><img src="' + image_folder + 'indicat_sub.gif" width="' + indicator.width + '" height="' + indicator.height + '" alt="" border="0"></a>';
      else
        textOut += '<img src="' + image_folder + 'spacer.gif" width="1" height="1" alt="" border="0">';
      textOut += '</td></tr>\n\n';

      indNum++;
    }
    if (i < items.length - 1)
      textOut += showSeparator(items[i].sepType, bgcolor, width);
  }
  
// bottom table row (below text)
  textOut += '<tr><td colspan = "2"><img src="' + image_folder + 'menu_bl2.gif" width="10" height="6" alt="" border="0"></td>';
  textOut += '<td width="' + contentWidth + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="1" alt="" border="0"></td>';
  textOut += '<td width="' + indicator.width + 'px" align="right"><img src="' + image_folder + 'menu_br.gif" width="8" height="6" alt="" border="0"></td></tr>\n\n';



  textOut += '</table></div>\n\n';
  document.write(textOut);
}
*/

function genTopMenu(width, menuId, bgcolor, items, rightmost)
{ var contentWidth = width - 4 - (indicator.width);
  var textOut = "";

// layer declaration
  textOut += '<div id="' + menuId + '" class="dropdown"><table width="' + width + 'px" border="0" cellspacing="0" cellpadding="0" vspace="0" hspace="0">\n\n';

// top table row (above text)
  textOut += '<tr><td height="2px" colspan="4" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td></tr>';
  textOut += '<tr><td width="2px" rowspan="' + (items.length * 2) + '" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td>';
  textOut += '<td bgcolor="' + bgcolor + '" width="' + indicator.width + 'px"><img src="' + image_folder + 'spacer.gif" width="' + indicator.width + '" height="6" alt="" border="0"></td>';
  textOut += '<td bgcolor="' + bgcolor + '" width="' + contentWidth + 'px"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="6" alt="" border="0"></td>';
  if (rightmost == 1)
     textOut += '<td bgcolor="#FFFFFF" width="2px"><img src="' + image_folder + 'spacer.gif" width="1" height="6" alt="" border="0"></td>';
  else
     textOut += '<td bgcolor="black" width="2px"><img src="' + image_folder + 'spacer.gif" width="1" height="6" alt="" border="0"></td>';  
  textOut += '</tr>\n\n';

// item rows
  for (i = 0; i < items.length; i++)
  { textOut += '<tr valign="top" bgcolor="' + bgcolor + '">';
    if (items[i].URL == 2)
      textOut += showHeader(contentWidth, items[i].text);
    else
    { textOut += showItem1(contentWidth, items[i].URL, items[i].text) + 'clearCurrent2(\'' + items[i].showSub + '\');';
      textOut += showItem2(items[i].showSub, items[i].URL, items[i].text);

      textOut += '<td width="2px" valign="middle" bgcolor="black">';
      if (items[i].showSub)
        textOut += '<a href="#" onMouseover="changeImage(\'ind' + indNum + '\', \'ind_on\'); clearCurrent2(\'' + items[i].showSub + '\'); showMenu(\'' + items[i].showSub + '\');" onMouseout="changeImage(\'ind' + indNum + '\', \'ind_off\'); initCheckMenu();" onClick="return false;"><img src="' + image_folder + 'indicat_sub.gif" width="1" height="' + indicator.height + '" alt="" border="0"></a>';
      else
        textOut += '<img src="' + image_folder + 'spacer.gif" width="1" height="1" alt="" border="0">';
      textOut += '</td></tr>\n\n';

      indNum++;
    }
    if (i < items.length - 1)
      textOut += showSeparator(items[i].sepType, bgcolor, width);
  }
  
// bottom table row (below text)
  textOut += '<tr><td bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="1" height="6" alt="" border="0"></td><td bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="1" height="6" alt="" border="0"></td>';
  textOut += '<td width="' + contentWidth + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="1" alt="" border="0"></td>';
  textOut += '<td width="2px" align="right" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="1" height="6" alt="" border="0"></td></tr>';
  textOut += '<tr><td height="2px" colspan="4" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td></tr>\n\n';


  textOut += '</table></div>\n\n';
  document.write(textOut);
}

/*original code
function genSubMenu(width, menuId, bgcolor, items)
{ var contentWidth = width - 4 - (2 * indicator.width);
  var textOut = "";

  textOut += '<div id="' + menuId + '" class="dropdown"><table width="' + width + 'px" border="0" cellspacing="0" cellpadding="0" vspace="0" hspace="0">\n\n';

  textOut += '<tr><td width="4px" rowspan="' + (items.length * 2 + 1) + '" background="' + image_folder + 'menu_shad.gif" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="4" height="1" alt="" border="0"></td>';
  textOut += '<td width="' + indicator.width + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + indicator.width + '" height="1" alt="" border="0"></td>';
  textOut += '<td width="' + contentWidth + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="1" alt="" border="0"></td>';
  textOut += '<td width="' + indicator.width + 'px" align="right"><img src="' + image_folder + 'menu_tr.gif" width="8" height="6" alt="" border="0"></td>';
  textOut += '</tr>\n\n';

  for (i = 0; i < items.length; i++)
  { textOut += '<tr valign="top" bgcolor="' + bgcolor + '">';
    if (items[i].URL == 2)
      textOut += showHeader(contentWidth, items[i].text);
     else
    { textOut += showItem1(contentWidth, items[i].URL, items[i].text);
      textOut += showItem2(items[i].showSub, items[i].URL, items[i].text);
      textOut += '<td width="' + indicator.width + 'px" valign="middle"><img src="' + image_folder + 'spacer.gif" width="1" height="1" alt="" border="0"></td>\n';
      textOut += '</tr>\n\n';
    
      indNum++;
    }
    if (i < items.length - 1)
      textOut += showSeparator(items[i].sepType, bgcolor, width);
  }

  textOut += '<tr><td width="' + indicator.width + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="6" height="6" alt="" border="0"></td><td width="' + contentWidth + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="1" alt="" border="0"></td><td width="' + indicator.width + 'px" align="right"><img src="' + image_folder + 'menu_br.gif" width="8" height="6" alt="" border="0"></td></tr>\n\n';

  textOut += '</table></div>\n\n';
  //alert(textOut);
  document.write(textOut);
}
*/

function genSubMenu(width, menuId, bgcolor, items)
{ var contentWidth = width - 4 - (indicator.width);
  var textOut = "";

  textOut += '<div id="' + menuId + '" class="dropdown"><table width="' + width + 'px" border="0" cellspacing="0" cellpadding="0" vspace="0" hspace="0">\n\n';

  textOut += '<tr><td height="2px" colspan="4" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td></tr>';
  textOut += '<tr><td width="2px" rowspan="' + (items.length * 2 + 1) + '" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td>';
  textOut += '<td width="' + indicator.width + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + indicator.width + '" height="1" alt="" border="0"></td>';
  textOut += '<td width="' + contentWidth + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="1" alt="" border="0"></td>';
  textOut += '<td width="2px" align="right" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="1" height="6" alt="" border="0"></td>';
  textOut += '</tr>\n\n';

  for (i = 0; i < items.length; i++)
  { textOut += '<tr valign="top" bgcolor="' + bgcolor + '">';
    if (items[i].URL == 2)
      textOut += showHeader(contentWidth, items[i].text);
    else
    { textOut += showItem1(contentWidth, items[i].URL, items[i].text);
      textOut += showItem2(items[i].showSub, items[i].URL, items[i].text);
      textOut += '<td width="2px" valign="middle" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="1" height="1" alt="" border="0"></td>\n';
      textOut += '</tr>\n\n';
    
      indNum++;
    }
    if (i < items.length - 1)
      textOut += showSeparator(items[i].sepType, bgcolor, width);
  }

  textOut += '<tr><td width="' + indicator.width + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="6" height="6" alt="" border="0"></td><td width="' + contentWidth + 'px" bgcolor="' + bgcolor + '"><img src="' + image_folder + 'spacer.gif" width="' + contentWidth + '" height="1" alt="" border="0"></td><td width="2px" align="right" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="1" height="6" alt="" border="0"></td></tr>\n\n';
  textOut += '<tr><td height="2px" colspan="4" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="2" height="1" alt="" border="0"></td></tr>';
  textOut += '</table></div>\n\n';
  //alert(textOut);
  document.write(textOut);
}


function showHeader(cwidth, htext)
{ return '<td width="' + indicator.width + 'px" valign="middle"><img src="' + image_folder + 'spacer.gif" width="1" height="1" alt="" border="0"></td><td width="' + cwidth + 'px" valign="middle" class="menuBold">' + htext + '</td><td width="2px" valign="middle" bgcolor="black"><img src="' + image_folder + 'spacer.gif" width="1" height="1" alt="" border="0"></td></tr>\n\n';
}

function showSeparator(type, bgcolor, width)
{ if (type == 2)
    return '<tr bgcolor="black"><td colspan="4" valign="middle" align="center"><img src="' + image_folder + 'gel_btm.gif" width="' + (width - 8) + '" height="1" alt="" border="0" ></td></tr>\n\n';
  else
    return '<tr bgcolor="black"><td colspan="4"><img src="' + image_folder + 'spacer.gif" width="1" height="1" alt="" border="0"></td></tr>\n\n';
}

function showItem1(cwidth, iURL, iText)
{if (iURL.indexOf("Java") == -1)
	var iURL = main_folder + "" + iURL;
 if (iText.indexOf("<img") == -1)
	return '<td width="' + indicator.width + 'px" valign="middle"><img src="' + image_folder + indicator.off + '" width="' + indicator.width + '" height="' + indicator.height + '" alt="" border="0" name="ind' + indNum + '"></td><td width="' + cwidth + '" valign="middle" class="menu"><a href="' + iURL + '" class="menu" onMouseOver="changeImage(\'ind' + indNum + '\', \'ind_on\'); window.status=\'' + iText +'\'; ';
  else
  	return '<td width="' + indicator.width + 'px" valign="middle"><img src="' + image_folder + indicator.off + '" width="' + indicator.width + '" height="' + indicator.height + '" alt="" border="0" name="ind' + indNum + '"></td><td width="' + cwidth + '" valign="middle" class="menu"><a href="' + iURL + '" class="menu" onMouseOver="changeImage(\'ind' + indNum + '\', \'ind_on\'); window.status=\'Stock Info\'; ';
}

function showItem2(showSub, iURL, iText)
{ tOut = "";
  if (showSub)
    tOut += ' showMenu(\'' + showSub + '\');';

  tOut += ' return true;" onMouseout="window.status=\' \'; changeImage(\'ind' + indNum + '\', \'ind_off\');';
  if (showSub)
    tOut += ' initCheckMenu();"';
  else
    tOut += '"';

  if (iURL == "#")
    tOut += ' onClick="return false;">';
  else
    tOut += '>';
  tOut += iText + '</a></td>';
  return tOut;
}

function generateMenus()
{ 
  for (currMenu in menusList)
  { menusList[currMenu].genMenu();
    add2myLayers(currMenu);
  }
}

