<!--
	
/* Animate page exit */
var animOut;
function doAnimateOut(goto,pageid) {
	$('additionalLinks').style.display='block';
	if (!animOut) {
		animOut = new Animator({
			onComplete: function() { 
				if (pageid) { //dynamically load page content
					//first tidy up the page
					$('mainLogo').style.display='none';				
					$('bulletinBoardContainer').style.display='none';
					$('vertBar').style.left='0px';
					
					//$('homeLink').onclick = void;
					
					//stop BB rotation
					clearTimeout(timerBB);
					
					//now do AJAX load
					loadPage(pageid);
				
				} else { 
					//redirect to goto page
					document.location=goto;
				}
			} 
			})
			.addSubject(new NumericalStyleSubject($('vertBar'), 'right',100,(getPageWidth()-$('vertBar').offsetWidth-10)))
			.addSubject(new CSSStyleSubject($('horizBar'), 'top: -130px;'))
			.addSubject(new NumericalStyleSubject($('bulletinBoardContainer'), 'opacity', 1, 0))
			.addSubject(new CSSStyleSubject($('homeNav'), 'top: 70px;'))
			.addSubject(new CSSStyleSubject($('smallLogo'), 'left: 12px;'))
			.addSubject(new CSSStyleSubject($('fontControls'), 'left: 20px;'))
			.addSubject(new NumericalStyleSubject($('additionalLinks'), 'opacity', 0, 1))
			.addSubject(new NumericalStyleSubject($('mainLogo'), 'opacity', 1, 0));
		animOut.play();
	
		return false;
	} else {
		return true;
	}
}



/* Function to evaulate on page resize, and after dynamically inserting content */
var prevContentHeight=0;
function adjustHeight() {

	//hide items so as not to affect page height (only if this is a down-sizing!)
	if (prevContentHeight>0 && prevContentHeight > $('contentArea').offsetHeight) {
		$('waveContainer').style.display = 'none';
		$('vertBar').style.display = 'none';
		$('smallLogo').style.display = 'none';
	}
	
	//adjust height to take into account new content
	var docHeight = getPageHeight();

	//display again
	$('waveContainer').style.display = 'block';
	$('vertBar').style.display = 'block';
	$('smallLogo').style.display = 'block';
	
	//make adjustments
	$('vertBar').style.height = docHeight+'px';
	$('waveContainer').style.top = (docHeight-60-20)+'px';
	$('smallLogo').style.top = (docHeight-40-125)+'px';
	
	prevContentHeight = $('contentArea').offsetHeight;

}



/* Set of functions to animate the bulletin board, and keep it cycling */
var currentBB = 1;
var numBBs = 3;
var animHideBB, animShowBB, timerBB;
function changeBB() {
	hideBB();
	timerBB = setTimeout('changeBB()',5000);
}		
function hideBB() {
	animHideBB = new Animator({
		onComplete: function() { 
			$('bb_'+currentBB).style.display='none';
			currentBB = (currentBB%numBBs)+1;
			showBB(); 
		}
	}).addSubject(new NumericalStyleSubject($('bb_'+currentBB), 'opacity', 1, 0));
	animHideBB.play();
}
function showBB() {
	$('bb_'+currentBB).style.display='block';
	animShowBB = new Animator().addSubject(new NumericalStyleSubject($('bb_'+currentBB), 'opacity', 0, 1));
	animShowBB.play();
}		


/* Construct animator for waves, and repeat the animation */
var animWaves;
function initAnimWaves() {
	animWaves = new Animator({
		duration: 4500,
		onComplete: animateWaves,
		transition: Animator.tx.linear
	})
	 .addSubject(new NumericalStyleSubject($('waves_1'), 'background-position',0,844))
	 .addSubject(new NumericalStyleSubject($('waves_2'), 'background-position',844,0));
	 animWaves.play();
}
function animateWaves() {
	animWaves.play();
}



/* Page onload function */
function doOnLoad() {
	if (triggerBB) setTimeout('changeBB()',5000);
	initAnimWaves();
}





/* The following functions are referred to by the generic functions in dynamicContent.js
   that are design to display different sections of Site Manager content on the page. 
   These functions are obviously dependant on the site layout, so are separated from the
   dynamicContent.js scripts */
   
function siteManagerLoading(show) {
	//show loader
	$('contentLoading').style.display=(show?'block':'none');
}


/* Function to content area (animated) */
var animContent;
function showContent(pageid) {
	//and then display it 
	$('contentArea').style.display='block';
	
	adjustHeight();
	
	animContent = new Animator()
		.addSubject(new NumericalStyleSubject($('contentArea'), 'opacity', 0, 1));
	animContent.play();

}

//Renders HTML content and triggers animation in 
function renderContent(content) {
	//populate content
	$('contentArea').innerHTML = content;
	showContent();
}


/* Function to show title bar (animated) */
var animTitle;
function showTitle() {
	animTitle = new Animator()
		.addSubject(new CSSStyleSubject($('titleBar'), 'top: 17px;'));
	animTitle.play();
}

//function to render title image and then trigger animation
function renderTitle(title) {
	dtUrl = phpHttpRoot+'/app/dt/?text='+title+'+';
	$('titleDT').onload=showTitle;
	$('titleDT').src=dtUrl;
}


//function to display page photos from array of URLs
function renderPagePhotos(PagePhotoDetail) {
	$('pagePhotos').style.display='block';
	$('pagePhotos').innherHTML='';
	for(i=0;i<PagePhotoDetail.length;i++) {
		$('pagePhotos').innerHTML += '<img class="zeroOpacity" id="pagePhoto_'+i+'" alt="'+(PagePhotoDetail[i]['AltText']?PagePhotoDetail[i]['AltText'].replace('"','\\"'):'')+'" onload="showPagePhoto(this);" />';
		$('pagePhoto_'+i).src=PagePhotoDetail[i]['URL'];
	}
}

var animPagePhotos;
function showPagePhoto(thisPagePhoto) {
	animPagePhotos = new Animator({
		//onComplete: adjustHeight
		})
		.addSubject(new NumericalStyleSubject(thisPagePhoto, 'opacity', 0, 1))
	animPagePhotos.play();
}





/* Adjust font size of ContentArea div, and set cookie for next page */
function doFontAdjust(sz) {
	$('contentArea').style.fontSize = sz+'em';
	createCookie('fontSizeAdjust',sz,30);
}



//-->	
