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 (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() {	if ((document.getElementById('myGallery'))) {		var myGallery = new gallery($('myGallery'), {			timed: window.g_timed,			showArrows: window.g_showArrows,			showCarousel: window.g_showCarousel,			showInfopane: window.g_showInfopane,			embedLinks: window.g_embedLinks,			useReMooz: window.g_useReMooz			})		}	})addLoadEvent(function() {		if (document.getElementById("map_canvas")) {		var map = new GMap2(			document.getElementById("map_canvas"));			map.setCenter( new GLatLng(window.lat,window.lng),window.mapScale);			map.addControl(new GLargeMapControl());			map.addControl(new GMapTypeControl());			var lsc = new google.maps.LocalSearch();			map.addControl(new google.maps.LocalSearch()			);		function createMarker(point,html,title) {			var marker = new GMarker(point,{title:title});						GEvent.addListener(				marker, "click", function() {					marker.openInfoWindowHtml(html);					});			return marker;			}        		var point = new GLatLng(window.lat,window.lng)		var html = window.mapHTML + '<br><form action="javascript:getDirections()">' +		'From (post code): <input type="text" SIZE=8 MAXLENGTH=8 name="saddr" id="saddr" value="" /><br>' +		'Walk <input type="checkbox" name="walk" id="walk" /> &nbsp; Avoid main roads <input type="checkbox" name="highways" id="highways" />' +		'<INPUT value="Get Directions" TYPE="SUBMIT"><br>' +		'<input type="hidden" id="daddr" value="'+ window.mapTitle +'@'+ window.lat + ',' + window.lng + '"/></form></div>'        		var marker = createMarker(point,html,window.mapTitle);		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);			});				}		})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);	}addLoadEvent(function() {		var flashvars = {		affcode: window.affcode		}	var params = {}	var attributes = {}	var i	var MyBanner = window.bannerArray		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 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.onchange = getPage						}					}				}			}		}	})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)		}	})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 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();	}addLoadEvent(function() {	var formObject	if ((formObject = document.getElementById('loginform'))) {		var conField = document.getElementById('confirm')		var conDiv = conField.parentNode		conDiv.style.display = 'none'		var emailField = document.getElementById('email')		var emailDiv = emailField.parentNode		emailDiv.style.display = 'none'		var codeField = document.getElementById('code')		var codeDiv = codeField.parentNode		codeDiv.style.display = 'none'		var noteField = document.getElementById('note')		var noteDiv = noteField.parentNode		noteDiv.style.display = 'none'				var myLogin = document.getElementById('login')		var myRegister = document.getElementById('register')				myLogin.showCon = conDiv		myLogin.showEmail = emailDiv		myLogin.showCode = codeDiv		myLogin.showNote = noteDiv				myRegister.showCon = conDiv		myRegister.showEmail = emailDiv		myRegister.showCode = codeDiv		myRegister.showNote = noteDiv				myLogin.onfocus = loginSwitch		myRegister.onfocus = registerSwitch				formObject.username = document.getElementById('username')		formObject.password = document.getElementById('password')		formObject.confirm = conField		formObject.email = emailField		formObject.code = codeField		formObject.register = myRegister		formObject.onsubmit = validate 		}	})addLoadEvent(function() {	if ((deleteRecord = document.getElementById('deleteRecord'))) {		deleteRecord.onfocus = deleteAlert		}	})function deleteAlert() {	alert('Important: this action cannot be undone; uncheck delete if you wish to maintain this record')	}function loginSwitch() {	this.showCon.style.display = 'none'	this.showEmail.style.display = 'none'	this.showCode.style.display = 'none'	this.showNote.style.display = 'none'	}function registerSwitch() {	this.showCon.style.display = 'block'	this.showEmail.style.display = 'block'	this.showCode.style.display = 'block'	this.showNote.style.display = 'block'	}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	}		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		}	})function expandFrame() {	clearData(this)	if (window.myFrame == 'expand') { window.myFrame = 'retract' }	else { window.myFrame = 'expand' }	if (window.myFrame == 'expand') {		this.paFrame.style.width = '1050px'		this.paFrame.style.borderColor = '#333'		this.paFrame.style.borderStyle = 'solid'		this.paFrame.style.borderWidth = '2px'		this.paFrame.style.left = '-250px'		this.appendChild(document.createTextNode('Make panel narrower'))		}	if (window.myFrame == 'retract') {		this.paFrame.style.borderStyle = 'none'		this.paFrame.style.width = '750px'		this.paFrame.style.left = '0'		this.appendChild(document.createTextNode('Make panel wider'))		}	}function getPage() {	var getString = this.options[this.selectedIndex].value	if (getString != '') {		var myObject = document.getElementById('rCustom')		if ((myObject)) {			if (myObject.checked == true) { var plusString = '&option=rCustom' }			else { var plusString = '' }			}		else { var plusString = '' }		var getUrl = 'edit.php?page=' + getString + plusString		window.location.href = getUrl		}	}	addLoadEvent(function() {	var getThumbs	if ((getThumbs = document.getElementById('selectThumbs'))) {		getThumbs.side = document.getElementById('side')		getThumbs.onclick = showThumbs		}	})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) {	this.myURL = myURL;	this.myWidth = myWidth;	this.myHeight = myHeight;	}function winLinks(myClass,myURL) {	var myLinks = {}	myLinks['extlink'] = new myWindow(myURL,900,600)	myLinks['display'] = new myWindow(myURL,600,600)	if ((myLinks[myClass])) return myLinks[myClass];	}	function newWindow() {	var myWin = this.item;	if ((myWin)) {		var thisWin;		thisWin = window.open(myWin.myURL,'popup','toolbar=no,location=no,scrollbars=yes,resizable=yes,width=' + myWin.myWidth + ',height=' + myWin.myHeight);		thisWin.focus();		return false;		}	}function clearData(myLabel) {	while (myLabel.childNodes[0]) {    		myLabel.removeChild(myLabel.childNodes[0]);    		}	}function isInteger(s) {	return (s.toString().search(/^-?[0-9]+$/) == 0);	}