// Pre-load the images so that the site displays faster...

(new Image(36,18)).src='dot.gif';
(new Image(36,18)).src='tDot.gif';
(new Image(12,10)).src='noSign1.gif';
(new Image(12,10)).src='noSign2.gif';
(new Image(12,10)).src='minus.gif';
(new Image(12,10)).src='plus.gif';
(new Image()).src='correctUnionFlag.gif';
(new Image()).src='invertedUnionFlag.gif';
(new Image()).src='paperGreen.jpg';
(new Image()).src='darkGreen.jpg';
(new Image()).src='marbledGrey.jpg';
(new Image()).src='headerText.gif';
(new Image()).src='mail.gif';

// Set up variables

var	pageTitle = new Array('Welcome','Family Times','Family History',
					      'Union Flag','Javascript Calendar'),
	linkTitle = new Array('BBC Radio 3','BBC Radio 4'),
	linkURL	  = new Array('http://www.bbc.co.uk/iplayer/console/bbc_radio_three',
				       	        'http://www.bbc.co.uk/iplayer/console/bbc_radio_fourfm'),
	This             ='ma',
	Is               ='il',
	My               ='to:',
	Address          ='&#64;'+'&#116;&#97;&#114;&#114;&#103;&#101;&#116;'+
			          '&#46;'+'&#105;&#110;&#102;&#111;',
	See              ='?sub',
	You              ='ject=',
	d			     = document,	
	l			     = location,
	menuCookie		 = 'menu',		  
	pageCookie		 = 'page',
	floatCookie		 = 'float',		  
	baselineCookie	 = 'baseline',
	floatPosition	 = 'floatPosition',
	dateModified	 = 'not available',
	now			     = new Date(),
	date			 = new Date(d.lastModified),
 	page			 = new Array(),
	pageLastUpdated  = new Array(),
	floatMenuRunning = false,	     
    timesRunning	 = false,
    Days             = new Array('Sunday'   ,'Monday'  ,'Tuesday',
	                             'Wednesday','Thursday','Friday','Saturday'),
	Months		     = new Array('January'  ,'February','March'   ,'April'   ,
	                             'May'      ,'June'    ,'July'    ,'August'  ,
						         'September','October' ,'November','December'),
	thisPage		 = getPage();

// Replace the setUTCHours method to avoid Konqueror bug #139435.
// The only problem with this method is that if an error is thrown,
// the error's line number is the line that throws the error, not 
// the line of the method call.  This is currently unavoidable.
// This emulates the Internet Explorer error behaviour - it isn't 
// worth the effort to emulate multiple browser behaviours.

Date.prototype.setUTCHours =
	function (n)
		{switch ((arguments.length>4)?4:arguments.length)
			{case 0: throw new Error('Argument not optional'); break;
			 case 4: this.setUTCMilliseconds(arguments[3]);
			 case 3: this.setUTCSeconds(arguments[2]);
			 case 2: this.setUTCMinutes(arguments[1]);
			 case 1: this.setUTCMinutes(this.getUTCMinutes()+((n-this.getUTCHours())*60));
			}
		}

// Determine gap to left margin and gap to top of screen
var	floatXOffset	= 10,		floatYOffset	  = 10;

// Determine pixel position of content top and bottom IF the content is not
// defined as a DIV (DIV is better because of browser rendering differences).
var screenTop		=  0,		contentTop		  =  0,	
	screenBottom	=  0,		contentOuterHeight=  0,	
	menuHeight		=  0,		contentInnerHeight=  0;

// Start setting for menu behaviour.
var	floatIt		    = getFloatState();

// Use 'toFoot' or 'toHead' to give starting position of menu.
var	baseline		= getBaselineState();

// Start setting for menu visibility.
var	menuVisible		= getMenuState();		

// Set the date for the cookies to expire (one year hence).

now.setFullYear(now.getFullYear()+1);

// Format the date last modified if it is available

//	if (Date.parse(date)!=0&&
//		Date.parse(date)!=Date.parse(Date()))
if (Date.parse(date)!=0 && !isNaN(Date.parse(date)))
	{dateModified=	'on&nbsp;'+date.getDate()+
	                '&nbsp;'  +Months[date.getMonth()]+
				    '&nbsp;'  +date.getFullYear()
	}

// Disallow selection in the menu and header navigation arrows for IE4+
// The equivalent non-IE4 code is in the body tag's onMouseDown and 
// onClick attributes.

d.onselectstart=function allowSelectIE()
	{return !(d.getElementById('floatMenu').contains(event.srcElement)||
			  event.srcElement.id=='headerPrev'||
			  event.srcElement.id=='headerNext');
	}

// DOM code emulating IE "contains" used to disallow selection for NS6

function containsDOM(container,contained)
	{var isParent=false;
	 do {if (isParent=container==contained) break; 
	     contained=contained.parentNode;
		}
	 while (contained!=null);
	 return isParent;
	} 

// ******************** Initial code date processing code ******************

// OK, so don't trust everything that says UTC to be in UTC!
// I am using the UTC methods here so that I can be in control
// of the times and dates without worrying about localisation.

// IMPORTANT:  Months are zero based (0 - 11 = Jan - Dec).

