/*********************************************************************/
/* Crofton Pumping Station Web Site JavaScript Library               */  
/* Written for the Crofton Branch of The Kennet & Avon Canal Trust   */ 
/* by Harry. A. Willis of Hungerford UK, a Crofton Branch volunteer  */
/*********************************************************************/


/*********************************************************************************************************
** The variables in the first part of this file define the data that changes on a seasonal basis	**
**													** 
** ONLY USE A TEXT EDITOR (eg MS NotePad.exe) OR A SPECIALISED CODE EDITOR TO CHANGE THIS FILE		**
** DO NOT USE A WORD PROCESSOR!	Be careful to reproduce all quotation marks, semicolons etc.		**
**													**
** DO NOT CHANGE ANYTHING BELOW THE WARNING NOTES UNLESS YOU KNOW WHAT YOU ARE DOING!			**
*********************************************************************************************************/

/*
** Set updateDayNum, updateMonthNum and updateYearNum to the relevant data for the date that the Site was last updated
*/
 
updateDayNum 	= 30;
updateMonthNum 	= 06;
updateYearNum 	= 2010;

/*
** The values for 'thisSeason' and 'nextSeason' MUST be enclosed in quotation marks.
** Set 'thisSeason' to the year number of the current season, UNLESS 'isClosedForWInter' is 'true' IN WHICH CASE 
** set it to  to the year number of the next opening season.
** Set 'nextSeason' to the year number of the next opening season.
*/   

thisSeason 						= "2010";
nextSeason 						= "2010";

/*
** If showNextSeasonsOpeningTimes is 'true' then, when the 'opening times' menu option is selected, a 'click 'here' option
** is provided to display next season's opening times and charges, which MUST BE DEFINED in the relevant section below, also the 
** year number for next season MUST BE DEFINED in 'nextSeason' above..
**
** If isClosedForWinter is 'true' then, when the 'opening times' menu option is selected, a warning message is displayed
** to that effect, and that what is about to be shown is the Next Season's opening times and charges.
** If this flag is set to 'true', then NEXT Season's opening times and charges MUST BE DEFINED in the THIS SEASON variables below
** AND the 'thisSeason' variable above MUST be set to the year number of the NEXT open season!
**
** Update 2nd July 2004
** This seasons running schedule is in the file ornngshedww.html
** Next seasons running schedule is in the file ornngshedwwnext.html
** 
*/

showNextSeasonsOpeningTimes 	= false;
isClosedForWinter		= false;

/*
** Introduced December 2004 - HAW
** The next three variables control the welcome message on the 'intro' page
*/
  
sayHappyXmas 		=false;
sayHappyNewYear		= false;
sayNothing		=false;

/*
**Define here the e:Mail addresses for enquiries and webmaster 
*/

enquiriesAddress = "er23fc45";
webMasterAddress = "wbsc9pen6";

/*
** Change the data in the variable definitions below to reflect the relevent opening times & charges
** Note the use '&amp;' which renderes as an '&' in the code 
*/

thisSeasonOpenDates			= "April 2nd to September 26th";

thisSeasonSteamEaster		= "April 3-4-5(Easter)";
thisSeasonSteamMay			= "May 1-2-3, May 29-30-31";
thisSeasonSteamJune			= "June 26-27";
thisSeasonSteamJuly			= "July 31- August 1";
thisSeasonSteamAugust			= "August 28-29-30";
thisSeasonSteamSeptember		= "September 25-26";

thisSeasonInSteamChargesLine1		= "Adults £8.00, Seniors £7.00, Children £3.00,";
thisSeasonInSteamChargesLine2		= "Families (2 adults &amp; 2 children) £18.00";

thisSeasonNotInSteamChargesLine1	= "Adults £5.00, Seniors £4.50,Children £3.00";
thisSeasonNotInSteamChargesLine2	= "Families (2 adults &amp; 2 children) £12.50 ";

nextSeasonOpenDates			= "April 2nd to September 26th";

