/**
 * This script writes the next meeting schedule.
 *
 * @author Stanley Kubasek
 * @update 9/11/2008
 *
 * NOTE: If we don't have a meeting on a given Saturday,
 * add that date (mm/dd format) to noMeetingDates variable.
 * 
 * NOTE 2: If we have a meeting in alternate location, modify
 * the alternateMeetingDates variable.
 */

/**
 * MEETING IN A DIFFERENT LOCATION
 * 
 * To add, either edit what's in the alternateMeetingDates variable (below),
 * or add this line below
 * IMPORTANT: leave quotes, brackets, and the comma in place
 * 
 *[ "9/20", "place description" ],
 */ 
var alternateMeetingDates = [

// ADD NEW ONES BELOW THIS LINE
["11/8", "at the Lyndhurst Public Library on 355 Valley Brook Avenue in Lyndhurst, NJ 07071"],
["11/15", "at the Lyndhurst Public Library on 355 Valley Brook Avenue in Lyndhurst, NJ 07071"],


];

/**
 * NO MEETINGS ON THESE DATES
 * 
 * TO ADD: either replace existing text, or add a ", month/day" to the end.
 * IMPORTANT: leave quotes, brackets, commas in place, ie, 
 * var noMeetingDates = new Array( "9/4", "11/28"  );
 */
var noMeetingDates = new Array( "5/28", "6/11", "7/2", "9/3" );

/**
 * MEETING PLACE
 */
var mtgPlace = " at the Rutherford Public Library";

function writeNextMeetingTime() {
document.write( "9:30-11:30AM" );
}

/*** DO NOT EDIT ANYTHING BELOW ***/

function writeNextMeetingDate() {
var weekday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var month = new Array("January","February","March","April","May","June","July", "August", "September", "October", "November", "December")
var d = getNextMeetingDate();

document.write(
weekday[ d.getDay() ] + ", " + 
month[ d.getMonth() ] + " " + 
d.getDate() + ", " + 
getYear(d)); 
}

function getYear(d) {
if (d.getYear() > 2000)
return d.getYear();

return (d.getYear() + 1900);
}

function writeNextMeetingLocation() {
var d = getNextMeetingDate();
var nxtMtgDate = "" + (d.getMonth() + 1) + "/" + d.getDate();

for (var i = 0; i < alternateMeetingDates.length; i++) {
if (alternateMeetingDates[i][0] == nxtMtgDate) {
mtgPlace = alternateMeetingDates[i][1];
}
}
document.write( mtgPlace );

}

function getNextMeetingDate() {
var d = new Date();
d.setDate(d.getDate() + 6 - d.getDay());

var nxtMtgDate = "" + (d.getMonth() + 1) + "/" + d.getUTCDate();

// take into condiration "the no meetings" array and set
// a date according to it

for (var i = 0; i < noMeetingDates.length; i++) {
// if there is not meeting next week
if (noMeetingDates[i] == nxtMtgDate) {
// we have to start over with next week's date
d.setDate(d.getDate() + 7);
nxtMtgDate = "" + (d.getMonth() + 1) + "/" + d.getUTCDate();
}
else {
// we have a meeting
continue; 
}
}

return d;
}