//  [The Zeroth of month 10 (November) is the last day of October,
//   that gives the start point for finding the last Sunday.]

//	Canada starts DST on the second Sunday in March and ends DST 
//	on the first Sunday in November.

var torontoStart = new Array( 2, 14, 2);
var torontoEnd	 = new Array(10,  7, 2);

//	UK starts DST on the last Sunday in March and ends DST on
//	the last Sunday in October.

var londonStart	 = new Array( 3,  0, 1);
var londonEnd	 = new Array(10,  0, 2);

//	WA starts DST on the last Sunday in October and ends DST on
//	the last Sunday in March.

var perthStart	 = new Array(10,  0, 2);
var perthEnd	 = new Array( 3,  0, 3);

//	NZ starts DST on the last Sunday in September and ends DST
//	on the First Sunday in April.

var auklandStart = new Array( 9, 0, 2);
var auklandEnd	 = new Array( 3, 7, 3);

function format_DST_date(seedDate)
	{sFormatted = seedDate.getUTCHours();
	 if (seedDate.getUTCHours()   > 12)   {sFormatted = sFormatted - 12;}
	 sFormatted += ":";
	 if (seedDate.getUTCMinutes() < 10)	  {sFormatted += "0";}
	 sFormatted += seedDate.getUTCMinutes() + " ";
	 if (seedDate.getUTCHours() < 12)
		{sFormatted += "AM [";
		 if (seedDate.getUTCHours() < 10) {sFormatted += "0";}
		}
	 else	{sFormatted += "PM [";}
	 sFormatted += seedDate.getUTCHours() + ":" ;
	 if (seedDate.getUTCMinutes() < 10)   {sFormatted += "0";}

	 sFormatted += seedDate.getUTCMinutes()       + "] " +
				   Days[seedDate.getUTCDay()]     +  " " +
				   seedDate.getUTCDate()          +  " " +
				   Months[seedDate.getUTCMonth()] +  " " +
				   seedDate.getUTCFullYear();

	 return sFormatted;
	}

function find_DST_change(seedYear, seedPart)
	{seedDate = new Date();
	 seedDate.setUTCFullYear(seedDate.getUTCFullYear()+seedYear);
	 seedDate.setUTCMonth(seedPart[0],seedPart[1]);
	 seedDate.setUTCHours(seedPart[2],0,0);
	 seedDate.setUTCDate(seedDate.getUTCDate() -
					     seedDate.getUTCDay());
	 return seedDate;
	}

function setLastDateDST(vNow, vStart, vEnd, vSecond)
	{return (vNow < vStart)
			?find_DST_change(-1, vSecond)
			:(vNow > vEnd)?vEnd:vStart;
	}

function setNextDateDST(vNow, vStart, vEnd, vFirst)
	{return (vNow < vStart)
			?vStart
			:(vNow > vEnd)?find_DST_change( 1, vFirst):vEnd;
	}

todayToronto      = new Date();
todayToronto.setUTCHours(todayToronto.getUTCHours()-5);

var vTorontoStart = find_DST_change( 0, torontoStart);
// Wierd! Opera 7.50 required this to have explicit "var".

vTorontoEnd		  = find_DST_change( 0, torontoEnd);

todayLondon		  = new Date();
vLondonStart	  = find_DST_change( 0, londonStart);
vLondonEnd		  = find_DST_change( 0, londonEnd);

todayPerth        = new Date();
todayPerth.setUTCHours(todayPerth.getUTCHours()+8);
vPerthStart		  = find_DST_change( 0, perthStart);
vPerthEnd		  = find_DST_change( 0, perthEnd);

todayAukland	  = new Date();
todayAukland.setUTCHours(todayAukland.getUTCHours()+12);
vAuklandStart	  = find_DST_change( 0, auklandStart);
vAuklandEnd		  = find_DST_change( 0, auklandEnd);

// Northern Hemisphere has Daylight saving in the middle of the 
// year and Standard time at the ends.

if (todayToronto > vTorontoStart && todayToronto < vTorontoEnd)
	{todayToronto.setUTCHours(todayToronto.getUTCHours()+1);}

vTorontoLast	 = setLastDateDST(todayToronto, vTorontoStart, 
                                  vTorontoEnd,   torontoEnd);
vTorontoNext	 = setNextDateDST(todayToronto, vTorontoStart,
                                  vTorontoEnd,   torontoStart);
vTorontoNextNext = new Date((vTorontoNext==vTorontoStart)
                            ?vTorontoEnd
							:(vTorontoNext==vTorontoEnd)
								?find_DST_change(1, torontoStart)
								:find_DST_change(1, torontoEnd));

if (todayLondon > vLondonStart && todayLondon < vLondonEnd)
	{todayLondon.setUTCHours(todayLondon.getUTCHours()+1);}
 
vLondonLast		 = setLastDateDST(todayLondon, vLondonStart, 
                                  vLondonEnd,   londonEnd);
vLondonNext		 = setNextDateDST(todayLondon, vLondonStart, 
                                  vLondonEnd,   londonStart);
vLondonNextNext	 = new Date((vLondonNext==vLondonStart)
                            ?vLondonEnd
							:(vLondonNext==vLondonEnd)
								?find_DST_change(1, londonStart)
								:find_DST_change(1, londonEnd));

