//--script to provide functions used to build the upcoming concert calendar

//----Get the current month and year
today = new Date();
thismonth=today.getMonth()+1;
thisyear=today.getFullYear();
thisday=today.getDate();
if (thisyear < 1950) //--compensate for non-y2k browsers
 thisyear = thisyear-1900;
else
 thisyear =thisyear - 2000;
var keymonth = (thisyear*12)+thismonth; //keymonth is number of months since 1/1/2000
var keyday = (keymonth * 35)+thisday;
var thiskeymo;
var relstart = 1
if (site == "RobC") relstart = 200

//--Function to format an upcoming event calendar entry
//------bbmo is the month number
//------bbday id the day of the month
//------bbyr,is the integer year
//------bbvenue is the index into the venue table entry or a string
//------bbcity is the venue city string or index into venue array
//------bbURL is a venue url string or entry into table
//------bbmail is the email address or index into the venue array
//------bbphone is a phine number string or index into the venue array
//------bbother is a string to be added to the last calendar cell
function bbgig(bbmo,bbday,bbyr,bbvenue,bbcity,bbURL,bbmail,bbphone,bbother)
  {
   var thiskeyday = ((((bbyr-2000)*12)+bbmo)*35)+bbday;
   if (thiskeyday > keyday-relstart)
     {
     document.write('<tr>');               //begin calendar entry
     document.write('<td>');               //begin date cell
     document.write(months[bbmo]+' '+bbday+', '+bbyr);  // write the date
     document.write('</td>');
     document.write('<td>');               //begin cell for venue name
     if (isNaN(bbvenue))                   // If venue parameter is not a number
       outname=bbvenue;                    //use string as venue name
     else if (venueURL[bbvenue] =="")      // else if there is no url in the table 
       outname=venuename[bbvenue];         // just use name from array
          else                             //  if there is a url in the table
             outname="<a href='http://"+venueURL[bbvenue]+"'>"+venuename[bbvenue]+"</a>";  //format a link
     document.write(outname);
     document.write('</td>');
     document.write('<td>');               //begin cell for venue city
     if (bbcity == "")                     //if city parameter is null
       outcity= venuecity[bbvenue];       //use venue index into city array
     else if (isNaN(bbcity))              // else if city parameter is a string 
             outcity=bbcity;              // use string as city
          else                            //else 
             outcity=venuecity[bbcity]; // get city from table using passed parameter
     document.write(outcity);
     document.write('</td>');
     document.write('<td>');             // begin contact cell
     outweb="";                          //set cell content fields to null
     outemail="";
     outphone="";
     outcontact = "";
     if (bbURL == "")                     //if URL parameter is null
       outURL= venueURL[bbvenue];       //use venue index into URL array
     else if (isNaN(bbURL))              // else if URL parameter is a string 
             outURL=bbURL;              // use string as URL
          else                            //else 
             outURL=venueURL[bbURL]; // get URL from table using passed parameter
     if (outURL == "")
         ;
     else
        outcontact="web:<a href='http://"+outURL+"'>"+outURL+"</a>";  //format a web link
     if (bbmail == "")                     //if mail parameter is null
       outURL= venuemail[bbvenue];       //use venue index into email array
     else if (isNaN(bbmail))              // else if mail parameter is a string 
             outURL=bbmail;              // use string as email
          else                            //else 
             outURL=venuemail[bbmail]; // get email from table using passed parameter
     if (outURL == "" || outURL == 'none')
         ;
     else {
        outmail="email:<a href='mailto:"+outURL+"'>"+outURL+"</a>";  //format a mail link
        if (outcontact != "")
          outmail = '<br>'+outmail;
        outcontact = outcontact+outmail;
        }

     if (bbphone == "")                     //if phone parameter is null
       outphone= venuephone[bbvenue];       //use venue index into phone array
     else if (isNaN(bbphone))              // else if phone parameter is a string 
             outphone=bbphone;              // use string as phone
          else                            //else 
             outphone=venuephone[bbohone]; // get phone from table using passed parameter
     if (outphone == "" || outphone == 'none')
         ;
     else {
        outphone="phone:"+outphone;  //format a phone number
        if (outcontact != "")
          outphone = '<br>'+outphone;
        outcontact = outcontact+outphone;
        }

     outother = bbother;
     if (outother != "") {
        if (outcontact != "")
          outother = '<br>'+outother;
          outcontact = outcontact+outother;
        }

     document.write(outcontact);
     document.write('</td>');
     document.write('</tr>');
     }
  }