nextSeasonSteamEaster			= "April 3-4-5(Easter)";
nextSeasonSteamMay			= "May 1-2-3, May 29-30-31";
nextSeasonSteamJune			= "June 26-27";
nextSeasonSteamJuly			= "July 31- August 1";
nextSeasonSteamAugust			= "August 28-29-30";
nextSeasonSteamSeptember		= "September 25-26";

nextSeasonInSteamChargesLine1		= "Adults £8.00, Seniors £7.00, Children £3.00,";
nextSeasonInSteamChargesLine2		= "Families (2 adults &amp; 2 children) £18.00";

nextSeasonNotInSteamChargesLine1	= "Adults £5.00, Seniors £4.50,Children £3.00";
nextSeasonNotInSteamChargesLine2	= "Families (2 adults &amp; 2 children) £12.50 ";

/*
***************************
** END OF SEASONAL EDITS **
***************************
**
**                                                                                                                
** Unless you need to change the main menue structure, or terms and conditions, THERE SHOULD BE NO NEED            
** TO CHANGE ANYTHING BELOW THIS POINT
*****************************************************************************************************************
*/

/*
******************************************
** Changes to terms and conditions go here
*/
function writeConditions()
{
joinTheTrust();
document.writeln("<p class='footer' align='center'>");
document.writeln("These Admission Charges assume that you are able to sign a Gift Aid donation form <br>");
document.writeln("Alternative entrance fees are posted at the Station for those unable to do this.<br><br>");
document.writeln("Groups must book in advance (see top of page).&nbsp;<br>");
document.writeln("Pets are not allowed in the building.<br>");
document.writeln("Unfortunately, due to the nature of the building,<br>");
document.writeln("access for wheelchairs is severely restricted.</p>");
}

/*
******************************************
** Join The Trust!
*/
function joinTheTrust()
{
document.writeln("<p class='twidth' align='center' style = 'font-weight: bold; font-size: 12pt; color: rgb(255, 0, 0);font-style: italic;'>Join the Kennet & Avon Canal Trust<br>");
document.writeln("and Get In Free As Often As You Like!!<br>");
/*document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");*/
document.writeln("Click <a href=\"javascript:openOneWindow(\'1\',\'jointhetrust.html\',\'winor\')\"> here</a> for more information");
/*document.writeln("Click <a href=\"javascript:openOneWindow(\'1\',\'www.katrust.org\',\'winor\')\"")*/
}
/*
******************************************
** Boiler Rivet Appeal
*/
function boilerRivetAppeal()
{
document.writeln("<p class='twidth' align='center' style = 'font-weight: bold; font-size: 12pt; color: rgb(255, 0, 0);font-style: italic;'>Help Us Raise £10,000 to keep Crofton in Steam<br> ");
document.writeln("Click <a href=\"javascript:openOneWindow(\'2\',\'boilerrivetappeal.html\',\'winriv\')\"> here</a> for more information");
}