// Southern Hemisphere has Standard time in the middle of the 
// year and Daylight saving at the ends.

if (todayPerth > vPerthStart || todayPerth < vPerthEnd)
	{todayPerth.setUTCHours(todayPerth.getUTCHours()+1);}

vPerthLast	   = setLastDateDST(todayPerth, vPerthEnd,  
                                  vPerthStart, perthStart);
vPerthNext	   = setNextDateDST(todayPerth, vPerthEnd,  
                                  vPerthStart, perthEnd);
vPerthNextNext = new Date((vPerthNext==vPerthEnd)	
                            ?vPerthStart
							:(vPerthNext==vPerthStart)
								?find_DST_change(1, perthEnd)
								:find_DST_change(1, perthStart));

if (todayAukland > vAuklandStart || todayAukland < vAuklandEnd)
	{todayAukland.setUTCHours(todayAukland.getUTCHours()+1);}

vAuklandLast	 = setLastDateDST(todayAukland, vAuklandEnd,  
                                  vAuklandStart, auklandStart);
vAuklandNext	 = setNextDateDST(todayAukland, vAuklandEnd,  
                                  vAuklandStart, auklandEnd);
vAuklandNextNext = new Date((vAuklandNext==vAuklandEnd)	
                            ?vAuklandStart
							:(vAuklandNext==vAuklandStart)
								?find_DST_change(1, auklandEnd)
								:find_DST_change(1, auklandStart));

// ************************ Functions for initial code **********************

// Write the HTML that displays the cookie switch link

function writeOptionsMenu()
	{var spanAttributes='<span style="color:gold;cursor:pointer;" ' +
				  'onmouseover="this.style.color=\'red\'" '         + 
				  'onmouseout="this.style.color=\'gold\'" '         +
				  'onfocus="this.style.color=\'red\'" '             + 
				  'onblur="this.style.color=\'gold\'" onClick="';

	 d.write(spanAttributes+'toggleMenu()" id="menuText">'    +
			((getCookie(menuCookie)==null||
		      getCookie(menuCookie)=='visible')?'Hide':'Show')+
			'&nbsp;menu</span><br>');

	 if (navigator.cookieEnabled)
		d.write(spanAttributes+'toggleCookies()" id="cookieText">'  +
				((getCookie(pageCookie)==null)?'Remember':'Forget') +
		        '&nbsp;settings</span><br>');

	 if	(document.getElementById('msieGE4'))
		d.write(spanAttributes+
				'window.external.AddFavorite(l.protocol+\'//\'+'            + 
		                                    'l.host+l.pathname,d.title);">' +
				'Set&nbsp;<b>site</b>&nbsp;as&nbsp;a&nbsp;favourite'        +
				'</span><br>'+
			    spanAttributes+
				'window.external.AddFavorite(l.protocol+\'//\'+'          +
					'l.host+l.pathname+\'?page=\'+parseInt(thisPage+1), ' +
					'd.title+\' - \'+pageTitle[thisPage]);">'             +
				'Set&nbsp;<b>page</b>&nbsp;as&nbsp;a&nbsp;favourite'      +
				'</span><br>');
	}

// Set the initial page from parsed the URL search string, 
// if absent then use the cookie if present.

function getPage()
	{var value=-1;
// If there is a search string on the URL then try to find a page in it.
     if (l.search)		
		{var pageNo=unescape(l.search).toLowerCase().match(/\Wpage=\w+/);
		 pageNo=(pageNo==null)
			    ?'0'
		        :(pageNo[0].split('=')[1].match(/\D+/))
					?'0'
				    :pageNo[0].split('=')[1];
		 if (parseInt(pageNo)>0 && parseInt(pageNo)<=pageTitle.length) 
			{value=parseInt(pageNo)-1;}
		}

// If no valid page is found in the search string (if there is one) 
// then try to find a page in the cookie
	 if (!(value>=0 && value<pageTitle.length))
	 	{var pageNo=parseInt(getCookie(pageCookie)); 
	     value=(pageNo>=0&&pageNo<pageTitle.length)?pageNo:0;
		}
	 return ((value<0)?0:value);
	}

// ********************** Start of On Load code ***************************

function startUp()
	{if (baseline=='toHead') 
	      d.getElementById('headLink').style.fontWeight='bold';
	 else d.getElementById('footLink').style.fontWeight='bold';

	 if (floatIt) d.getElementById('floatLink').style.fontWeight='bold';
	 else	 	  d.getElementById(  'fixLink').style.fontWeight='bold';

	 d.getElementById('floatMenu').style.visibility=(menuVisible)
		                                            ?'visible'
	                                                :'hidden';

// Opera 7.50 can't handle the position reset.
     if (menuVisible || window.opera)				
		{d.getElementById('menuSpace').width='170px';
		 d.getElementById('contentSpace').width='70%';
		 d.getElementById('rightSpace').width=null;
		}
	 else
		{d.getElementById('menuSpace').width='15%';
		 d.getElementById('contentSpace').width=null;
		 d.getElementById('rightSpace').width='15%';
		}

	 for (var i=0;i<divisions.length;i++)
		if (divisions[i].id.split('_')[1]=='C')
			divisions[i].style.display=
		      (getBlockState(divisions[i].id.split('_')[0])=='expand')
		      ?'block'
	          :'none';

	 for (var i=0;i<images.length;i++)
		if (images[i].id.split('_')[1]=='B')
			{images[i].src=
		      ((getBlockState(images[i].id.split('_')[0])=='expand')
		      ?'min'
	          :'pl')+'us.gif';
			 images[i].title=images[i].alt=
		      ((getBlockState(images[i].id.split('_')[0])=='expand')
		      ?'Close':'Open')+' '+images[i].alt.split(' ')[1];
			}

	 defaultStatus='Welcome to our web pages.'
	 goTo(thisPage)		//Start with the chosen page.
	 startFloatMenu()	//Float the menu.
	}

