// jimmyrussell.com.js

// this is the onload for each page, that fills in the
//   common info

function pageload(arg)
{
   clientSideInclude("sidebar", "sidebar.html");

   // build menu bar

   var e_mbar = document.getElementById("menubar");
   var menu = ""
      + "<p align=center>"
      + "Home page of Jim &quot;bjimba&quot; Russell"
      + "<br>";

   if (arg != "main") { menu += "<a href=\"main.html\">"; }
   menu += "[Main]";
   if (arg != "main") { menu += "</a>"; }
   menu += " ";
   if (arg != "music") { menu += "<a href=\"music.html\">"; }
   menu += "[Music]";
   if (arg != "music") { menu += "</a>"; }
   menu += " ";

   if (arg != "roots") { menu += "<a href=\"roots.html\">"; }
   menu += "[Genealogy]";
   if (arg != "roots") { menu += "</a>"; }
   menu += " ";

   if (arg != "theatre") { menu += "<a href=\"theatre.html\">"; }
   menu += "[Theatre]";
   if (arg != "theatre") { menu += "</a>"; }

   e_mbar.innerHTML = menu;
}


function clientSideInclude(id, url)
{
   var req = false;

   // For Safari, Firefox, and other non-MS browsers
   if (window.XMLHttpRequest)
   {
      try
      { req = new XMLHttpRequest(); }
      catch (e)
      { req = false; }
   }
   else if (window.ActiveXObject)
   {
      // For Internet Explorer on Windows
      try
      { req = new ActiveXObject("Msxml2.XMLHTTP"); }
      catch (e)
      {
         try
         { req = new ActiveXObject("Microsoft.XMLHTTP"); }
         catch (e)
         { req = false; }
      }
   }
   var element = document.getElementById(id);
   if (!element)
   {
      alert("Bad id " + id + "passed to clientSideInclude.  "
            + "You need a div or span element "
            + "with this id in your page.");
      return;
   }
   if (req)
   {
      // Synchronous request, wait till we have it all
      req.open('GET', url, false);
      req.send(null);
      element.innerHTML = req.responseText;
   }
   else
   {
      element.innerHTML =
         "Sorry, your browser does not support "
         + "XMLHTTPRequest objects. This page requires "
         + "Firefox, Safari, or (in a pinch) "
         + "Internet Explorer 5 or better.  Other browsers "
         + "may also fit the bill.";
   }
}
