var vEvents = new Array(11);

vEvents[0]  = new Event(2011,3,5,6,   "Rolling Party / Lapeer Living History Show","The Foster's","Mark Foster");
vEvents[1]  = new Event(2011,4,15,17, "Company & Battalion Drill","","Historic Fort Wayne, Detroit","JW Kelly");
vEvents[2]  = new Event(2011,5,13,15, "Walker Tavern",            "", "Brooklyn, MI",  "George Kilbourn");
vEvents[3]  = new Event(2011,6,10,12, "Lexington, MI",            "lexington","Lexington, MI", "John/Kathleen Fredal");
vEvents[4]  = new Event(2011,7,21,25, "Bull Run",                 "manassas", "Manassas, VA ", "Keith Rouse");
vEvents[5]  = new Event(2011,8,12,14, "Wilson's Creek",           "wilsons","Missouri ",     "Rich Firman  (max)");
vEvents[6]  = new Event(2011,8,12,14, "Milford Memories",         "milford","Milford, MI",   "Gordon Peterson  (supplemental for those who can't travel out of state)");
vEvents[7]  = new Event(2011,9,16,18, "Holland, MI",              "holland","Holland, MI",   "John McIntosh  (max)");
vEvents[8]  = new Event(2011,9,23,25, "River of Time",            "baycity","Bay City, MI ", "John Auger  (supplemental)");
vEvents[9]  = new Event(2011,10,7,9,  "Wolcott Mill",             "wolcott","Bruce Twp. MI ","Mary Kay Foster");
vEvents[10] = new Event(2011,11,11,11,"Veteran's Day Parade",     "vd","Royal Oak, MI", "John McIntosh");
vEvents[11]= new Event(2012,1,28,28, "2012 AGM",                  "agm","Lansing,MI",    "Executive Board");

function fcnNextEvent(_year, _month, _day) {

	var sb="";
	
	for(var x=0; x < vEvents.length; x++) {
	
	  if(vEvents[x].getMonth() < _month) continue;
	  if(vEvents[x].getDay() < _day) continue;

	  if(vEvents[x]) {

	    sb = sb + vEvents[x].getYear() + "-" + vEvents[x].getMon() + "-" + vEvents[x].getDay() + ": " + vEvents[x].getEvent();

	    break;
	    
	  } //end 'if' block

	} //end 'for' loop 
	
	return(sb);

} //end fcnNextEvent() method....

/*
** Return a list of events formatted as html table rows
** @return String containing the events
**
*/
function fcnGetEvents() {

	var sb="";
	
	for(var x=0; x < vEvents.length; x++) {
	
	  sb = sb + "      <tr>\n";
	  sb = sb + "        <td>" + vEvents[x].getYear()        + "-" + vEvents[x].getMon() + "-" + vEvents[x].getDay() + "</td>\n";
	  sb = sb + "        <td><a name='" + vEvents[x].getBookmark() + "'>" + vEvents[x].getEvent()       + "</a></td>\n";
	  sb = sb + "        <td>" + vEvents[x].getLocation()    + "</td>\n";
	  sb = sb + "        <td>" + vEvents[x].getFacilitator() + "</td>\n";
	  sb = sb + "        <td>" + vEvents[x].getCampStyle()   + "</td>\n";
	  sb = sb + "      </tr>\n";

	} //end 'for' loop 
	
	return(sb);	

} //end end fcnGetEvents() method...

/*
** Return last event
** 
**
*/
function fcnLastEvent() {

	var x = vEvents.length - 1;
	var sb = vEvents[x].getYear() + "-" + vEvents[x].getMon() + "-" + vEvents[x].getDay() + ": " + vEvents[x].getEvent();
	return(sb);

} //end fcnLastEvent() method...

/*
** return the name of the month that cooresponds to the given number
** @return String containing the month name
** 
*/
function getMonthName(_mon) {

	vMonths = ["No zero","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
	
	return(vMonths[_mon]);	
	
} //end getMonthName() method ...

/*
** purpose: hold event data
** javascript class
**
*/
function Event (_year, _month, _startDay, _endDay, _event, _bookmark, _location, _facilitator) {

	this.year        = _year;
	this.month       = _month;
	this.startDay    = _startDay;
	this.endDay      = _endDay;
	this.event       = _event;
	this.bookmark    = _bookmark;
	this.location    = _location;
	this.facilitator = _facilitator;
	
	this.getYear = function () {
	
		return this.year;
	};

	this.getMonth = function () {

		return this.month;
	};

	this.getMon = function () {

		if(1==this.month)  return "Jan";
		if(2==this.month)  return "Feb";
		if(3==this.month)  return "Mar";
		if(4==this.month)  return "Apr";
		if(5==this.month)  return "May";
		if(6==this.month)  return "Jun";
		if(7==this.month)  return "Jul";
		if(8==this.month)  return "Aug";
		if(9==this.month)  return "Sep";
		if(10==this.month) return "Oct";
		if(11==this.month) return "Nov";
		if(12==this.month) return "Dec";

	};

	this.getDay = function() {

		return this.startDay;
	};
	
	this.getStartDay = function() {

		return this.startDay;
	};

	this.getEndDay = function() {

		return this.endDay;
	};


	this.getEvent = function () {

		return this.event;
	};
	
	this.getBookmark = function() {
	
		return this.bookmark;
	};
	
	this.getLocation = function() {
		
		return this.location;
	
	};
	
	this.getFacilitator = function() {
	
		return this.facilitator;
		
	};
	
	this.getCampStyle = function() {
	
		return("&nbsp;");
	};
	
} //end ThisDay class