/*
******************************************************
** Additions or deletions to the main menu go in here 
** --- BE CERTAIN THAT YOU UNDERSTAND THE LOGIC OF THIS FUNCTION BEFORE YOU MAKE ANY CHANGES
*/
function writeMenue()
{
	/*
	** Writes the main menue. The menue item for the current page has no link and is set in round brackets rather than square ones,
	** decided by the text in the document header tag <title>
	*/
	var windowName = window.name;
	var winBit = windowName.substring(0,3);
	if (winBit != "win")
	{
		document.writeln("<table id='menue' border='1' align='center' class='menue' cellpadding='4' frame='box' style='border-collapse: collapse; border: 1px solid Green;'>");
		if (document.title == "About Crofton Pumping Station")
			{
				document.writeln("<tr><td>(About)</td>");
			}
		else
			{
				document.writeln("<tr><td><a href='about.html' title='Crofton Beam Engines Home'>[About]</a></td>");
			}
		if (document.title == "How To Find Us")
			{
				document.writeln("<td>(Find Us)</td>");
			}
		else
			{
				document.writeln("<td><a href='findus.html' title='Location Map and Directions'>[Find Us]</a></td>");
			}
		if (document.title == "Public Opening Times - Current Year")
			{
				document.writeln("<td>(Opening Times)</td>");
			}
		else
			{
				document.writeln("<td><a href='openingtimes.html' title='Public Opening Times and when we are in Steam '>[Opening Times]</a></td>");
			}
		if (document.title == "History - Home")
			{
				document.writeln("<td>(History)</td>");
			}
		else
			{
				document.writeln("<td><a href='history.html' title='The History of Crofton Pumping Station since the beginning'>[History]</a></td>");
			}
		if (document.title == "Tour Start")
			{
				document.writeln("<td>(Virtual Tour)</td></tr>");
			}
		else
			{
				document.writeln("<td><a href='tour.html' title='A Virtual Tour of the Pumping Station'>[Virtual Tour]</a></td>");
			}
			/* dummy element to even up columns*/
			document.writeln("<td></td></tr>");
			/***********************************/
		if (document.title == "How it Works")
			{ 
				document.writeln("<tr><td>(How it Works)</td>");
			}
		else
			{
				document.writeln("<tr><td><a href='hwhowtworks.html' title='Explanations of how the various parts work'>[How it Works]</a></td>");
			}
		if (document.title == "Interesting Items")
			{
				document.writeln("<td>(Odds &amp Ends)</td>");
			}
		else
			{
				document.writeln("<td><a href='interestingi.html' title='Some Interesting Facts and Anecdotes'>[Odds &amp Ends]</a></td>");
			}
		if (document.title == "Why not Join Us??")
			{
				document.writeln("<td>(Come &amp; Join Us!)</td>");
			}
		else
			{
				document.writeln("<td><a href='joinus.html' title='If you live reasonably near by why not join us?'>[Come &amp; Join Us!]</a></td>");
			}
		/*if (document.title == "Winter Maintenance Work")
			{
				document.writeln("<td>(Winter Work)</td>");
			}
		else
			{
				document.writeln("<td><a href='wintermaintenance.html' title='Winter 2003/4 Maintenance Work'>[Winter Work]</a></td>");
			}
			*/
		
		/*if (document.title == "News")
			{
				document.writeln("<td>(News)</td>");
			}
		else
			{
				document.writeln("<td><a href='news.html' title='News'>[News]</a></td>");
		}*/
		if (document.title == "Links")
			{
				document.writeln("<td>(Links)</td></tr>");
			}
		else
			{
				document.writeln("<td><a href='links.html' title='Links to sites of similar interest'>[Links]</a></td></tr>");
			}
		document.writeln("</table>");
	}
}

/*
************************************************************
************************************************************
** DO NOT EDIT ANY VARIABLES OR FUNCTIONS BELOW THIS LINE **
************************************************************
************************************************************
*/

whichSeason = "";

