function DescribeInstrument( Instrument)
{
   if (Instrument == _FIDDLE)
      return "fiddle";   
   if (Instrument == _BANJO)
      return "banjo";   
   if (Instrument == _BASS)
      return "bass";   
   if (Instrument == _MANDOLIN)
      return "mandolin";   
   if (Instrument == _GUITAR)
      return "guitar";
   if (Instrument == _DEFAULT)
      return "default";
   return "Bad instrument number";
}


function Display( inMusician, Instrument, Mon, Day, Year)
{
   // if 'Musician' contains a space, it's a name, otherwise jpg path

   FirstName = inMusician;   // default in case single name
   LastName  = "";
   Musician  = "";

   if (inMusician == "Request")
   {  if (Year < 1900)
         Year += 1900;
   
      var DisplayDate = Mon + " " + Day + ", " + Year;
   
      document.write('<TD valign=top><A HREF="mailto:trlucas@gmail.com?Subject=Taco Jam ' + DisplayDate + 
                     '&Body=Hey Tom, Could I have the ' + DisplayDate + ' ' + DescribeInstrument(Instrument) + ' slot%3F">Request this slot!</A></TD>'); 
      return;
   }
   else if ( inMusician != "" && inMusician.indexOf(' ') == -1)
   {
      for (i=1; i < inMusician.length; i++)
      {  if (inMusician.charAt(i) == ".")
         {   Musician = inMusician.substring(0, i);
             break;
         }
      }

      if (Musician == "")
         Musician = inMusician;

      for (i=1; i < Musician.length; i++)
      {  if (Musician.charAt(i) <= "Z")
         {  FirstName = Musician.substring(0, i);
            LastName = Musician.substring(i, Musician.length);
            break;
         }
      }



      var FullName = FirstName + " " + LastName;
      var CodeName = FirstName + " " + LastName;
      var URLindex = -1;

      for (i=0; i < URLlist.length; i++)
      { if (CodeName == URLlist[i][0])
           URLindex = i;
      }

      var InstrumentDescription = "";
           
      if (URLindex > -1)
      {  var URLrec = URLlist[URLindex];

         if (inMusician.indexOf(".") == -1)
         {  if (Instrument & (URLrec[4]))
            {  if (Instrument & _FIDDLE)
                  InstrumentDescription = ".fiddle";
               else if (Instrument & _BANJO)
                  InstrumentDescription = ".banjo";
               else if (Instrument & _BASS)
                  InstrumentDescription = ".bass";
               else if (Instrument & _MANDOLIN)
                  InstrumentDescription = ".mandolin";
               else if (Instrument & _GUITAR)
                  InstrumentDescription = ".guitar";
            }
         }
      }

      MusicianJPG = "http://sfbluegrass.org/php/pics/" + inMusician + InstrumentDescription + ".jpg";

      if (URLindex == -1 || URLlist[URLindex][1] == "")       // no url associated with this musician, just display pic
         document.write("<TD vAlign=top><IMG SRC='" + MusicianJPG + "' alt='" + FullName + "'></TD>");
      else
      {  if (URLlist[URLindex][1].indexOf(';') == -1)   // only one url associated with this musician
                document.write("<TD vAlign=top><A HREF=" + URLlist[URLindex][1] + "><IMG SRC='" + MusicianJPG + "' alt='" + FullName + "'></A></TD>");
         else   // More than one URL...link to intemediate page
                document.write("<TD vAlign=top><A HREF=http://members.aol.com/BanjoWonk/link.html?" + URLindex + "><IMG SRC='" + MusicianJPG + "' alt='" + FullName + "'></A></TD>");
      }
   }
   else
   {  if (inMusician.substr(0,8) == "Reserved")
      {  document.write("<TD vAlign=top><IMG SRC='http://members.aol.com/BanjoWonk/Reserved.jpg' alt='" +
         "Reserved by " + inMusician.substr(12) + "'></TD>");
      } 
      else
      {  var emailaddy = "";
         var s = inMusician.split("=");
      
         if (s[0] == "booker")
         {  emailaddy = s[1];
            document.write('<TD vAlign=top><A HREF="request.php?email=' + emailaddy + '">Click here to request this slot.</A>');
         }
         else
            document.write("<TD vAlign=top>" + inMusician     + "</TD>");
      }
   }
}

function LineItem( Fiddler, Guitarist, Mandolinist, Banjoist, Bassist)
{

        CurrentDate = new Date();


        LineDate = new Date( LineDate.getTime() + MillisecondsPerWeek);

        if (!Ancient())
        {       if (DisplayingCurrent())
                {       if (CurrentDate.getTime() >= LineDate.getTime())
                           return;
                }
                else
                {       if (CurrentDate.getTime() < LineDate.getTime())
                           return;
                }
        }

        Month = new Array ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

        if ( LineDate.getMonth() % 2) // change background color month to month
           document.write("<TR bgColor=" + GetEvenColor() + ">");
        else
           document.write("<TR bgColor=" + GetOddColor() + ">");

        var Mon = Month[LineDate.getMonth()];

        document.write("<TD vAlign=top>" + Mon + " " + LineDate.getDate() + "</TD>");

        if (Mon == "Jul" && LineDate.getDate() == 4)
                document.write("<TD align=middle colSpan=5><h3>No jam tonight. Happy Independence Day.</h3></TD>");
        else if (Mon == "Sep" && LineDate.getDate() <= 7)
                document.write("<TD align=middle colSpan=5><h3>No jam tonight. Happy Labor Day.</h3></TD>");
        else if (Mon == "Dec" && LineDate.getDate() == 25)
                document.write("<TD align=middle colSpan=5><h3>No jam tonight. Merry Christmas.</h3></TD>");
        else
        {       Display( Fiddler,      _FIDDLE,    Mon, LineDate.getDate(), LineDate.getYear());
                Display( Banjoist,     _BANJO,     Mon, LineDate.getDate(), LineDate.getYear());
                Display( Bassist,      _BASS,      Mon, LineDate.getDate(), LineDate.getYear());
                Display( Mandolinist,  _MANDOLIN,  Mon, LineDate.getDate(), LineDate.getYear());
                Display( Guitarist,    _GUITAR,    Mon, LineDate.getDate(), LineDate.getYear());
        }

        document.write("</TR>");
}
