// Define Meetings
m = new Array();

m[0]  = new meeting(21,  4,  2010, "Full orchestra");
m[1]  = new meeting(28,  4,  2010, "Full orchestra (1st Effingham Scout Hut)");
m[2]  = new meeting(5,   5,  2010, "Full orchestra and splits");
m[3]  = new meeting(12,  5,  2010, "Full orchestra and splits");
m[4]  = new meeting(19,  5,  2010, "Full orchestra");
m[5]  = new meeting(26,  5,  2010, "Full orchestra and splits");
m[6]  = new meeting(2,   6,  2010, "Half term");
m[7]  = new meeting(9,   6,  2010, "Full orchestra (1st Effingham scout hut)");
m[8]  = new meeting(16,  6,  2010, "Full orchestra and splits");
m[9]  = new meeting(23,  6,  2010, "Full orchestra (1st Effingham scout hut)");
m[10] = new meeting(26,  6,  2010, "Performance at Effingham Village Day");
m[11] = new meeting(30,  6,  2010, "Summer Concert 6pm Rehearsal 7.15pm Concert");


// Make the frame replace itself with the HTML which describes the
// next meeting. The user will never know it was generated by
// JavaScript! (at least under Netscape, MIE seems to allow you to see
// the source :-( ...as does Netscape6/Mozilla - oh well!

displayNextMeeting();


function displayNextMeeting()
{
//   doc = open("","");

   // Find next meeting
   var nextMeet = new nextMeeting();
   var simpledate = new simplifyDate(nextMeet.date);
   
   // And write it out
   document.writeln("<div id='nextmeet'>");
   document.writeln("<span class='meetdate'>");
   document.writeln(simpledate.text);
   document.writeln("</span> - ");
   document.writeln("<span class='meettitle'>");
   document.writeln(nextMeet.title);
   document.writeln("</span>");
   document.writeln("</div>");
}

function meeting(day, month, year, title)
{
   this.date = new Date(year, month-1, day, 18, 0, 0);
   this.title = title;
}

function simplifyDate(datestr)
{
   var month = new Array();
   month[0] = "Jan";
   month[1] = "Feb";
   month[2] = "Mar";
   month[3] = "Apr";
   month[4] = "May";
   month[5] = "Jun";
   month[6] = "Jul";
   month[7] = "Aug";
   month[8] = "Sep";
   month[9] = "Oct";
   month[10] = "Nov";
   month[11] = "Dec";

   if(datestr == "")
   {
      this.text = "";
   }
   else
   {
      var year = datestr.getYear();

      // Some MIE versions give a 2 digit year. Other versions of MIE
      // and older Netscapes give a 4 digit year while Netscape 4.70 gives
      // years since 1900 (i.e. 2000 ==> 100) !!!!
      if(year < 80)
      {
         year += 2000;
      }
      else
      {
         if(year < 1900)
         {
            year += 1900;
         }
      }
      this.text = datestr.getDate() + "-" + month[datestr.getMonth()] + "-" + year;
   }
}

function nextMeeting()
{
   var today = new Date();

   this.date = "";
   this.title = "Sorry, meetings for the new term have not yet been scheduled";
//   this.title = "Meetings are proceeding as normal, but the webmaster has not been updated!";

   for(var i in m)
   {
      if(m[i].date.getTime() >= today.getTime())
      {
         this.date = m[i].date;
         this.title = m[i].title;
         break;
      }
   }
}

