// JavaScript Document

// array holding the text
var daysofweek = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var monthstr = ['January','February','March','April','May','June','July','August','September','October','November','December'];

var monthreplystr = [ 'It\'s only January, and far too early to be thinking of another <span class="greshams">Greshams</span> Christmas Menu, I\'ll need to lose some weight first!',
					  'It\'s only February, and far too early to be thinking of another <span class="greshams">Greshams</span> Christmas Menu, I\'ll need to lose some weight first!',
					  'It\'s only March, and far too early to be thinking of another <span class="greshams">Greshams</span> Christmas Menu, I\'ll need to lose some weight first!',
					  'It\'s only April, and far too warm to be thinking of another <span class="greshams">Greshams</span> Christmas Menu,',
					  'It\'s only May, and far too hot to be thinking of another <span class="greshams">Greshams</span> Christmas Menu,',
					  'It\'s only June, and far too hot to be thinking of another <span class="greshams">Greshams</span> Christmas Menu,',
					  'It\'s July, and far too hot to be thinking of another <span class="greshams">Greshams</span> Christmas Menu,',
					  'It\'s August, and far to warm to be thinking of the <span class="greshams">Greshams</span> Christmas Menu, but should be published very soon,',
					  'It\'s September, so the <span class="greshams">Greshams</span> Christmas Menu should be published very soon,',
					  'It\'s October, so the <span class="greshams">Greshams</span> Christmas Menu should be published very soon,' ];
													 

function promote( event_number )
// function created to decide if the event should continue to be promoted or not
{

	var x 				= new Date();									// create some variables
	var current 		= new Object();									// holding the current month & day
	var performance 	= new Object();									// performance month & day

	current.day 		= x.getDate();									// todays date (number)
	current.month 		= x.getMonth() +1;								// todays month, 0 = january, so increment by 1

	performance.date 	= event_record[event_number][e_performance];	// date field at this location

	performance.day 	= performance.date.substring( 0, 2 );			// strip out the performance - day
	performance.day 	= performance.day *1;							// make sure thses are numbers, not strings
	performance.month 	= performance.date.substring( 3, 5 );			// strip out the performance - month
	performance.month 	= performance.month *1;							// make sure thses are numbers, not strings
	
	performance.active  = false;										// assumed
	
	var current_month	= false;										// assumed
	var future_month	= false;										// assumed
	
	// var current_day  	= false;										// assumed
	// var future_day     	= false;										// assumed	
	
	/*
	document.write( 'event_number: ' + event_number + '<br />' );
	document.write( 'performance month: ' + performance.month + '<br />' );
	document.write( 'current month: ' 	  + current.month + '<br />' );
	document.write( 'performace day: '    + performance.day + '<br />' );
	document.write( 'current day: '       + current.day + '<br />' );	
	*/
	
	if ( performance.month == current.month ) current_month = true; else current_month = false;
	
	// document.write( 'current month: ' + current_month + '<br />' );
	
	if ( performance.month > current.month ) future_month = true; else future_month = false;
	
	// document.write( 'future month: ' + future_month + '<br />' );
	
	if ( future_month == true ) performance.active = true;				// always show events in future months
	
	// document.write( 'performance active: ' + performance.active + '<br />' );

	if (( performance.month == current.month ) && ( performance.day >= current.day )) performance.active = true;

	// if the event is turned off (false) force the performce to false
	if ( event_record[event_number][e_show] == false ) performance.active = false;
		
	// return the correct value of all the flags		
	return event_record[event_number][e_show] = performance.active;
}


function write_ToDayIs()
{
// write the current date in the format, "Today is: Monday, 15th February 2010" 
// array holding the text, first day of the week = 0, sunday



var str = 'th'; // most days of the month end with 'th'

var x = new Date;

if ( x.getDate() == 1 || x.getDate() == 21 ) str = 'st';	// 1st or 21st
if ( x.getDate() == 31 ) str = 'st';						// catch the 31st of the month
if ( x.getDate() == 2 || x.getDate() == 22 ) str = 'nd';	// 2nd or 22nd
if ( x.getDate() == 3 || x.getDate() == 23 ) str = 'rd';	// 3rd or 23rd

document.write( 'Today is: ' + daysofweek[ x.getDay() ] + ', ' + x.getDate() + str + ' ' + monthstr[ x.getMonth() ] );
// document.write( 'Today is: ' + daysofweek[ x.getDay() ] + ', ' + x.getDate() + str + ' ' + monthstr[ x.getMonth() ] + ' ' + x.getFullYear() );
}


function write_partofday()
{
var x = new Date;

// now workout which part of the day it is
var welcomemsg = "Good Morning";

var hh = x.getHours();

if ( hh > 11 ) welcomemsg = "Good Afternoon";	// after 12 O'clock
if ( hh > 17 ) welcomemsg = "Good Evening";	// after 5 O'clock

document.write( ', ' + welcomemsg + '.' );
}


function write_contactanchor( thispage, thisposition )
{
// save all that lengthy code
document.write( '<a href="' + thispage.filename 				// page, file name
			   + '?tab=' + thisposition.tab + '#TabbedPanels1"'	// the tab number of the person/position
			   + ' title="Open the ' + thispage.pagename 	// page title/name
			   + ' page to contact ' + thisposition.forename 	// person's forename
			   +'">' + thisposition.title + '</a>' );			// position title
}



function individual_cost( month )
{
var a = ( membership.individual_annual / 12 ) * month;
// a = Math.round(a*100)/100;
a = a.toFixed(2);
return a;
}


function plus_spouse_cost( month )
{
var b = ( membership.individual_spouse_annual / 12 ) * month;
// b = Math.round(b*100)/100;
b = b.toFixed(2);
return b;
}


function family_cost( month )
{
var c = ( membership.family_annual / 12 ) * month;
// c = Math.round(c*100)/100;
c = c.toFixed(2);
return c;
}


function pensioner_cost( month )
{
var d = ( membership.pensioner_annual / 12 ) * month;
// d = Math.round(d*100)/100;
d = d.toFixed(2);
return d;
}


function pensioner_spouse_cost( month )
{
var e = ( membership.pensioner_spouse_annual / 12 ) * month;
// e = Math.round(e*100)/100;
return e.toFixed(2);
}
