
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_music_menu(selected_item) {

  // first row of menu items
  var title1     = ["Printed Music", "Bach",  "Jenkins Fantasias", "Manchester Viol Book", "Teach Your Neighbor"];
  var link1      = ["music_1.html", 
		    "music_6.html",
		    "music_3.html", 
                    "music_4.html", 
		    "music_5.html"
		   ]; 
  // second row of menu item (currently not used)

/*
  var title2     = ["Schenk Nymphe di Rheno"];
  var link2      = ["music_7.html"
                   ];		   
*/
  var n_items
  var item_num;
  var class1, class2, class3;
  
  // Build first row of menu. The first item ("Printed Music") is on the left of
  // the menu bar, all others are in a list to the right.
  if (selected_item === title1[0]) {class2 = "class=\"tmSelected\"";} else {class2 = ""}
  document.writeln();
  document.writeln('      <div id="top_menu_background_1">');
  document.writeln('        <ul class="top_menu_left">');
  document.writeln('          <li ' + class2 + '><a href=' + link1[0] + '>' + title1[0] + '</a></li>');
  document.writeln('        </ul>');
  document.writeln('        <ul class="top_menu_right">');
  n_items = title1.length;
  for (item_num=1; item_num<n_items; item_num++) {
    class1 = "";
    class2 = "";
    if (item_num === 1)    {class1 = "rmi";}
    if (selected_item === title1[item_num]) {class2 = "tmSelected";}
    class3 = class1 + ' ' + class2;
    if (class3.length > 1) {class3 = "class=\"" + class3 + "\"";}
    document.writeln('          <li ' + class3 + '><a href="', link1[item_num], '">', title1[item_num],  '</a></li>');
  }
  document.writeln('        </ul>');
  document.writeln('        <div style="clear:both"></div>');
  document.writeln('      </div> <!-- end top_menu_background_1 -->');


  // Build second row of menu. (currently not used)
/*
  document.writeln();
  document.writeln('      <div id="top_menu_background_2">');
  document.writeln('        <ul class="top_menu_right">');
  n_items = title2.length;
  for (item_num=0; item_num<n_items; item_num++) {
    class1 = "";
    class2 = "";
    if (item_num === 0)        {class1 = "rmi";}
    // the following produces a black bar to the left of the left-most menu item.
    // This was added when Schenk was the only item on the second menu line, and
    // might be removed if more items get added.
    if (item_num === n_items-1)             {class1 = (class1 + " lmi_special");}
    if (selected_item === title2[item_num]) {class2 = "tmSelected";}
    class3 = class1 + ' ' + class2;
    if (class3.length > 1) {class3 = "class=\"" + class3 + "\"";}
    document.writeln('          <li ' + class3 + '><a href="', link2[item_num], '">', title2[item_num],  '</a></li>');
  }
  document.writeln('        </ul>');
  document.writeln('        <div style="clear:both"></div>');
  document.writeln('      </div> <!-- end top_menu_background_2 -->');
*/

} // end build_music_menu