// ************** End of On Load code, Start of Event driven code ************

function goTo(pageNo)	
	{thisPage=pageNo;
	 d.getElementById('pageName').innerHTML=
		 (pageNo+1)+' - '+pageTitle[pageNo]+'<br>'+
		 '<span style="font-size:7pt;font-weight:normal;">['+
		 pageLastUpdated[pageNo].replace(/\s/g,'&nbsp;')+']</span>';
	 d.getElementById('pageHere').innerHTML=page[pageNo];
	 if (!timesRunning&&pageTitle[pageNo]=='Family Times') refreshTimes();
	 if (getCookie(pageCookie)!=null) setCookie(pageCookie,pageNo,now);
	}

function goPrev()	{if (thisPage>0)				{goTo(thisPage-1);}}
function goNext()	{if (thisPage<page.length-1)	{goTo(thisPage+1);}}
function goLast()	{goTo(page.length-1);}

// Position the Options menu below the Options "link"

function locateOptionsMenu()
	{clientWidth=(typeof(innerWidth)=='number')
				?innerWidth							//Non-IE
				:(d.documentElement&&d.documentElement.clientWidth)
					?d.documentElement.clientWidth	//IE6+ standards compliant
					:(d.body&&d.body.clientWidth)
						?d.body.clientWidth			//IE4 compatible
						:0;							//Failed

	 var head	        =d.getElementById('optionsMenuHead'),
		 currentElement	=head,	
	 	 layer	        =d.getElementById('optionsMenuLayer'),
		 offsetTop		=0;

	 while(currentElement!=d.body)
		{offsetTop +=parseInt(currentElement.offsetTop)-
		             parseInt(currentElement.scrollTop);
		 currentElement=currentElement.offsetParent;
		}

	 layer.style.left	   =(parseInt(clientWidth)-13-
		                     parseInt(head.offsetWidth))+'px';
	 layer.style.top	   =(offsetTop+
		                     parseInt(head.offsetHeight))+'px';
	 layer.style.visibility='visible';
	}

// Make the main menu visible or invisible and remember user's choice

function toggleMenu()
	{if (d.getElementById('menuText').innerHTML.substr(0,4)=='Show')
		{d.getElementById('menuText').innerHTML        ='Hide&nbsp;menu';
		 d.getElementById('menuSpace').width           ='170px';
		 d.getElementById('contentSpace').width        ='70%';
		 d.getElementById('rightSpace').width          =null;
		 d.getElementById('floatMenu').style.visibility='visible';
		 menuVisible=true;
		 if (getCookie(menuCookie)!=null) 
		   setCookie(menuCookie,'visible',now);
		}
	 else
		{d.getElementById('menuText').innerHTML='Show&nbsp;menu';
		 d.getElementById('floatMenu').style.visibility='hidden';
// Opera 7.50 has trouble redisplaying the correct menuSpace width 
// to 170px above so leave it at the original settings.
         if (!window.opera)							
			{d.getElementById('menuSpace').width='15%';
			 d.getElementById('contentSpace').width=null;
			 d.getElementById('rightSpace').width='15%';
			}
		 menuVisible=false;
		 if (getCookie(menuCookie)!=null) 
		   setCookie(menuCookie,'hidden',now);
		}
	}

// Expand or collapse all menu tree branches

function toggleAll(pAction)
	{if (pAction=='Open') var div='block',tst= 'pl',img='min';
	 else				  var div= 'none',tst='min',img= 'pl';

	 if (divisions[0].style.display==null)
		{alert('Sorry, your browser does not support ' + 
		       'the methods used on this page.');
	     return false;
		}

	 for (var i=0;i<divisions.length;i++)
		{if (divisions[i].id.split('_')[1]=='C')
			{divisions[i].style.display=div;
			 if (getCookie(divisions[i].id.split('_')[0])!=null)
				setCookie(divisions[i].id.split('_')[0],
				          (div=='block')?'expand':'collapse',now);
			}
		}

	 for (var i=0;i<images.length;i++)
		{if	((images[i].id.split('_')[1]=='B') &&
			 (images[i].src.substr(images[i].src.lastIndexOf('/')+1)==
		      tst+'us.gif')
			)
			images[i].src=img+'us.gif'
			images[i].title=images[i].alt=
		      ((img=='min')?'Close':'Open')+' '+images[i].alt.split(' ')[1];
		}

	 return false;
	}

// Expand and collapse a specified branch of the menu tree