function writeOpeningTimesForSeason(whichSeason)
{
if (isClosedForWinter)
	{
		alert("The Station is Closed for the Winter - the Opening Times that follow are for the next Season");
		whichSeason = "this"; 
	}
	else
	{
		if (showNextSeasonsOpeningTimes && whichSeason == "this")
			{	
				document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
				document.writeln("Click <a href='openingtimesnextsn.html' title= 'Next Years Opening Times and Charges'><i>here</i></a> for " + nextSeason + "</p>");
			}
	}
if (whichSeason == "this")
	{
		document.writeln("<h2 class='twidth' align='center'>Public Opening Times "+ thisSeason + "</h2>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("The station is open every day except Wednesdays<br>from<br>" + thisSeasonOpenDates + "<br>between<br>10.30 a.m. and 5.00 p.m.<br> (Last Entrance - 4:30 p.m.)</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>The Engines will be In Steam on the following dates:-<br>");
		document.writeln(thisSeasonSteamEaster + "<br>" + thisSeasonSteamMay + "<br>" + thisSeasonSteamJune + "<br>" + thisSeasonSteamJuly + "<br>" + thisSeasonSteamAugust + "<br>" + thisSeasonSteamSeptember + "</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("(Click <a href=\"javascript:openOneWindow(\'1\',\'ornngschedww.html\',\'winor\')\"");
		document.writeln("title='The scheduled start/stop times for each engine '><i>here</i></a> for daily engine running schedule)</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("<i><u>When in Steam,</u></i> Admission charges are:-<br>" + thisSeasonInSteamChargesLine1 + "<br>" + thisSeasonInSteamChargesLine2 + "</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("<i><u>When not in Steam,</u></i> the charges are:-<br>" + thisSeasonNotInSteamChargesLine1 + "<br>" + thisSeasonNotInSteamChargesLine2);
		document.writeln("<br><br> (Children under 5 years old always have free entry)</p>");
		writeConditions();
	}
else
	{
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("Click <a href='openingtimes.html' title= 'Return to Opening Times and Charges for this year'><i>here</i></a> to return to " + thisSeason + "</p>");
		document.writeln("<h2 class='twidth' align='center'>Public Opening Times "+ nextSeason + "</h2>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("The station is open every day except Wednesdays<br>from<br>" + nextSeasonOpenDates + "<br>between<br>10.30 a.m. and 5.00 p.m.</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>The Engines will be In Steam on the following dates:-<br>");
		document.writeln(nextSeasonSteamEaster + "<br>" + nextSeasonSteamMay + "<br>" + nextSeasonSteamJune + "<br>"+ nextSeasonSteamJuly + "<br>" + nextSeasonSteamAugust + "<br>" + nextSeasonSteamSeptember + "</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("(Click <a href=\"javascript:openOneWindow(\'1\',\'ornngschedwwnext.html\',\'winor\')\"");
		document.writeln("title='The scheduled start/stop times for each engine '><i>here</i></a> for daily engine running schedule)</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("<i><u>When in Steam,</u></i> Admission charges are:-<br>" + nextSeasonInSteamChargesLine1 + "<br>" + nextSeasonInSteamChargesLine2 + "</p>");
		document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
		document.writeln("<i><u>When not in Steam,</u></i> the charges are:-<br>" + nextSeasonNotInSteamChargesLine1 + "<br>" + nextSeasonNotInSteamChargesLine2);
		document.writeln("<br><br> (Children under 5 years old always have free entry)</p>");
		writeConditions();
	}
	document.writeln("<p class='twidth' align='center' style='font-size: 12pt;'>");
   	document.writeln("How to find us: - Click <a href=\"javascript:openOneWindow('1','findus.html','winof')\"><i>here</i></a> for Map/Directions</p>");
}

/*
*********************
** Cookie Handling **
**********************************************************************************************************************************
** The function 'parseDate()' creates a string from date interger data. 'updateDate' is set to such a string using
** the 'site last updated' values above.
** 
** When a user visits the site, a cookie is set with a string produced by 'parseDate()' based upon the 'site last updated' values. 
** On return to the site, if the date string value in the cookie differs from the value in 'updateDate' then the user
** is presented with a 'click here' option to link to a 'news.html' where updated site news is provided.
**
** The function writeWelcome() reads and sets the cookie, and writes the initial welcome message, 
**  -- which is either 'Welcome' -- if there is no cookie
**  -- or
**  -- 'Welcome back' -- if the cookie IS present 
**
** If a cookie is present, and the date stored differs from 'updateDate' the function 'writeUpdateInfo()' writes the 'click here' 
** option to get to 'news.html'. 'writeUpdateInfo() doess not a write a message if no cookie is present or the dates are the same. 
********************************************************************************************************************************
*/
updateDate	 		= parseDate(updateDayNum, updateMonthNum, updateYearNum);
updateInfo			= false;
tDate 				= new Date;
cookieExpireDate 		= tDate;
cookieExpireDate.setYear(cookieExpireDate.getYear()+2); 

function parseDate(dayNum, monthNum, yearNum)
{
	month 		= new Array;
	month[0] 	= "January";
	month[1] 	= "February";
	month[2]	= "March";
	month[3]	= "April";
	month[4]	= "May";
	month[5]	= "June";
	month[6]	= "July";
	month[7]	= "August";
	month[8]	= "September";
	month[9]	= "October";
	month[10]	= "November";
	month[11]	= "December";
	dSuffix 	= "";
	rd 		= "";
	if (dayNum == 1 || dayNum == 21 || dayNum == 31)
		dSuffix = "st";
	else
		{
		if (dayNum == 2 || dayNum == 22)
		dSuffix = "nd";
			else
			{
			if (dayNum == 3)
				dSuffix = "rd";
			else
				dSuffix = "th";
			}
		}
	rd = dayNum + dSuffix + " " + month[monthNum-1] + " " + yearNum;
	return rd;
}

function setCookie()
{
	cookieExpireDate.setYear(cookieExpireDate.getYear()+2);
	cookieDate 			= updateDate;
	document.cookie	="updateDate="+cookieDate+";expires=" + cookieExpireDate.toGMTString();
}

function writeUpdateInfo()
{
	document.writeln("<p class='footer' style='font-size:90%;'><< Site Last Updated "  + updateDate + ">></p>");
	if (updateInfo)
		{
			document.writeln("<p class='footer' style='font-size:100%;'>--The Site has been updated since your last visit, click");
			document.writeln("<a href='javascript:openOneWindow(\"1\",\"news.html\",\"winnews\")' title='Details of whats been updated'>here</a> for details --<br>");
			document.writeln("(You can also access this information by clicking on \'news\' in the main menu\)</p>");
		}
}

function writeWelcome()
{	
	updateInfo = false;
	if (sayNothing)
		{
			welcomeMessage = ""
		}
		else
			{
				if (sayHappyXmas)
					{
						welcomeMessage = "Happy Christmas from Crofton Beam Engines"
					}
					else 
						{
							if (sayHappyNewYear)
								{
									welcomeMessage = "Happy New Year from Crofton Beam Engines"
								}
								else
									{
										welcomeMessage = "Getting Ready to Reopen"
									}
						}
			}
			if ( !sayNothing)
			{
	document.write("<h2 align='center' style='font-style: normal' >" + welcomeMessage + "<br><br></h2>");
	}
	
/**************************************************************
***************************************************************
***     Use of Cookie removed in December 2003 legislation   ***
****************************************************************
****************************************************************
 
	if (document.cookie != "")
	{
		document.write (" back");
		theCookie=document.cookie;
		cookieDate=theCookie.split("=")[1];
		if (cookieDate != updateDate)
		{
			updateInfo = true;
		}
	}
	document.writeln(" to the Official Crofton Beam Engines Web Site<br><br></h2>");
	setCookie();

****************************************************************************************
****************************************************************************************/

}

/*
** The following variables are used by the functions 'openOneWindow()' and 'closeOneWindow()'
** which manage window opening, and ensure that no orphan windows are left at the end of the session
** 'params' contains size and other parameters used by the child windows.
** Note that if you want the functions 'closeWindow()', 'printWindow' or 'printAndClose()
** to work, then the child window titles must begin with 'win'.  
*/ 
oneWin1=null;
oneWin2=null;
oneWin3=null;

params="width=700,height=600,scrollbars=yes,resizable=yes"

function openOneWindow(which, url, title)
{
switch (which)
	{
	case '1':
		{
		oneWin1=window.open(url,title,params);
		oneWin1.focus();
		break;
		}
	case '2':
		{
		oneWin2=window.open(url,title,params);
		oneWin2.focus();
		break;
		}
	case '3':
		{
		oneWin3=window.open(url,title,params);
		oneWin3.focus();
		break;
		}
	}
}

function closeOneWindow(which)
{
switch (which)
	{
		case "all":
		{
			if (oneWin1 && !oneWin1.closed)
			{
				oneWin1.close();
				oneWin1=null;
			}
			if (oneWin2 && !oneWin2.closed)
			{
				oneWin2.close();
				oneWin2=null;
			}
			if (oneWin3 && !oneWin3.closed)
			{
				oneWin3.close();
				oneWin3=null;
			}
			break;
		}
	case '1':
		{
		if (oneWin1 && !oneWin1.closed)
			oneWin1.close();
		break;
		}
	case '2':
		{
		if (oneWin2 && !oneWin2.closed)
			oneWin2.close();
		break;
		}
	case '3':
		{
		if (oneWin3 && !oneWin3.closed)
			oneWin3.close();
		break;
		}
	}
}

function writeHeader()
{
	document.writeln("<table id='heading' cellspacing='0' align='center' border='4' style='border: 4px inset olive; border-collapse:separate;' class='twidth'>");
	document.writeln("<tr align='middle'><td><p class='logo'>");
	document.writeln("<img alt='image' src='crofton%20logo%20fixed%20green.gif' width='95' height='80' border='0' align='top'>");
	document.writeln("&nbsp;&nbsp;&nbsp;&nbsp;Crofton Beam Engines&nbsp;&nbsp; &nbsp;");
	document.writeln("<img alt='image' src='kalogo.gif' width='95' height='70' border='0' align='top'>");
	document.writeln("</p></td></tr><tr><td>");
	document.writeln("<p class='footer'>Crofton Pumping Station, Crofton, Marlborough, Wiltshire,&nbsp;SN8 3DW, United Kingdom<br>");
	document.writeln("Telephone +44 (0)1672 870300, eMail <a href='mailto:"+enquiriesAddress+"@CroftonBeamEngines.org'>enquiries</a>");
	document.writeln("</p></td></tr></table><br>");
}

function writeFooter()
{
	document.writeln("<hr class='body' style='color: black;'>");
	document.writeln("<p class='footer'>Crofton Pumping Station is a Branch of The Kennet &amp; Avon Canal Trust, ");
	document.writeln(" Charity No. CC209206<br><br>");
	document.writeln("Copyright &copy The Kennet &amp; Avon Canal Trust. Content not to be used without prior permission.<br>");
	document.writeln("We welcome your feedback on this web site,  please address any queries, comments or suggestions to");
	document.writeln("<a href='mailto:"+webMasterAddress+"@croftonbeamengines.org'>the webmaster</a></p>");
}

function printWindow()
{
	if (window.print)
	{
	document.writeln("<p class = 'footer'>");
	document.writeln("<form> <input type = button name = print value = 'Print' title = 'Print this Document' style='font-weight: bolder;' onClick = 'javascript:window.print()'></form></p><br>");   
	}
}

function closeWindow()
{
	var windowName = window.name;
	var winBit = windowName.substring(0,3);
	if (winBit == "win")
	{
		document.writeln("<p class = 'footer'>");
		document.writeln("<form> <input type = button name = close value = 'Close' title = 'Close this Window' style='font-weight: bolder;' onClick = 'javascript:window.close()'></form></p><br>");   
	}
}

function printAndClose()
{
	var windowName = window.name;
	var winBit = windowName.substring(0,3);
	document.writeln("<p class = 'footer'>");
	document.writeln("<form>");
	if (window.print)
	{
		document.writeln("<input type = button name = print value = 'Print' title = 'Print this Document' style='font-weight: bolder;' onClick = 'javascript:window.print()'> &nbsp; &nbsp;");   
	}
	if (winBit == "win")
	{
		document.writeln("<input type = button name = close value = 'Close Window' title = 'Close this Window' style='font-weight: bolder;' onClick = 'javascript:window.close()'></form></p>");   
	}
	document.writeln("<br><br>");
}
