// Event handling array and functions
// implementing events for day and month

// NOTE: Fix bug in generator that forgets the colon after day.
var events = new Array(
{ month: 5, day: 15, title: "Ladies Section<br />Coffee Morning", times: "Ladies Section Coffee Morning", description: "Gargrave Village Hall<br />£1&#46;50 Coffee and Scone&#45;Cake Stall<br />Proceeds to Gargrave Village Hall"},
{ month: 5, day: 16, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 5, day: 21, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 5, day: 22, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 5, day: 28, title: "Ladies Section<br />Dance For Lions", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance for Lions<br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 5, day: 31, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 6, day: 11, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 6, day: 12, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 6, day: 13, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 6, day: 24, title: "Art Exhibition", times: "Art Exhibition", description: "Gargrave Village Hall"},
{ month: 6, day: 25, title: "Art Exhibition", times: "Art Exhibition", description: "Gargrave Village Hall"},
{ month: 6, day: 26, title: "Art Exhibition", times: "Art Exhibition", description: "Gargrave Village Hall"},
{ month: 6, day: 27, title: "Art Exhibition", times: "Art Exhibition", description: "Gargrave Village Hall"},
{ month: 7, day: 11, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 7, day: 17, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 8, day: 8, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 8, day: 20, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 8, day: 21, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 8, day: 27, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 8, day: 30, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 9, day: 10, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance for Mencap<br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 9, day: 12, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 9, day: 14, title: "Silk Road Mongolia", times: "Starting at 7&#58;30", description: "Slide Show &#47; Lecture&#58; Norma Kendal<br />Gargrave Village Hall  &#40;Contact Frank Laver 01756&#45;749609&#41;<br />Nominal fee charged&#46; Refreshments included&#46;"},
{ month: 9, day: 18, title: "Ladies Section<br />Coffee Morning", times: "Ladies Section Coffee Morning", description: "Gargrave Village Hall<br />£1&#46;50 Coffee and Scone&#45;Cake Stall<br />Proceeds to Royal Institute for the Blind"},
{ month: 9, day: 18, title: "Hobbies And Crafts Weekend", times: "Hobbies and Crafts Weekend", description: "Gargrave Village Hall"},
{ month: 9, day: 19, title: "Hobbies And Crafts Weekend", times: "Hobbies and Crafts Weekend", description: "Gargrave Village Hall"},
{ month: 9, day: 24, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 9, day: 25, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 9, day: 28, title: "National Trust in the North", times: "Starting at 7&#58;30", description: "Slide Show &#47; Lecture&#58; John Bevers<br />Gargrave Village Hall  &#40;Contact Frank Laver 01756&#45;749609&#41;<br />Nominal fee charged&#46; Refreshments included&#46;"},
{ month: 10, day: 8, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 10, day: 10, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 10, day: 12, title: "Bridge over the river Wye", times: "Starting at 7&#58;30", description: "Slide Show &#47; Lecture&#58; Frank Robertshaw<br />Gargrave Village Hall  &#40;Contact Frank Laver 01756&#45;749609&#41;<br />Nominal fee charged&#46; Refreshments included&#46;"},
{ month: 10, day: 23, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 10, day: 26, title: "California to Caledonia", times: "Starting at 7&#58;30", description: "Slide Show &#47; Lecture&#58; Bob Swallow<br />Gargrave Village Hall  &#40;Contact Frank Laver 01756&#45;749609&#41;<br />Nominal fee charged&#46; Refreshments included&#46;"},
{ month: 10, day: 29, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance for Lions<br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 11, day: 9, title: "New England and the Fall", times: "Starting at 7&#58;30", description: "Slide Show &#47; Lecture&#58; Mr &amp; Mrs Kellington<br />Gargrave Village Hall  &#40;Contact Frank Laver 01756&#45;749609&#41;<br />Nominal fee charged&#46; Refreshments included&#46;"},
{ month: 11, day: 12, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 11, day: 14, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 11, day: 23, title: "Tibet ", times: "Starting at 7&#58;30", description: "Slide Show &#47; Lecture&#58; Maralyn Whilwhol<br />Gargrave Village Hall  &#40;Contact Frank Laver 01756&#45;749609&#41;<br />Nominal fee charged&#46; Refreshments included&#46;"},
{ month: 11, day: 27, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"},
{ month: 12, day: 7, title: "Graubunden <br />&#40;SE Switzerland&#41;", times: "Starting at 7&#58;30", description: "Slide Show &#47; Lecture&#58; Ray Wilkinson<br />Gargrave Village Hall  &#40;Contact Frank Laver 01756&#45;749609&#41;<br />Nominal fee charged&#46; Refreshments included&#46;"},
{ month: 12, day: 10, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 12, day: 10, title: "Ladies Section<br />Dance ", times: "8&#58;00 &#45; 12&#58;00", description: "Gargrave Village Hall<br />Dance <br />To reserve tickets call&#58; 01756&#45;749715 or 01756&#45;792107"},
{ month: 12, day: 12, title: "Flea Market", times: "10&#58;00 &#45; 4&#58;00PM", description: "Gargrave Village Hall<br />Contact&#58; Caroline Thompson 01756&#45;749235"},
{ month: 12, day: 18, title: "Modern Sequence Dance", times: "7&#58;30 &#45; 10&#58;30PM", description: "Gargrave Village Hall<br />Contact&#58; <br />John Stevenson 01535&#45;632935<br />Frank Davy 01756&#45;748446"}
);

//{ month: 2, day: 14, title: "Pantomime &#58; Cinderella", times: "7&#58;15 PM", description: "Cinderella at Gargrave Village Hall<br />AdvanceTickets from newsagents from 18th January&#46;<br />Tickets also on the door&#46; Adults £4&#46;00&#44; Concessions £3&#46;00"},
//{ month: 2, day: 15, title: "Pantomime &#58; Cinderella", times: "7&#58;15 PM", description: "Cinderella at Gargrave Village Hall<br />AdvanceTickets from newsagents from 18th January&#46;<br />Tickets also on the door&#46; Adults £4&#46;00&#44; Concessions £3&#46;00"},
//{ month: 2, day: 16, title: "Pantomime &#58; Cinderella", times: "2&#58;15 PM and 7&#58;15 PM", description: "Cinderella at Gargrave Village Hall<br />AdvanceTickets from newsagents from 18th January&#46;<br />Tickets also on the door&#46; Adults £4&#46;00&#44; Concessions £3&#46;00"})

// Fix dates to this year
var thisYear = 2010;
var dayStrings = new Array( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" );
var monthStrings = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" );

function displayEventDate(day, month)
{
var eventDate = new Date();
var dayMod10 = 0;
var daySuffix;

	eventDate.setFullYear(thisYear,month-1,day);

	// Calculate what suffix to add to the day. like 11th, 21st 3rd
	if(day < 10 || day >= 20)
	{
	  dayMod10 = day % 10;
	}
	
	switch(dayMod10)
	{
  case 1:  daySuffix = "st"; break;
  case 2:  daySuffix = "nd"; break;
  case 3:  daySuffix = "rd"; break;
	default: daySuffix = "th";	  
	}

	document.write('<b>'+dayStrings[eventDate.getDay()]+' '+monthStrings[month-1]+' '+day+daySuffix+'</b> ');
}

// Display an event from the table
function displayTableEntry( i )
{
document.write('<table width="500" cellspacing="0" cellpadding="0" class="smalltext">');
document.write('<tr>');
document.write('<td width="100" align="right" valign="top"><b>'+events[i].title+'</b></td>');
document.write('<td width="5"><img src="transdot.gif" width="5" height="2"></td>');
document.write('<td bgcolor="#808080" width="1"><img src="transdot.gif" width="1" height="2"></td>');
document.write('<td width="5"><img src="transdot.gif" width="5" height="2"></td>');
document.write('<td width="389" valign="top"><b>');
displayEventDate(events[i].day, events[i].month);
document.write(events[i].times+'</b><br />');
document.write(events[i].description+'</td>');
document.write('</tr>');
document.write('</table> <img src="greydot.gif" width="500" height="1" vspace="5">');
}

// Display the title for today's events.
function displayTitle()
{
document.write('<table width="500" cellspacing="0" cellpadding="0" CLASS="smalltext">');
document.write('<tr>');
document.write("<td><b>What's On Today</b></td>");
document.write('</tr>');
document.write('</table>');
}

// Display the events that are on today
function displayDay()
{
  var today = new Date();
	title = 1;
  for(i in events)
	{
	  if(events[i].month == (today.getMonth() + 1) && events[i].day == today.getDate())
		{
		  if(title == 1)
			{
			  title--;
				displayTitle();
			}
		  displayTableEntry(i);
		}
	}
}

// Display the events that are on today
function displayFrontPageDay()
{
  var today = new Date();
	title = 1;
	tableStart=1;
  for(i in events)
	{
	  if(events[i].month == (today.getMonth() + 1) && events[i].day == today.getDate())
		{
		  if(tableStart == 1)
			{
			  tableStart--; // Only display this once.
        document.write('<table width="100%" border="1" bgcolor="#0000ff" cellspacing="1" cellpadding="1" CLASS="smalltext">');
        document.write('<tr><td bgcolor="#ffffff">');
			}
		  if(title == 1)
			{
			  title--;
        document.write("<b>What's On Today</b><br />");
			}
      document.write(events[i].title + ": " + events[i].times + "<br />");
		}
	}
	if(tableStart == 0)
	{
	  document.write('<a href="whatsonthismonth.htm">More Details</a>');
    document.write('</tr></table>');
	}
	else
	{
    document.write('<table width="100%" border="1" bgcolor="#0000ff" cellspacing="1" cellpadding="1" CLASS="smalltext">');
    document.write('<tr><td bgcolor="#ffffff">');
	  document.write('<img src="rightarrow_sw.gif" align="left" hspace="5">Take a look at <a href="whatsonthismonth.htm">whats on this month</a>');
    document.write('</tr></table>');
	}
}

// Display the events that are on this month
function displayMonth(month)
{
  var i;
  for(i in events)
	{
	  if(events[i].month == month)
		{
		  displayTableEntry(i);
		}
	}
}