function toggleDisplay(pSet)
	{pBranch=d.getElementById(pSet+'_C');

	 if (pBranch.style.display==null)
		{alert('Sorry, your browser does not support ' + 
		       'the methods used on this page.');
	     return false;
		}

	 pImage=d.getElementById(pSet+'_B');

	 if ((pBranch.style.display==null)||(pBranch.style.display=='none'))
		{pBranch.style.display='block';	pImage.src='minus.gif';
		 pImage.title=pImage.alt='Close '+pImage.alt.split(' ')[1];
		 if (getCookie(pSet)!=null) setCookie(pSet,'expand',now);
		}
	 else
		{pBranch.style.display= 'none';	pImage.src='plus.gif';
		 pImage.title=pImage.alt='Open '+pImage.alt.split(' ')[1];
		 if (getCookie(pSet)!=null) setCookie(pSet,'collapse',now);
		}
	}

// Store or remove site configuration cookies

function toggleCookies()
	{if (d.getElementById('cookieText').innerHTML.substr(0,8)=='Remember')
		{d.getElementById('cookieText').innerHTML='Forget&nbsp;settings';
		 setCookie(menuCookie,(menuVisible)?'visible':'hidden',now);	
		 setCookie(pageCookie,thisPage,now);
		 setCookie(floatCookie,(floatIt)?'true':'false',now);			
		 setCookie(baselineCookie,baseline,now);

		 for (var i=0;i<divisions.length;i++)
			{if (divisions[i].id.split('_')[1]=='C')
				setCookie(divisions[i].id.split('_')[0],
						  (divisions[i].style.display=='block')
			                ?'expand'
		                    :'collapse',
						  now);}
		}
	 else
		{d.getElementById('cookieText').innerHTML='Remember&nbsp;settings';
		 deleteCookie(menuCookie);	deleteCookie(pageCookie);
		 deleteCookie(floatCookie);	deleteCookie(baselineCookie);
		 for (var i=0;i<divisions.length;i++)
			{if (divisions[i].id.split('_')[1]=='C')
				deleteCookie(divisions[i].id.split('_')[0]);
			}
		 deleteCookie(floatPosition);
		}
	}

// ***** End of direct event-driven code, Start of cookie processing code *****

/*	name		- name of the cookie
	value		- value of the cookie
	[expires]	- expiration date of the cookie 
	                (defaults to end of current session)
	[path]	    - path for which the cookie is valid 
	                (defaults to path of calling document)
	[domain]	- domain for which the cookie is valid 
	                (defaults to domain of calling document)
	[secure]	- Boolean value indicating if the cookie 
	              transmission requires a secure transmission

	* an argument defaults when it is assigned null as a placeholder
	* a null placeholder is not required for trailing omitted arguments
*/
function setCookie(name,value,expires,path,domain,secure)
	{var curCookie = name+'='+escape(value)+
     				 ((expires)	?';expires='+expires.toGMTString()	:'') +
				     ((path)	?';path='   +path					:'') +
				     ((domain)	?';domain=' +domain					:'') +
				     ((secure)	?';secure'							:'');
	 d.cookie=curCookie;
	}

//	name - name of the desired cookie
//	* return string containing value of specified cookie or 
//                             null if cookie does not exist

function getCookie(name)
	{var dc=d.cookie, prefix=name+'=', begin=dc.indexOf('; '+prefix);
	 if	(begin==-1)
	     {begin=dc.indexOf(prefix); if (begin!=0) return null;}
	 else begin+=2;
	 var end=d.cookie.indexOf(';',begin);
	 if	(end==-1) end=dc.length;
	 return unescape(dc.substring(begin+prefix.length,end));
	}

/*	name	 - name of the cookie
	[path]	 - path of the cookie 
                 (must be same as path used to create cookie)
	[domain] - domain of the cookie 
                 (must be same as domain used to create cookie)
	* path and domain default if assigned null or 
	                  omitted if no explicit argument preceeds
*/
function deleteCookie(name, path, domain)
	{if (getCookie(name))
		d.cookie=name+'='+
		         ((path)	?';path='  +path	:'')+
			     ((domain)	?';domain='+domain	:'')+
				 ';expires=Thu, 01-Jan-70 00:00:01 GMT';
	}

function getFloatState()
	{var floatState=getCookie(floatCookie), value=false;
	 if (floatState==null || floatState=='true') value=true;
	 return value;
	}

function getMenuState()
	{var menuState=getCookie(menuCookie), value=false;
	 if (menuState==null || menuState=='visible') value=true;
	 return value;
	}

function getFloatPosition()
	{var floatPosition=getCookie(floatPosition);
	 if (floatposition==null) floatPosition=0;
	 return floatPosition;
	}

function getBaselineState()
	{var baselineState=getCookie(baselineCookie);
	 if (baselineState==null) baselineState='toHead';
	 return baselineState;
	}

function getBlockState(blockName)
	{var blockState=getCookie(blockName);
	 if (blockState==null)	blockState='expand';
	 return blockState;
	}

// ******************** Start of page-specific code ***************************

// Get the date this page was last modified
// (if the server sends it in the header)

