function addLoadEvent(func) {    var oldonload = window.onload;    if (typeof window.onload != 'function') { window.onload = func; }    else {    	window.onload = function() {			if (oldonload) {				oldonload();            	}			func();        	}    	}	}addLoadEvent(function() {	if ((document.getElementById('twitter'))) {		jQuery("#twitter").getTwitter({			userName: window.t_username,			numTweets: window.t_tweets,			loaderText: "Loading tweets...",			slideIn: true,			slideDuration: 750,			showHeading: true,			headingText: "Latest Tweet",			showProfileLink: true,			showTimestamp: true			})		}	})addLoadEvent(function() {	if ((document.getElementById('myGallery'))) jQuery('#myGallery').spacegallery({loadingClass: 'loading'});	})addLoadEvent(function() {	if (jQuery('dt.theme') != null) {		jQuery('dt.theme').click(function() {			jQuery('dd.title').slideUp('normal');				jQuery(this).next().slideDown('normal');			});		jQuery("dd.title").hide();		jQuery("dt.open").trigger('click');				jQuery("dd.btitle").hide();		jQuery("dt.bopen").trigger('click');		}	})addLoadEvent(function() { rotate() })addLoadEvent(function() {	if (document.getElementById("navigation")) {		if (window.attachEvent) {			var sfEls = document.getElementById("navigation").getElementsByTagName("li");			for (var i=0; i<sfEls.length; i++) {				sfEls[i].onmouseover=function() {					this.className+=" sfhover";					}				sfEls[i].onmouseout=function() {					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");					}				}			}		}	})addLoadEvent(function() {	var mySearch	if ((mySearch = document.getElementById('q_search'))) {		if (window.q_search != 'clicked') mySearch.setAttribute('value','search')		mySearch.onclick = unSearch		}	})addLoadEvent(function() {	if ((document.getElementById('slideshow'))) var slideshow = new BarackSlideshow('menu', 'pictures', 'loading', {transition: window.g_transition, auto: window.g_auto})	})addLoadEvent(function() {		function createIcon() {		var Icon = new GIcon()		Icon.image = window.map.iconimage		Icon.iconSize = new GSize(window.map.iconsize[0],window.map.iconsize[1])		Icon.shadow = window.map.iconshadow		Icon.shadowSize = new GSize(window.map.shadowsize[0],window.map.shadowsize[1])		Icon.iconAnchor = new GPoint(window.map.iconanchor[0],window.map.iconanchor[1])		Icon.infoWindowAnchor = new GPoint(window.map.infowindowanchor[0],window.map.infowindowanchor[1])		Icon.transparent = window.map.icontransparent		Icon.printImage = window.map.printimage		Icon.mozPrintImage = window.map.mozprintimage		Icon.printShadow = window.map.printshadow		Icon.imageMap= window.map.imagemap		return Icon		}	if ((document.getElementById(window.map.mapid))) {		var map = new GMap2(document.getElementById(window.map.canvasid));		map.setCenter(			new GLatLng(window.map.glatlng[0],window.map.glatlng[1]),			window.map.glatlng[2]			);		map.addControl(new GLargeMapControl());		map.addControl(new GMapTypeControl());;		function createMarker(point,text,title,iconType) {			var myIcon = createIcon()			if (iconType == 1) var marker = new GMarker(point,myIcon);			else var marker = new GMarker(point,{title:title});			GEvent.addListener(				marker, "click", function() {					marker.openInfoWindowHtml(text);					});			return marker;			}				var location = window.map.location		var i		for (i=0;i<location.length;i++) {			var WINDOW_HTML = window.map.bubbletext[i] + "<br /><form action='javascript:getDirections()'>" +			"From (post code): <input type='text' size=8 maxlength=8 name='saddr' id='saddr' value=''><br><br>" +			window.map.walk + 			"Avoid main roads <input type='checkbox' name='highways' id='highways'>" +			" <input value='Get Directions' type='submit'><br>" +			"<input type='hidden' id='daddr' value='" + window.map.location[i] +"@" + window.map.glatlngspec[i][0] + "," + window.map.glatlngspec[i][1] + "'></form></div>"						var marker = createMarker(				new GLatLng(window.map.glatlngspec[i][0],window.map.glatlngspec[i][1]),        		WINDOW_HTML,window.map.location[i],        		1);			map.addOverlay(marker);			}               				// === create a GDirections Object ===		window.gdir = new GDirections(map, document.getElementById("directions"));		// === Array for decoding the failure codes ===		var reasons=[];		reasons[G_GEO_SUCCESS]            = "Success";		reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";		reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";		reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";		reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";		reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";		reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";		reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";		reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";		reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";				// === catch Directions errors ===		GEvent.addListener(gdir, "error", function() {			var code = gdir.getStatus().code;			var reason="Code "+code;			if (reasons[code]) {				reason = reasons[code]				} 			alert("Failed to obtain directions, "+reason);			});					}			})addLoadEvent(function() {		var flashvars = {		affcode: window.affcode		}	var params = {}	var attributes = {}	var i	var MyBanner = window.bannerArray		params.wmode = 'transparent';		if ((window.swfobject)) {		for (i in MyBanner) {			var banner = MyBanner[i][0]			if ((document.getElementById(banner))) {				var movieName = MyBanner[i][1]				var mwidth = MyBanner[i][2]				var mheight = MyBanner[i][3]				var mVer = MyBanner[i][4]				swfobject.embedSWF(movieName,banner,mwidth,mheight,mVer,false,flashvars,params,attributes)				}			}		}	})addLoadEvent(function() {	var selectObject = {}	var archive = window.archive	for (var i=0; i<archive.length; i++) {		if ((selectObject = document.getElementById(archive[i][0]))) {			var selectGo = document.getElementById(archive[i][3])			selectGo.style.display = 'none'			selectObject.archiveURL = archive[i][1] + '.php?' + archive[i][2] + '='			selectObject.onchange = getPage			}		}	})addLoadEvent(function() {	var i,j	if ((document.getElementById('edit'))) {		var myForms = document.getElementsByTagName('form')		for (var i=0; i < myForms.length; i++) {			var formClassObject = myForms[i].getAttributeNode('class')			if (formClassObject != null) {				if (formClassObject.value == 'page_select') {					var mySelects = myForms[i].getElementsByTagName('select')					for (j in mySelects) {						var myOption = mySelects[j]						myOption.page_id = 'edit'						myOption.element_id = 'rCustom'						myOption.onchange = getEdit						}					}				}			}		}	})addLoadEvent(function() {	window.field = new Array()	var myFields = document.getElementsByTagName('fieldset')	for (var i=0; i < myFields.length; i++) {		if (myFields[i].className == 'expanData') doToggle(myFields[i],i)		}	})addLoadEvent(function() {	if ((deleteRecord = document.getElementById('deleteRecord'))) {		deleteRecord.onfocus = deleteAlert		}	})		addLoadEvent(function() {	if ((document.getElementById('quote'))) {		document.getElementById('quote').innerHTML = text;		}	})	addLoadEvent(function() {	var myLinks,linkClassObject	if ((myLinks = document.getElementsByTagName('a'))) {		var myWinLink, myWinURL, MyLink;		for (i in myLinks) {			if (isInteger(i)) {				MyLink = myLinks[i]				var linkClassObject = myLinks[i].getAttributeNode('class')				if (linkClassObject != null) {					myWinLink = linkClassObject.value;					var urlClassObject = myLinks[i].getAttributeNode('href');					if (urlClassObject != null) myWinURL = urlClassObject.value;					MyLink.item = winLinks(myWinLink,myWinURL);					MyLink.onclick = newWindow;					}				}			}		}		})	addLoadEvent(function() {	var paneSpan	if ((paneSpan = document.getElementById('paneSpan'))) {		paneSpan.paFrame = document.getElementById('paFrame')		paneSpan.onclick = expandFrame		}	})	addLoadEvent(function() {	var getThumbs	if ((getThumbs = document.getElementById('selectThumbs'))) {		getThumbs.side = document.getElementById('side')		getThumbs.onclick = showThumbs		}	})/* FUNCTIONS */function unSearch() {	window.q_search = 'clicked'	this.setAttribute('value','')	}function getDirections() {	var opts = {};	if (document.getElementById("walk").checked) {		opts.travelMode = G_TRAVEL_MODE_WALKING;		}	if (document.getElementById("highways").checked) {		opts.avoidHighways = true;		}	var saddr = document.getElementById("saddr").value	var daddr = document.getElementById("daddr").value	window.gdir.load("from: "+saddr+" to: "+daddr, opts);	}function doToggle(myFieldset,i) {	var j	var myDivs = myFieldset.getElementsByTagName('div')	var myFImage = myFieldset.firstChild.getElementsByTagName('img')[0]	window.field[i] = 0	myFImage.incr = i	myFImage.myDivs = myDivs	myFImage.onmouseover = LegendImageOver	myFImage.onmouseout = LegendImageOut	myFImage.onclick = accessFields	for (j in myDivs) {		if ((isInteger(j))) {			var myDiv = myDivs[j]			myDiv.style.display = 'none'			}		}	}function LegendImageOver() {	var incr = this.incr	if (window.field[incr] == 0) { this.src = 'images/openFieldOver.gif' }	else { this.src = 'images/closeFieldOver.gif' }	}function LegendImageOut() {	var incr = this.incr	if (window.field[incr] == 0) { this.src = 'images/openField.gif' }	else { this.src = 'images/closeField.gif' }	}function rotate() {	var c	var imgCount = window.imgCount	var slideDir = window.slideDir	var slideArray = window.slideArray	var frameImages = new Array(imgCount)	if ((document.getElementById('slideImage'))) {		var imgSlide = document.getElementById('slideImage')		for(c=0; c<imgCount; c++) {			frameImages[c] = "images/slides/" + slideArray[c]			}		imgSlide.src = frameImages[window.startCount]		window.startCount = window.startCount + 1		if (window.startCount == imgCount) {window.startCount = 0}		setTimeout("rotate()",2 * 2000)		}	}function accessFields() {	var j	var incr = this.incr	if (window.field[incr] == 1) { window.field[incr] = 0 }	else { window.field[incr] = 1 }	var myDivs = this.myDivs	for (j in myDivs) {		if ((isInteger(j))) {			var myDiv = myDivs[j]			if (window.field[incr] == 0) {				myDiv.style.display = 'none'				this.src = 'images/openField.gif'				this.setAttribute('alt','open field')				this.setAttribute('title','open field')				}			else {				myDiv.style.display = 'block'				this.src = 'images/closeField.gif'				this.setAttribute('alt','hide field')				this.setAttribute('title','hide field')				}			}		}	}function submitform() {	this.myForm.submit();	}function deleteAlert() {	alert('Important: this action cannot be undone; uncheck delete if you wish to maintain this record')	}
function validate() {	if (this.register.checked == true) {		if (this.password.value != this.confirm.value) {			alert('Register: You have not confirmed your password correctly')			return false			}		else if (this.username.value == "" || this.password.value == "" || this.email.value == "") {			alert('Register: You have missed a field')			return false			}		else return true		}	else if (this.username.value == "" || this.password.value == "") {			alert('Login: You have missed a field')			return false			}	else return true	}function expandFrame() {	clearData(this)	if (window.myFrame == 'expand') { window.myFrame = 'retract' }	else { window.myFrame = 'expand' }	if (window.myFrame == 'expand') {		this.paFrame.style.display = 'block'		this.paFrame.style.position = 'absolute'		this.paFrame.style.width = '600px'		this.paFrame.style.height = '600px'		this.paFrame.style.borderColor = '#333'		this.paFrame.style.borderStyle = 'solid'		this.paFrame.style.borderWidth = '2px'		this.paFrame.style.left = '-300px'		this.appendChild(document.createTextNode('(Close)'))		}	if (window.myFrame == 'retract') {		this.paFrame.style.display = 'none'		this.appendChild(document.createTextNode('(Open)'))		}	}function getPage() {	var getNo = this.options[this.selectedIndex].value	var archive = this.archiveURL	if (getNo != '') {		var getUrl = archive + getNo		window.location.href = getUrl		}	}function getEdit() {	var getString = this.options[this.selectedIndex].value	if (getString != '') {		var myObject = document.getElementById(this.element_id)		if ((myObject)) {			if (myObject.checked == true) { var plusString = '&option=' + this.element_id }			else { var plusString = '' }			}		else { var plusString = '' }		var getUrl = 'index.php?pageid=' + this.page_id + '&page=' + getString + plusString		window.location.href = getUrl		}	}function showThumbs() {	while (this.childNodes[0]) {    	this.removeChild(this.childNodes[0]);    	}	if ((!window.thumb) || window.thumb == 'hide') { window.thumb = 'show' }	else { window.thumb = 'hide' }	if (window.thumb == 'show') {		this.side.style.display = 'block'		this.appendChild(document.createTextNode('Hide thumbnails'))		}	if (window.thumb == 'hide') {		this.side.style.display = 'none'		this.appendChild(document.createTextNode('View thumbnails of all styles'))		}	}function myWindow(myURL,myWidth,myHeight,myNav,myRelative) {	this.myURL = myURL;	this.myWidth = myWidth;	this.myHeight = myHeight;	this.myNav = myNav;	this.myRelative = myRelative;	}function winLinks(myClass,myURL) {	var mc,mw,mh,mn,mr	var linksArray = window.windowLinks	var myLinks = {}	for (var i=0;i<linksArray.length;i++) {		mc = linksArray[i][0]		mw = linksArray[i][1]		mh = linksArray[i][2]		mn = linksArray[i][3]		mr = linksArray[i][4]		myLinks[mc] = new myWindow(myURL,mw,mh,mn,mr)		}	var myNewWindow = myLinks[myClass];	return  myNewWindow;	}	function newWindow() {	var thisWin;	var myWin = this.item;	if (myWin) {		if (myWin.myRelative == 'parent') {			updateParent(myWin.myURL);			window.close();			}		else {			thisWin = window.open(myWin.myURL,'popup','toolbar=' + myWin.myNav + ',location=' +  myWin.myNav + ',scrollbars=yes,resizable=yes,width=' + myWin.myWidth + ',height=' + myWin.myHeight);			thisWin.focus();			return false;			}		}	}function updateParent(newURL) {	myParent = window.opener	if (myParent != null && newURL !='') myParent.document.location = newURL	}function clearData(myLabel) {	while (myLabel.childNodes[0]) {    		myLabel.removeChild(myLabel.childNodes[0]);    		}	}function isInteger(s) {	return (s.toString().search(/^-?[0-9]+$/) == 0);	}
