
// Object constructor
function diaryEntry(day, month, year,  date, event)
{
   this.day = day;
   this.month = month;
   this.year = year;
   this.date = date; 
   this.event = event;
}

// this function builds the table component of the page
function display_diary()
{
	var dPlan = new Array();
	var today = new Date();
	var aday;
	var amonth;
	var ayear;
	var printit; 
	var bgcol;
	
	// set other local variables
	aday = today.getDate();
	amonth = today.getMonth() + 1;
	ayear = today.getFullYear();
	bgcol="#CCCCCC";	
	
	
	
	//THIS IS THE BIT WHERE YOU PUT YOUR DETAILS. THEY WILL THEN BE PRINTED IN A 2 COLUMN TABLE HEADED DATE AND EVENT					
	//THEY MUST BE NUMBERED CONSECUTIVELY AND DATES OF DAYS NEED TWO DIGITS ie "01" NOT "1"	
	
	dPlan[0] = new diaryEntry("05","02","2009","Jan /. Feb 2009","<center>Visit to Durgapur by <br> Rev David Truby, 	Rev Steven Bennett and Rev Camilla Veitch from Wirksworth");
	dPlan[1] = new diaryEntry("20","02","2009","Jan / Feb 2009","<center>Visit to Patna Diocese by <br>John and Elizabeth Hurfurt 	from Ashbourne");
	dPlan[2] = new diaryEntry("17","05","2009","May 17 2009","<center>Partnership AGM at Wingerworth <br>Lunch at 1.00 pm <br>Business Meeting and Reports at 2.30 pm");
	dPlan[3] = new diaryEntry("25","05","2009","May 2009","<center>Visits from India by <br>a party from Nagpur to 	Allestree and <br>a party from Patna to Ashbourne");
	
	//END OF DETAILS	
	

// set a local variable equal to the length of the array
	var maxEntries=dPlan.length;
	
	// print out the header
	document.write("<table width='100%' border='2'>");
	document.write("<tr align='center'><td>Date</td><td>Event</td></tr>")
	
	// check to see if the row shold be printed.
	for (i=0;i<maxEntries;i++)
	{
		printit=0;
	
		// is the year in the Plan greater than or equal to the current year ?
		if (dPlan[i].year>=ayear)
		{
			// if the year in the Plan is equal to the current year
			if (dPlan[i].year==ayear)
			{
				// is the month in the Plan greater than or equal to the current month 
				if (dPlan[i].month==amonth)
				{
					if (aday>dPlan[i].day)
					{
						printit=0;
					}
					else
					{
						printit=1;
					}
				}
				else
				{
					if (dPlan[i].month>amonth)
					{
						printit=1;
					}
					else
					{
						printit=0;
					}
				}
			}
			else
			{
				printit=1;
			}
		}
		else
		{
			printit=0;
		}
		
		// if the row should be printed
		if (printit==1)
		{
			document.write("<tr bgcolor="+ bgcol + " align='left'><td>" + dPlan[i].date + "</td><td>" + dPlan[i].event + "</td></tr>")
			
			// change bgcol
			if (bgcol=="#CCCCCC")
			{
				bgcol="white";
			}
			else
			{
				bgcol="#CCCCCC";
			}
		}
	}
	
	// close the table
	document.write("</table>");
}