function format_date(today)
	{sFormatted=today.getUTCHours();
	 if (today.getUTCHours()  >12) sFormatted-=12;
	 sFormatted+=':';
	 if (today.getUTCMinutes()<10) sFormatted+='0';
	 sFormatted+=today.getUTCMinutes()+'&nbsp;';

	 if (today.getUTCHours()<12)
		{sFormatted+='AM&nbsp;[';
		 if (today.getUTCHours()<10) sFormatted+='0';
		}
	 else sFormatted+='PM&nbsp;[';

	 sFormatted+=today.getUTCHours()+':';
	 if (today.getUTCMinutes()<10) sFormatted+='0';

	 sFormatted += today.getUTCMinutes()      +'] '    +
		           Days[today.getUTCDay()]    +' '     +
		           today.getUTCDate()         +'&nbsp;'+
		           Months[today.getUTCMonth()]+'&nbsp;'+
		           today.getUTCFullYear();
	 return sFormatted;
	}

function refreshTimes()
	{if (pageTitle[thisPage]=='Family Times')
		{timesRunning=true;

		 TimeOut = window.setTimeout("refreshTimes()", 1000);

		 todayToronto	= new Date();
		 todayToronto.setUTCHours(todayToronto.getUTCHours()-5);

		 todayLondon	= new Date();

		 todayPerth		= new Date();
		 todayPerth.setUTCHours(todayPerth.getUTCHours()+8);

		 todayAukland	= new Date();
		 todayAukland.setUTCHours(todayAukland.getUTCHours()+12);

// Northern hemisphere has Daylight saving in middle months of the year

		 if (todayToronto > vTorontoStart && todayToronto < vTorontoEnd)
			{todayToronto.setUTCHours(todayToronto.getUTCHours()+1);}

		 if (todayLondon > vLondonStart && todayLondon < vLondonEnd)
			{todayLondon.setUTCHours(todayLondon.getUTCHours()+1);}
 
// Southern hemisphere has Daylight saving at the year's start and end months

		 if (todayPerth > vPerthStart || todayPerth < vPerthEnd)
			{todayPerth.setUTCHours(todayPerth.getUTCHours()+1);}

		 if (todayAukland > vAuklandStart || todayAukland < vAuklandEnd)
			{todayAukland.setUTCHours(todayAukland.getUTCHours()+1);}

// If the date goes past a change date then refresh the Last and
// Next dates (twice per year per location).

		 if (todayToronto > vTorontoNext)
			{vTorontoLast	  = vTorontoNext;
			 vTorontoNext	  = setNextDateDST(todayToronto,
									           vTorontoStart,
									           vTorontoEnd,
									           torontoStart);
			 vTorontoNextNext = new Date((vTorontoNext==vTorontoStart)
									     ?vTorontoEnd
									     :(vTorontoNext==vTorontoEnd)
										  ?find_DST_change(1, torontoStart)
										  :find_DST_change(1, torontoEnd));
			}

		 if (todayLondon > vLondonNext)
			{vLondonLast	 = vLondonNext;
			 vLondonNext	 = setNextDateDST(todayLondon,
									          vLondonStart,
									          vLondonEnd,
									          londonStart);
			 vLondonNextNext = new Date((vLondonNext==vLondonStart)
									    ?vLondonEnd
									    :(vLondonNext==vLondonEnd)
										 ?find_DST_change(1, londonStart)
										 :find_DST_change(1, londonEnd));
			}

		 if (todayPerth > vPerthNext)
			{vPerthLast	      = vPerthNext;
			 vPerthNext	      = setNextDateDST(todayPerth,
									           vPerthEnd,
									           vPerthStart,
									           perthEnd);
			 vPerthNextNext   = new Date((vPerthNext==vPerthEnd)
									     ?vPerthStart
									     :(vPerthNext==vPerthStart)
										  ?find_DST_change(1, perthEnd)
										  :find_DST_change(1, perthStart));
			}

		 if (todayAukland > vAuklandNext)
			{vAuklandLast	  = vAuklandNext;
			 vAuklandNext	  = setNextDateDST(todayAukland,
									           vAuklandEnd,
									           vAuklandStart,
									           auklandEnd);
			 vAuklandNextNext = new Date((vAuklandNext==vAuklandEnd)
									     ?vAuklandStart
									     :(vAuklandNext==vAuklandStart)
										  ?find_DST_change(1, auklandEnd)
										  :find_DST_change(1, auklandStart));
			}

// If the date rolls over a year then refresh the Start and End dates
// (once per year per location).

		 if (todayToronto.getUTCFullYear() > 
			 vTorontoStart.getUTCFullYear())
			{vTorontoStart	= find_DST_change( 0, torontoStart);
			 vTorontoEnd	= find_DST_change( 0, torontoEnd);
			}

		 if (todayLondon.getUTCFullYear() >
			 vLondonStart.getUTCFullYear())
			{vLondonStart	= find_DST_change( 0, londonStart);
			 vLondonEnd		= find_DST_change( 0, londonEnd);
			}

		 if (todayPerth.getUTCFullYear() >
			 vPerthStart.getUTCFullYear())
			{vPerthEnd	    = find_DST_change( 0, perthEnd);
			 vPerthStart	= find_DST_change( 0, perthStart);
			}

		 if (todayAukland.getUTCFullYear() >
			 vAuklandStart.getUTCFullYear())
			{vAuklandEnd	= find_DST_change( 0, auklandEnd);
			 vAuklandStart	= find_DST_change( 0, auklandStart);
			}

// Determine whether a change date (Last or Next) is a start of DST
// or an end.

		if (vTorontoLast.getUTCMonth() < 6)
			 {strTorontoLast = "Start";	strTorontoNext = "End";}
		else {strTorontoLast = "End";	strTorontoNext = "Start";}

		if (vLondonLast.getUTCMonth() < 6)
			 {strLondonLast  = "Start";	 strLondonNext  = "End";}
		else {strLondonLast  = "End";	 strLondonNext  = "Start";}

		if (vPerthLast.getUTCMonth() < 6)
			 {strPerthLast = "End";	     strPerthNext = "Start";}	
		else {strPerthLast = "Start";	 strPerthNext = "End";}

		if (vAuklandLast.getUTCMonth() < 6)
			 {strAuklandLast = "End";	 strAuklandNext = "Start";}	
		else {strAuklandLast = "Start";	 strAuklandNext = "End";}

// Write out the results

		 d.times.Toronto.value			  = format_DST_date(todayToronto);
		 d.times.torontoLastStr.value	  = strTorontoLast;
		 d.times.torontoLastDST.value	  = format_DST_date(vTorontoLast);
		 d.times.torontoNextStr.value	  = strTorontoNext;
		 d.times.torontoNextDST.value	  = format_DST_date(vTorontoNext);
		 d.times.torontoNextNextStr.value = strTorontoLast;
		 d.times.torontoNextNextDST.value = format_DST_date(vTorontoNextNext);

		 d.times.London.value			  = format_DST_date(todayLondon);
		 d.times.londonLastStr.value	  = strLondonLast;
		 d.times.londonLastDST.value	  = format_DST_date(vLondonLast);
		 d.times.londonNextStr.value	  = strLondonNext;
		 d.times.londonNextDST.value	  = format_DST_date(vLondonNext);
		 d.times.londonNextNextStr.value  = strLondonLast;
		 d.times.londonNextNextDST.value  = format_DST_date(vLondonNextNext);

		 d.times.Perth.value			  = format_DST_date(todayPerth);
		 d.times.perthLastStr.value		  = strPerthLast;

		 // WA started DST late in 2006 because the Government rushed
		 // through the DST bill starting the trial at the last minute.
		 if (vPerthLast.getUTCFullYear()==2006) vPerthLast.setUTCMonth(11,3);
		 
		 d.times.perthLastDST.value	      = format_DST_date(vPerthLast);
		 d.times.perthNextStr.value	      = strPerthNext;
		 d.times.perthNextDST.value	      = format_DST_date(vPerthNext);
		 d.times.perthNextNextStr.value   = strPerthLast;
		 d.times.perthNextNextDST.value   = format_DST_date(vPerthNextNext);

		 d.times.Aukland.value			  = format_DST_date(todayAukland);
		 d.times.auklandLastStr.value	  = strAuklandLast;
		 d.times.auklandLastDST.value	  = format_DST_date(vAuklandLast);
		 d.times.auklandNextStr.value	  = strAuklandNext;
		 d.times.auklandNextDST.value	  = format_DST_date(vAuklandNext);
		 d.times.auklandNextNextStr.value = strAuklandLast;
		 d.times.auklandNextNextDST.value = format_DST_date(vAuklandNextNext);
	 	}
	 else timesRunning=false;
	}

