
// 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 - 700)/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, 177, leftSpace, 160, "#FF6600", 0);
//menusList["firstSubMenuOfFirstMenu"] = new createMenuObj("firstSubMenuOfFirstMenu", 1, 98, 389, 124, "#FF6600");
//menusList["secondSubMenuOfFirstMenu"] = new createMenuObj("secondSubMenuOfFirstMenu", 1, 150, 389, 124, "#FF6600");

menusList["secondMenuName"] = new createMenuObj("secondMenuName", 0, 177, leftSpace + 245, 150, "#FF6600", 0);
//menusList["firstSubMenuOfSecondMenu"] = new createMenuObj("firstSubMenuOfSecondMenu", 1, 100, 452, 140, "#298CEF");
//menusList["secondSubMenuOfSecondMenu"] = new createMenuObj("secondSubMenuOfSecondMenu", 1, 117, 452, 134, "#298CEF");
//menusList["thirdSubMenuOfSecondMenu"] = new createMenuObj("thirdSubMenuOfSecondMenu", 1, 135, 452, 124, "#298CEF");

menusList["thirdMenuName"] = new createMenuObj("thirdMenuName", 0, 177, leftSpace + 340, 120, "#FF6600", 0);
//menusList["firstSubMenuOfThirdMenu"] = new createMenuObj("firstSubMenuOfThirdMenu", 1, 100, 452, 140, "#298CEF");

menusList["fourthMenuName"] = new createMenuObj("fourthMenuName", 0, 177, leftSpace + 435, 115, "#FF6600", 0);
//menusList["firstSubMenuOfFourthMenu"] = new createMenuObj("firstSubMenuOfFourthMenu", 1, 100, 452, 140, "#298CEF");

menusList["fifthMenuName"] = new createMenuObj("fifthMenuName", 0, 177, leftSpace + 558, 128, "#FF6600", 0);
//menusList["firstSubMenuOfFifthMenu"] = new createMenuObj("firstSubMenuOfFifthMenu", 1, 111, 686, 124, "#298CEF");
//menusList["secondSubMenuOfFifthMenu"] = new createMenuObj("secondSubMenuOfFifthMenu", 1, 160, 686, 124, "#298CEF");

//menusList["sixthMenuName"] = new createMenuObj("sixthMenuName", 0, 177, 624, 100, "#298CEF", 1);





// ------------------------------------------------
// 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, "Our Present Location", "aboutUs.asp");
  items[1] = new createMenuItem(2, "Our Belief", "belief.asp");
  items[2] = new createMenuItem(2, "World-Wide Locations", "contactUs.asp");
  //items[3] = new createMenuItem(1, "Another Menu Item", "URL");
  //items[4] = new createMenuItem(1, "Fifth Menu Item", "#", "secondSubMenuOfFirstMenu");
  //items[5] = new createMenuItem(1, "6th Item in Menu", "URL");
  //items[6] = new createMenuItem(1, "Last Menu Item", "URL");
}

/* with (menusList["firstSubMenuOfFirstMenu"])
{ items[0] = new createMenuItem(1, "A Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item Two", "URL");
  items[2] = new createMenuItem(1, "Another Menu Item", "URL");
  items[3] = new createMenuItem(1, "Fourth Menu Item", "URL");
  items[4] = new createMenuItem(1, "Last Menu Item", "URL");
}

with (menusList["secondSubMenuOfFirstMenu"])
{ items[0] = new createMenuItem(1, "Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item", "URL");
}
*/

with (menusList["secondMenuName"])
{ items[0] = new createMenuItem(2, "President Message", "founder.asp");
  items[1] = new createMenuItem(2, "Pastor Message", "pastor.asp");
  items[2] = new createMenuItem(2, "Books by the President", "publications.asp");
  //items[3] = new createMenuItem(1, "Menu Item 4", "#", "thirdSubMenuOfSecondMenu");
  //items[4] = new createMenuItem(1, "Menu Item", "URL");
}

/*
with (menusList["firstSubMenuOfSecondMenu"])
{ items[0] = new createMenuItem(1, "Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item", "URL");
}

with (menusList["secondSubMenuOfSecondMenu"])
{ items[0] = new createMenuItem(1, "Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item", "URL");
  items[2] = new createMenuItem(1, "Menu Item", "URL");
  items[3] = new createMenuItem(1, "Menu Item", "URL");
  items[4] = new createMenuItem(1, "Menu Item", "URL");
  items[5] = new createMenuItem(1, "Menu Item", "URL");
  items[6] = new createMenuItem(1, "Menu Item", "URL");
}

with (menusList["thirdSubMenuOfSecondMenu"])
{ items[0] = new createMenuItem(1, "Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item", "URL");
}
*/

with (menusList["thirdMenuName"])
{ items[0] = new createMenuItem(2, "Weekly Program", "weeklyProgram.asp");
  items[1] = new createMenuItem(2, "Upcoming Events", "upcomingEvents.asp");
  //items[2] = new createMenuItem(1, "Menu Item", "URL");
}


with (menusList["fourthMenuName"])
{ items[0] = new createMenuItem(2, "Prayer Request", "prayerRequest.asp");
  items[1] = new createMenuItem(2, "Prayer Point", "prayerPoint.asp");
}


with (menusList["fifthMenuName"])
{ items[0] = new createMenuItem(2, "Login to Site", "login.asp");
  //items[1] = new createMenuItem(1, "2nd Menu Item", "URL");
  //items[2] = new createMenuItem(1, "Menu Item Three", "#", "firstSubMenuOfFifthMenu");
  //items[3] = new createMenuItem(1, "Menu Item 4", "URL");
  //items[4] = new createMenuItem(1, "Fifth Item in Menu", "URL");
  //items[5] = new createMenuItem(1, "Sixth Menu Item", "#", "secondSubMenuOfFifthMenu");
  //items[6] = new createMenuItem(1, "Menu Item", "URL");
  //items[7] = new createMenuItem(1, "Menu Item", "URL");
}
/*
with (menusList["firstSubMenuOfFifthMenu"])
{ items[0] = new createMenuItem(1, "Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item", "URL");
}

with (menusList["secondSubMenuOfFifthMenu"])
{ items[0] = new createMenuItem(1, "Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item", "URL");
  items[2] = new createMenuItem(1, "Menu Item", "URL");
}

with (menusList["sixthMenuName"])
{ items[0] = new createMenuItem(1, "Menu Item", "URL");
  items[1] = new createMenuItem(1, "Menu Item", "URL");
  items[2] = new createMenuItem(1, "Menu Item", "URL");
  items[3] = new createMenuItem(1, "Menu Item", "URL");
  items[4] = new createMenuItem(1, "Menu Item", "URL");
  items[5] = new createMenuItem(1, "Menu Item", "URL");
}
*/

// ---------------------------------------------------------------------------------------------------------------------------------------------------
// 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)
}

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 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 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="' + indicator.width + 'px" valign="middle"><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="' + bgcolor + '"><td colspan="3" valign="middle" align="center"><img src="' + image_folder + 'gel_btm.gif" width="' + (width - 8) + '" height="1" alt="" border="0" vspace="' + itemSeperation + '"></td></tr>\n\n';
  else
    return '<tr bgcolor="' + bgcolor + '"><td colspan="3"><img src="' + image_folder + 'spacer.gif" width="1" height="' + itemSeperation + '" 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);
  }
}

