//  photo_menu.js
//
//  Code for building the menu at the top of the Conclave photo pages.
//--------------------------------------------------------------------

function errmsg(msg, url, line) {
  var txt;
  txt = "Javascript error has occurred\n";
  txt += "Error message: " + msg + "\n";
  txt += "URL: " + url + "\n";
  txt += "Line #: " + line ;
  alert(txt);
  return true;
}

window.onerror=errmsg;

function build_photo_menu(menu_num) {
  // "menu_num" is the menu to be highlighted. 
  // If menu_num = 0, we are on the index page.
  // If menu_num > 0, we are on one of the photo pages, and we need to prepend
  // a path to get to another photo page or back to the index.
  var title     = ["Index", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009"];
  var link      = ["conclave_photos.html", "conc01/a00.html",  "conc02/a00.html",  "conc03/a00.html",  "conc04/a00.html",
                   "conc05/a00.html",  "conc06/a00.html",  "conc07/a00.html",  "conc08/a00.html",
		   "conc09/a00.html"]; 
  var n_items = title.length;
  var item_num;
  var class1, class2, class3;
  var path
  if (menu_num === 0) {
    class2 = "class=\"tmSelected\"";
    path = "";
  } else {
    class2 = ""
    path = "../";
  }
  document.writeln();
  document.writeln('          <div id="top_menu_background_1">');
  document.writeln('            <ul class="top_menu_left">');
  document.writeln('              <li ' + class2 + '><a href=' + path + link[0] + '>' + title[0] + '</a></li>');
  document.writeln('            </ul>');
  document.writeln('            <ul class="top_menu_right">');
  for (item_num=n_items-1; item_num>=1; item_num--) {
    class1 = "";
    class2 = "";
    if (item_num === n_items-1)   {class1 = "rmi";}
    if (menu_num === item_num)    {class2 = "tmSelected";}
    class3 = class1 + ' ' + class2;
    if (class3.length > 1) {class3 = "class=\"" + class3 + "\"";}
    document.writeln('                <li ', class3, '><a href="', path, link[item_num], '">',  
      title[item_num],  '</a></li>');
  }
  document.writeln('             </ul>  <!-- end of top_menu -->');
  document.writeln('        <div style="clear:both"></div>');
  document.writeln('          </div> <!-- end top_menu_background_1 -->');

} // end build_photo_menu