// ***************** Start of main menu flotation code ************************

function startFloatMenu()
	{floatObj=menuLoad('floatMenu');
	 if (getCookie(floatPosition)!=null) 
	   floatObj.sP(floatObj.x,parseInt(getCookie(floatPosition)));
	 floatWatch();
	}

function menuLoad(id)
	{var el=(d.getElementById)
	          ?d.getElementById(id)
			  :d.all?d.all[id]:d.layers[id];

	 contentTop        =d.getElementById('contentTop').offsetTop;
	 contentInnerHeight=d.getElementById('contentInner').offsetHeight;

	 if (menuVisible && el.offsetHeight>contentInnerHeight)
		{d.getElementById('contentOuter').style.height=
		   parseInt(el.offsetHeight)+'px';
		 contentOuterHeight=el.offsetHeight;
		}
	 else
	   contentOuterHeight=(d.getElementById('contentOuter').offsetHeight);

	 if (d.layers) el.style=el;

	 el.sP=function(x,y){this.style.left=parseInt(x)+'px';
	                     this.style.top =parseInt(y)+'px';};
	 el.x=floatXOffset;

	 el.y=(getCookie(floatPosition)==null)
			?contentTop+((baseline=='toHead')
		       ?0
		       :(contentOuterHeight-el.offsetHeight))
			:parseInt(getCookie(floatPosition));
	 return el;
	}

function floatWatch()
	{/*	 This routine will check to see if the expensive 
	     floating mechanism should be running.

		 Don't run the floater if the user has chosen 
		       to fix the menu in place.
		 The menu may move if either the screen bottom or
		                             the screen top    changes.
		 The menu may also move if the user expands   or 
		                                    collapses menu branches.
	*/

	 if (menuVisible)
		{var nowScreenTop=
		       (typeof(pageYOffset)=='number')
			   ?pageYOffset							//Netscape compliant
			   :(d.body&&d.body.scrollTop)
				  ?d.body.scrollTop					//DOM compliant
				  :(d.documentElement&&d.documentElement.scrollTop)
					 ?d.documentElement.scrollTop	//IE6+ standards compliant
					 :0,							//Failed
		 	nowScreenHeight=
				(typeof(innerHeight)=='number')
				?innerHeight						//Non-IE
				:(d.documentElement&&d.documentElement.clientHeight)
					?d.documentElement.clientHeight	//IE6+ standards compliant
					:(d.body&&d.body.clientHeight)
						?d.body.clientHeight		//IE4 compatible
						:0,							//Failed
			nowMenuHeight=	floatObj.offsetHeight;

		 contentTop=d.getElementById('contentTop').offsetTop;
		 contentInnerHeight=d.getElementById('contentInner').offsetHeight;

//	 If the menu is taller than the page content then 
//     set the page height to the menu height

		 contentOuterHeight=(nowMenuHeight>contentInnerHeight)
			                ?nowMenuHeight
			                :contentInnerHeight;

		 d.getElementById('contentOuter').style.height=
			 parseInt(contentOuterHeight)+'px';

//	 If the menu floats
//		If menu is not already on the move and
//         (the menu height changes or 
//          the screen top or bottom positions change) then
//	      float the menu.

		 if (floatIt)
		 	{if (!floatMenuRunning &&
				 ((nowMenuHeight!=menuHeight)||
				  (Math.round(screenTop)   ==Math.round(nowScreenTop))||
				  (Math.round(screenBottom)==Math.round(nowScreenTop+
			                                            nowScreenHeight))
				 )
				)
				{floatMenuRunning=true;
				 floatMenu();
				}
			}

//	 If the menu is fixed 
//		If the bottom of the menu goes beyond the new bottom of content
//			if the menu is head based then 
//				reposition menu to the top of the content 
//			if the menu is foot based then 
//				reposition menu to the new foot of the content

		 else
		   {if (Math.floor(floatObj.y+nowMenuHeight)>
			    Math.floor(contentTop+contentInnerHeight))
			  {floatObj.y=(baseline=='toHead')
			              ?contentTop
						  :Math.round((contentInnerHeight>nowMenuHeight)
								?contentTop+contentInnerHeight-nowMenuHeight
								:contentTop);

			   floatObj.sP(floatObj.x,floatObj.y);
			   if (getCookie(pageCookie)!=null) 
			     setCookie(floatPosition,Math.floor(floatObj.y),now);
			  }
		   }
		 menuHeight		=nowMenuHeight;
		 screenTop		=Math.round(nowScreenTop);
		 screenBottom	=Math.round(nowScreenTop+nowScreenHeight);
		}
	 else
	   {d.getElementById('contentOuter').style.height=
		  parseInt(d.getElementById('contentInner').offsetHeight)+'px';
	   }
	 window.setTimeout("floatWatch()", 250);
	}

function floatMenu()
	{var screenTop=(typeof(pageYOffset)=='number')
	               ?pageYOffset					   //Netscape compliant
				   :(d.body&&d.body.scrollTop)
				    ?d.body.scrollTop			   //DOM compliant
					:(d.documentElement&&d.documentElement.scrollTop)
					 ?d.documentElement.scrollTop  //IE6+ standards compliant
					 :0;						   //Failed
	 if (baseline=='toHead')
		{
//if content top is below screen top then 
//  float menu top at content top	 
//else 
//  if menu bottom above content bottom then 
//    float menu top at screen top + offset 
//  else
//    float menu bottom at content bottom

		 var pY=(screenTop<contentTop)		
				?contentTop					
				:(screenTop+floatYOffset+floatObj.offsetHeight<
				  contentTop+contentInnerHeight)
					?screenTop+floatYOffset	
					:contentTop+contentOuterHeight-floatObj.offsetHeight;
			}
	 else
	   {var screenHeight=
		      ((typeof(innerHeight)=='number')
		       ?innerHeight						//Non-IE
			   :(d.documentElement&&d.documentElement.clientHeight)
			    ?d.documentElement.clientHeight	//IE6+ standards compliant
			    :(d.body&&d.body.clientHeight)
				 ?d.body.clientHeight			//IE4 compatible
				 :0);							//Failed

//if screen bottom is below content bottom then 
//  float menu bottom at content bottom
//else if menu top is above content top then
//       float at content top
//     else float menu bottom at screen bottom - offset

        pY= (screenTop+screenHeight>contentTop+contentInnerHeight)
			?contentTop+contentOuterHeight-floatObj.offsetHeight	
			:(screenTop+screenHeight-floatYOffset-floatObj.offsetHeight<
			  contentTop)
			 ?contentTop		
			 :screenTop+screenHeight-floatYOffset-floatObj.offsetHeight;
		}						

	 if (Math.abs(pY-floatObj.y)/8<0.1) floatMenuRunning=false;

	 floatObj.y+=(pY-floatObj.y)/8;
	 floatObj.sP(floatObj.x,floatObj.y);

	 if (floatMenuRunning) setTimeout('floatMenu()',10);
	}

