 	var Dom = YAHOO.util.Dom;
	var YE = YAHOO.util.Event;
	var YM = YAHOO.util.Motion;
	var $ = Dom.get;
	var sUrl;
	var postData;
	var setFormData;
	var menuSize;

	YAHOO.widget.Chart.SWFURL = "/resources/js/library/charts.swf";

	YE.onDOMReady(function(){
		var dataSource = $('data');
		if(dataSource){
			YAHOO.example.Basic = function() {
		        var myColumnDefs = [
		            {key:"id", sortable:true, resizeable:true},
		            {key:"heading", sortable:true,resizeable:true},
		            {key:"author", sortable:true, resizeable:true},
		            {key:"date", sortable:true, resizeable:true}
		        ];

		        var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.blogDetails);
		        myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
		        myDataSource.responseSchema = {
		            fields: ["id","heading","author","date"]
		        };

		        var myDataTable = new YAHOO.widget.DataTable(dataSource,
		                myColumnDefs, myDataSource, {caption:"Blogs In The Database"});

		        return {
		            oDS: myDataSource,
		            oDT: myDataTable
		        };
		    }();
		}
	});

	function init(){

		var chartSource = $('chartsource');
		if(chartSource){
		    var jsonData = new YAHOO.util.DataSource( "/components/chartsource.class.php" );
		    jsonData.connMethodPost = true;
			jsonData.responseType = YAHOO.util.DataSource.TYPE_JSON;
			jsonData.responseSchema =
			{
					resultsList: "Results",
					fields: ["Name","Value"]
			};

			var yAxis = new YAHOO.widget.NumericAxis();
			yAxis.minimum = 0;
			yAxis.maximum = 500;

			var mychart = new YAHOO.widget.ColumnChart(chartSource, jsonData,
			{
				xField: "Name",
				yField: "Value",
				yAxis: yAxis,
				polling: 5000
			});
		}

		menuSize = Dom.getRegion('fixedmenu1');
		menuSize = menuSize['bottom'] - menuSize['top'];

		var minimiseLink = $('minimiseLink');
		if(minimiseLink){
			YE.on(minimiseLink, 'click', minimiseMenu);
		}

		var maximiseLink = $('maximiseLink');
		if(maximiseLink){
			YE.on(maximiseLink, 'click', maximiseMenu);
		}

		var comments = Dom.getElementsByClassName('ajax-call');
		for(var i=0; i<comments.length; i++){
			var theLink = comments[i];
			YE.on(theLink, 'click', makeRequest);
		}

		var viewCh = Dom.getElementsByClassName('change-view');
		for(var i=0; i<viewCh.length; i++){
			var theLink1 = viewCh[i];
			YE.on(theLink1, 'click', makeRequest);
		}

		var subMit = document.getElementById('searchform');
		if(subMit){
			YE.on(subMit, 'submit', formRequest);
		}

		/*var commentForm = document.getElementById('f');
		if(commentForm){
			YE.on(commentForm, 'submit', commentRequest);
		}*/

		//Above is the script for the comments form ajax

		var nextLink = Dom.getElementsByClassName('next');
		for(var i=0; i<nextLink.length; i++){
			var theLink3 = nextLink[i];
			YE.on(theLink3, 'click', makeRequest);
		}

		//these two little rules add ajax to the history page. To reinitialise them just un comment this section

		var prevLink = Dom.getElementsByClassName('previous');
		for(var i=0; i<prevLink.length; i++){
			var theLink4 = prevLink[i];
			YE.on(theLink4, 'click', makeRequest);
		}

		var commentLink = document.getElementById('showComment');
		if(commentLink){
			YE.on(commentLink, 'click', hideCommentBox);
			var commentBox = document.getElementById('commentBox');
			commentBox.style.overflow = 'hidden';
		}

		var mapInput = document.getElementById('getDirections');
		if(mapInput){
			mapInput = mapInput.loc;
			YE.on(mapInput, 'click', hideText);
		}
		var scrollTop = document.getElementById('scrollTop');
		if(scrollTop){
		    var scrollElement = document.getElementsByTagName('html');
		    scrollElement = scrollElement[0];
			var attributes = {
	        	scroll: { to: [0, 0] }
		    };
			var scrollAnim = new YAHOO.util.Scroll(scrollElement, attributes, 2, YAHOO.util.Easing.easeBothStrong);
			YE.on(scrollTop, 'click', function (){
			    /*var scrollElement = document.getElementById('top');*/
			    scrollAnim.animate();
			});
		}
		/*var loginLink = document.getElementById('loginLink');
		if(loginLink){
			YE.on(loginLink, 'click', loginRequest);
		}*/
		var logoutLink = document.getElementById('logoutLink');
		if(logoutLink){
			YE.on(logoutLink, 'click', logoutRequest);
		}
		/*var registerLink = document.getElementById('registerLink');
		if(registerLink){
			YE.on(registerLink, 'click', registerRequest);
		}*/
		var statsLinks = Dom.getElementsByClassName('statsAjax');
		for(var i=0; i<statsLinks.length; i++){
			var statsLink = statsLinks[i];
			YE.on(statsLink, 'click', statsRequest);
		}
		var whisperPops = Dom.getElementsByClassName('whisperPop');
		for(var i=0; i<whisperPops.length; i++){
			var whisperPop = whisperPops[i];
			YE.on(whisperPop, 'click', popWhisper);
		}
		var viewWhisperLinks = Dom.getElementsByClassName('viewWhisper');
		for(var i=0; i<viewWhisperLinks.length; i++){
			var viewWhisperLink = viewWhisperLinks[i];
			YE.on(viewWhisperLink, 'click', viewWhisper);
		}
		var removeWhispers = Dom.getElementsByClassName('removeLink');
		for(var i=0; i<removeWhispers.length; i++){
			var removeWhisperLink = removeWhispers[i];
			YE.on(removeWhisperLink, 'click', removeWhisper);
		}
		/*var sendWhisperLinks = Dom.getElementsByClassName('sendWhisper');
		for(var i=0; i<sendWhisperLinks.length; i++){
			var sendWhisperLink = sendWhisperLinks[i];
			YE.on(sendWhisperLink, 'click', sendWhisper);
		}*/
		var editGigLinks = Dom.getElementsByClassName('editGig');
		for(var i=0; i<editGigLinks.length; i++){
			var editGigLink = editGigLinks[i];
			YE.on(editGigLink, 'click', editGig);
		}
		var checkInputs = Dom.getElementsByClassName('checkInput');
		if(checkInputs.length > 0){
			for(var i=0;i<checkInputs.length;i++){
				var newImg = document.createElement('img');
				newImg.setAttribute('src', '/resources/images/warn.png');
				newImg.setAttribute('title', 'This field is required');
				newImg.setAttribute('class', 'errorImg');
				newImg.setAttribute('className', 'errorImg');
				checkInputs[i].parentNode.appendChild(newImg);

				/* Check a single field option*/
				YE.on(checkInputs[i], 'keyup', checkSingleFormDetails);
				YE.on(checkInputs[i], 'blur', checkSingleFormDetails);
			}

			/**
			 * Creates a paragraph at the end of the form with a small key indicating what the
			 * warning image actually means
			 *
			 **/
			var reqField = document.createElement('p');
			var form = Dom.getAncestorByTagName(checkInputs[0], 'form');
			form.appendChild(reqField);
			var newImg = document.createElement('img');
			newImg.setAttribute('src', '/resources/images/warn.png');
			newImg.setAttribute('title', 'This field is required');
			reqField.appendChild(newImg);
			newImg.setAttribute('style', 'padding: 0 10px; float: none; margin: 0; border: 0;');
			newImg.style.cssText = 'padding: 0 10px; float: none; margin: 0; border: 0;';
			reqField.appendChild(document.createTextNode('Denotes a required field'));
		}
		var submitInputs = document.getElementById('blogF');
		YE.on(submitInputs, 'submit', checkFormDetails);

		var submitInput = document.getElementById('f');
		YE.on(submitInput, 'submit', checkFormDetails);

		var notepad = $('notepad');
		if(notepad){
			setInterval("refreshNotepad()", 10000);
		}

		var notepadForm = $('notePadForm');
		if(notepadForm){
			YE.on(notepadForm, 'submit', postNote);
		}
	}

	function updateInit(){
		var notes = Dom.getElementsByClassName('note');
		for(var i=0; i< notes.length; i++){
			Dom.setStyle(notes[i], 'opacity', '0.5');
			YE.on(notes[i], 'mouseover', function(){
				Dom.setStyle(this, 'opacity', '1');
			});
			YE.on(notes[i], 'mouseout', function(){
				Dom.setStyle(this, 'opacity', '0.5');
			});
			if($('currentUser').innerHTML == 'ahallicks' || $('currentUser').innerHTML == 'RockyRoad'){
				var newLink = document.createElement('a');
				notes[i].appendChild(newLink);
				newLink.setAttribute('href', '/notepad');
				newLink.setAttribute('title', 'Unpin This Post From The Wall');
				newLink.style.cssText = 'position: absolute;top:5px;right:5px;display:block;width:24px;height:24px;background:none;';
				YE.on(newLink, 'click', removeNote);
			}
/*			var notePerson = notes[i].getElementsByTagName('h4')[0];
			if($('currentUser').innerHTML == notePerson.innerHTML){
				var editLink = document.createElement('a');
				notes[i].appendChild(editLink);
				editLink.setAttribute('href', '/notepad');
				editLink.setAttribute('title', 'Unpin This Post From The Wall');
				editLink.style.cssText = 'position: absolute;top:35px;right:5px;display:block;width:24px;height:24px;background:none;';
				editLink.appendChild(document.createTextNode('Edit'));
				YE.on(editLink, 'click', removeNote);
			}
*/
		}
	}

	var updateNotepad = {
		customevents:{
	        onComplete:function(eventType, args){
			},
	        onSuccess:function(eventType, args){
				if(args[0].responseText !== undefined){
					var oldNotepad = $('notepad');
					oldNotepad.id = 'oldNotepad';
					var responseDiv = $('getResponse');
					responseDiv.innerHTML = args[0].responseText;
					var newNotepad = $('notepad');
					oldNotepad.innerHTML = newNotepad.innerHTML;
					oldNotepad.id = 'notepad';

					updateInit();
				}
			},
	        onFailure:function(eventType, args){
				if(args[0] !== undefined){
					var errorMsg = "There was a slight hiccup";
				}
	        }
	    },
	  timeout: 200000
	};

	var showNewPost = {
		customevents:{
	        onComplete:function(eventType, args){
			},
	        onSuccess:function(eventType, args){
				if(args[0].responseText !== undefined){
					var oldNotepad = $('notepad');
					oldNotepad.id = 'oldNotepad';
					var responseDiv = $('getResponse');
					responseDiv.innerHTML = args[0].responseText;
					var newNotepad = $('notepad');
					oldNotepad.innerHTML = newNotepad.innerHTML;
					oldNotepad.id = 'notepad';

					$('note').innerHTML = '';
					$('note').value = '';

					$('postNote').removeAttribute('disabled');
					$('postNote').setAttribute('value', 'Post Note');

					updateInit();
				}
			},
	        onFailure:function(eventType, args){
				if(args[0] !== undefined){
					var errorMsg = "There was a slight hiccup";
				}
	        }
	    },
	  timeout: 200000
	};

	function refreshNotepad(){
		var notepad = $('notepad');
		if(notepad){
			sUrl = '/notepad';
			var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, updateNotepad, null);
		}
	}

	function postNote(e){
		YE.stopEvent(e);
		sUrl = '/notepad';
		postData = 'postNote=true&note=' + $('note').value;
		var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, showNewPost, postData);

		$('postNote').setAttribute('disabled', 'disabled');
		$('postNote').setAttribute('value', 'Posting Your Note');
	}

	function removeNote(e){
		YE.stopEvent(e);
		sUrl = this.href;
		var noteId = Dom.getPreviousSibling(this);
		noteId = noteId.getAttribute('id');
		noteId = noteId.split('-');
		noteId = noteId[1];
		postData = 'removeNote=true&noteId=' + noteId;
		var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, updateNotepad, postData);
	}

	function minimiseMenu(e){
		YE.stopEvent(e);
		var minimiseLink = $('minimiseLink');
		if(minimiseLink){
			$('fixedmenu1').style.overflow = 'hidden';
			var hideAnim = new YAHOO.util.Anim("fixedmenu1", {
				height: { to: 0 },
				opacity: { from: 1, to: 0 }
			}, 2, YAHOO.util.Easing.easeOut);
			hideAnim.animate();
			hideAnim.onComplete.subscribe(changeLinksSmall);
		}
	}

	function maximiseMenu(e){
		YE.stopEvent(e);
		var maximiseLink = $('maximiseLink');
		if(maximiseLink){
			$('fixedmenu1').style.overflow = 'hidden';
			var hideAnim = new YAHOO.util.Anim("fixedmenu1", {
				height: { to: menuSize },
				opacity: { to: 1 }
			}, 2, YAHOO.util.Easing.easeOut);
			hideAnim.animate();
			hideAnim.onComplete.subscribe(changeLinksBig);
		}
	}

	function changeLinksSmall(){
		var minimiseLink = $('minimiseLink');
		if(minimiseLink){
			minimiseLink.setAttribute('id', 'maximiseLink');
			minimiseLink.innerHTML = 'Maximise';
			YE.on(minimiseLink, 'click', maximiseMenu);
		}
	}

	function changeLinksBig(){
		var maximiseLink = $('maximiseLink');
		if(maximiseLink){
			maximiseLink.setAttribute('id', 'minimiseLink');
			maximiseLink.innerHTML = 'Minimise';
			YE.on(maximiseLink, 'click', minimiseMenu);
		}
	}

	var handleSuccess = function(o){

		var successBox = $('success');
		var thesrc = $('callback');
		/*var oldsrc = document.getElementsByTagName('html');
		oldsrc = oldsrc[0];*/
		var oldWrapper = $('top');

		if(o.responseText !== undefined){
			/*thesrc.innerHTML = "<p>Success!</p>";
			thesrc.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
			thesrc.innerHTML += "<li>HTTP status: " + o.status + "</li>";
			thesrc.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
			thesrc.innerHTML += "<li>HTTP headers: <ul>" + o.getAllResponseHeaders + "</ul></li>";
			oldsrc.innerHTML += "PHP response: " + o.responseText;*/
			//oldsrc.innerHTML = o.responseText;
			oldWrapper.innerHTML = o.responseText;
			var newWrapper = $('top');
			oldWrapper.innerHTML = newWrapper.innerHTML;
			setTimeout("hideSuccess()", 5000);
			YE.onDOMReady(init);
		}
	}

	var handleFailure = function(o){

		YAHOO.log("The failure handler was called.  tId: " + o.tId + ".", "info", "example");
		var successBox = $('success');
		var thesrc = $('callback');

		if(o.responseText !== undefined){
			if(successBox){
				successBox.innerHTML = 'Comment not added';
			}
			thesrc.innerHTML = "<ul><li>Transaction id: " + o.tId + "</li>";
			thesrc.innerHTML += "<li>HTTP status: " + o.status + "</li>";
			thesrc.innerHTML += "<li>Status code message: " + o.statusText + "</li></ul>";
			YE.onDOMReady(init);
		}
	}

	var callback =
	{
	  success:handleSuccess,
	  failure:handleFailure,
	  timeout: 10000,
	  argument: { foo:"foo", bar:"bar" }
	};

	function ajaxTest(e){
		sweetTitles.tipOut();
		YE.stopEvent(e);
		sUrl = this.href;
		//sUrl += '&ajax=1';

		callAjax(sUrl);
	}

	function makeRequest(e){

		sweetTitles.tipOut();
		YE.stopEvent(e);
		sUrl = this.href;
		//sUrl += '&ajax=1';
		//alert(sUrl);

		callAjax(sUrl);
	}

	function formRequest(e){

		sweetTitles.tipOut();
		YE.stopEvent(e);
		/*var subMit = document.getElementsByTagName('form');*/
		var subMit = document.getElementById('searchform');
		sUrl = subMit.getAttribute('action');
		//sUrl = this.href;
		//sUrl += '&ajax=1';

		/*var theForm = document.getElementById('searchform');*/
		var searchby = subMit.searchby.value;
		var searchterm = subMit.searchterm.value;

		postData = 'search=true&searchby='+searchby+'&searchterm='+searchterm;

		callAjax(sUrl, postData);
	}

	function commentRequest(e){
		var commentSec = document.getElementById('commentBox');
		if(commentSec){
			sweetTitles.tipOut();
			YE.stopEvent(e);
			/*var subMit = document.getElementsByTagName('form');*/
			var commentForm = document.getElementById('f');
			sUrl = commentForm.getAttribute('action');

			/*var theForm = document.getElementById('searchform');*/
			var postedBy = commentForm.posted_by.value;
			var emailAdd = commentForm.email.value;
			var comment = commentForm.comment.value;
			var checker = commentForm.checker.value;

			postData = 'submitted=true&posted_by='+postedBy+'&email='+emailAdd+'&comment='+comment+'&checker='+checker;

			callAjax(sUrl, postData);
		}
	}

	function callAjax(sUrl, postData, setFormData){
		//alert("I'm at the ajax call!");

		var theImg = document.getElementById('callback');
		var theSecondImg = document.getElementById('callback1');
		var thediv = document.getElementById('fadeBlock');
		var error = Dom.getElementsByClassName('error');
		var commentBox = document.getElementById('commentBox');
		for(var i=0; i<error.length; i++){
			if(error[i]){
				error[i].style.display = 'none';
			}
		}

		if(thediv){
			thediv.style.display = 'none';
		}
		if(theImg){
			theImg.style.display = 'block';
			theImg.style.position = 'static';
			theImg.style.marginTop = '20px';
			theImg.style.textAlign = 'center';
		}
		if(theSecondImg){
			theSecondImg.style.display = 'block';
		}

		/*thediv.style.position = 'static';
		thediv.style.marginTop = '20px';
		thediv.style.textAlign = 'center';*/

		if(theSecondImg){
			if(commentBox){
				var smilieBox = document.getElementById('smilieBox');
				var overLay = document.createElement('div');
				commentBox.appendChild(overLay);
				commentBox.style.overflow = 'hidden';
				overLay.style.position = 'absolute';
				overLay.style.height = '333px';
				overLay.style.width = '465px';
				overLay.style.top = '-2px';
				overLay.style.left = '0';
				overLay.style.background = '#F1F1F1';
				overLay.style.opacity = '0.9';
				overLay.appendChild(theSecondImg);
				Dom.insertBefore(overLay, smilieBox);
				Dom.setStyle(theSecondImg, 'margin-top', '150px');
			}
			theSecondImg.innerHTML = "<p>Posting Comment...</p><p class=\"mid\"><img src=\"/resources/images/loadingAnimation.gif\" alt=\"Loading Your Page...\" /></p>";
			theImg.innerHTML = '';
		} else {
			//thediv.innerHTML = "<img src=\"/resources/images/lightbox/loading.gif\" alt=\"Loading Your Page...\" />";
			theImg.innerHTML = "<img src=\"/resources/images/loading.gif\" alt=\"Loading Your Page...\" />";
		}

		var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
		YE.onDOMReady(init);
	}

	function hideSuccess(){

		var removeElement = function (){
			var fadeBlock = document.getElementById('fadeBlock');
	   		fadeBlock.style.visibility = 'hidden';
		}
		var myAnim = new YAHOO.util.Anim("fadeBlock", {
  		  height: { to: 0 },
  		  opacity: { to: 0 }
   		}, 2, YAHOO.util.Easing.easeOut);

   		myAnim.animate();
		myAnim.onComplete.subscribe(removeElement);
	}

	function showCommentBox(e){
		YE.stopEvent(e);
		/*var elementDis = function (){

		}*/
		var commentBox = document.getElementById('commentBox');
		commentBox.style.paddingTop = '10px';
		commentBox.style.paddingBottom = '10px';

		var showLink = document.getElementById('showComment');
		if(showLink){
			showLink.innerHTML = 'Hide Comment Box';
			YE.on(showLink, 'click', hideCommentBox);
		}
		var comAnim = new YAHOO.util.Anim("commentBox", {
			height: { to: 310 },
			opacity: { from: 0, to: 100 }
		}, 2, YAHOO.util.Easing.easeOut);
		comAnim.animate();
		//myAnim.onComplete.subscribe(elementDis);
	}

	function hideCommentBox(e){
		YE.stopEvent(e);
		var removeElement = function (){
		}
		var commentBox = document.getElementById('commentBox');
		commentBox.style.paddingTop = '0px';
		commentBox.style.paddingBottom = '0px';

		var showLink1 = document.getElementById('showComment');
		if(showLink1){
			showLink1.innerHTML = 'Show Comment Box';
			YE.on(showLink1, 'click', showCommentBox);
		}

		var comAnim1 = new YAHOO.util.Anim("commentBox", {
			height: { to: 0 },
			opacity: { from: 100, to: 0 }
		}, 2, YAHOO.util.Easing.easeOut);
		comAnim1.animate();
		comAnim1.onComplete.subscribe(removeElement);
	}

	function hideText(e){
		YE.stopEvent(e);
		this.value = "";
	}

	function loginRequest(e){
		YE.stopEvent(e);
		/* Create the Element */
		var extra = document.getElementById('extra_1');
		extra.style.display = 'block';
		/*var registerForm = document.getElementById('registerForm');
		registerForm.style.display = 'none';*/

		// Changed the following bit

		var loginForm = document.getElementById('loginForm');
		if(loginForm){
			var extra2 = document.createElement('div');
			extra.appendChild(extra2);
			extra2.setAttribute('id', 'extra_2');
			var loginContainer = document.createElement('div');
			extra2.appendChild(loginContainer);

			var newLoginForm = loginForm.cloneNode(true);
			loginContainer.appendChild(loginForm);
			loginContainer.setAttribute('id', 'loginCopy');
		}

		// From the following

		/*var loginContainer = document.createElement('div');
		loginContainer = extra.appendChild(loginContainer);
		loginContainer.setAttribute('id', 'loginContainer');
		loginContainer.setAttribute('style', 'display: block');

		var loginForm = document.createElement('form');
		loginForm = loginContainer.appendChild(loginForm);
		loginForm.setAttribute('action', '/login');
		loginForm.setAttribute('method', 'post');
		loginForm.setAttribute('id', 'loginForm');

		var fieldSet = document.createElement('fieldset');
		fieldSet = loginForm.appendChild(fieldSet);
		fieldSet.setAttribute('label', 'Use The Form To Login');

		var usernameP = document.createElement('p');
		usernameP.setAttribute('style', 'text-align: center');
		usernameP = fieldSet.appendChild(usernameP);

		var usernameText = document.createTextNode('Username:');
		usernameText = usernameP.appendChild(usernameText);

		var loginInput = document.createElement('input');
		loginInput = usernameP.appendChild(loginInput);
		loginInput.setAttribute('type', 'text');
		loginInput.setAttribute('name', 'username');
		loginInput.setAttribute('id', 'username');

		var autoComplete = document.createElement('div');
		autoComplete = usernameP.appendChild(autoComplete);
		autoComplete.setAttribute('id', 'autoComplete');

		var passwordP = document.createElement('p');
		passwordP.setAttribute('style', 'text-align: center');
		passwordP = fieldSet.appendChild(passwordP);

		var passwordText = document.createTextNode('Password:');
		passwordText = passwordP.appendChild(passwordText);

		var loginPassword = document.createElement('input');
		loginPassword = passwordP.appendChild(loginPassword);
		loginPassword.setAttribute('type', 'password');
		loginPassword.setAttribute('name', 'password');

		var submitP = document.createElement('p');
		submitP.setAttribute('style', 'text-align: center');
		submitP = fieldSet.appendChild(submitP);

		var loginSubmit = document.createElement('input');
		loginSubmit = submitP.appendChild(loginSubmit);
		loginSubmit.setAttribute('type', 'submit');
		loginSubmit.setAttribute('name', 'submit');
		loginSubmit.setAttribute('value', 'Login');

		var hiddenInput = document.createElement('input');
		hiddenInput = fieldSet.appendChild(hiddenInput);
		hiddenInput.setAttribute('type', 'hidden');
		hiddenInput.setAttribute('name', 'submitted');
		hiddenInput.setAttribute('value', 'TRUE');*/

		//var loginDialog = new YAHOO.widget.Dialog("loginContainer",

		var myDataSource = new YAHOO.widget.DS_JSArray(nameArray);
		var myAutoComp = new YAHOO.widget.AutoComplete("username","autoComplete", myDataSource);
		myAutoComp.animSpeed = 0.5;
		myAutoComp.useShadow = true;
		myAutoComp.typeAhead = true;
		myAutoComp.allowBrowserAutocomplete = false;

		var loginDialog = new YAHOO.widget.Dialog("loginCopy",
				{
				width: "300px",
				fixedcenter: true,
				modal: true,
				visible: false,
				draggable: false,
				iframe: false,
				close: true,
				effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:1}
				}
		);
		loginDialog.setHeader("Please Login To The Site");
		loginDialog.setBody(loginForm);
		loginDialog.render();
		loginDialog.show();

		YE.on(loginForm, 'submit', callLoginAjax);

		function callLoginAjax(e){
			YE.stopEvent(e);
			var sUrl = window.location.href;
			var userName = loginDialog.getData().username;
			var passWord = loginDialog.getData().password;
			var postData = 'submitted=true&username=' + userName + '&password=' + passWord;
			callAjax(sUrl, postData);
		}
	}

	function logoutRequest(e){
		YE.stopEvent(e);

		var logoutDialogDiv = document.createElement('div');
		var extra = document.getElementById('extra_1');
		extra.style.display = 'block';
		var registerForm = document.getElementById('registerForm');
		if(registerForm){
			registerForm.style.display = 'none';
		}
		logoutDialogDiv = extra.appendChild(logoutDialogDiv);
		logoutDialogDiv.setAttribute('id', 'logoutDialogId');

		var logoutDialog = new YAHOO.widget.Dialog("logoutDialogId",
				{
				width: "300px",
				fixedcenter: true,
				modal: true,
				visible: false,
				draggable: false,
				iframe: false,
				close: false,
				effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:1},
				buttons : [ { text:"Yes", handler:handleSubmit },
	                    	{ text:"No", handler:handleCancel } ]
				}
		);
		logoutDialog.setHeader("Logout?");
		logoutDialog.setBody("Are you sure you want to log out?");
		logoutDialog.render();
		logoutDialog.show();

		function handleSubmit(e){
			YE.stopEvent(e);
			var sUrl = '/logout';
			callAjax(sUrl);
			this.hide();
		}

		function handleCancel(e){
			YE.stopEvent(e);
			this.destroy();
		}
	}

	function registerRequest(e){
		YE.stopEvent(e);

		var extra = document.getElementById('extra_1');
		extra.style.display = 'block';
		var registerForm = document.getElementById('registerForm');
		if(registerForm){
			registerForm.style.display = 'none';
		}
		var extra2 = document.createElement('div');
		extra.appendChild(extra2);
		extra2.setAttribute('id', 'extra_2');
		var registerForm = document.getElementById('registerForm');
		var registerContainer = document.createElement('div');
		extra2.appendChild(registerContainer);

		var newRegForm = registerForm.cloneNode(true);
		registerContainer.appendChild(newRegForm);
		registerContainer.setAttribute('id', 'registerCopy');

		var registerDialog = new YAHOO.widget.Dialog("registerCopy",
				{
				width: "500px",
				fixedcenter: true,
				modal: true,
				visible: false,
				draggable: false,
				iframe: false,
				close: true,
				effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:1}
				}
		);
		registerDialog.setHeader("Please Login To The Site");
		registerDialog.setBody(newRegForm);
		registerDialog.render();
		registerDialog.show();

		YE.on(newRegForm, 'submit', callRegisterAjax);

		function callRegisterAjax(e){
			YE.stopEvent(e);
			var sUrl = '/register';

			var theImg = document.getElementById('callback');
			var theSecondImg = document.getElementById('callback1');
			var thediv = document.getElementById('fadeBlock');
			var error = Dom.getElementsByClassName('error');
			for(var i=0; i<error.length; i++){
				if(error[i]){
					error[i].style.display = 'none';
				}
			}

			if(thediv){
				thediv.style.display = 'none';
			}
			if(theImg){
				theImg.style.display = 'block';
				theImg.style.position = 'static';
				theImg.style.marginTop = '20px';
				theImg.style.textAlign = 'center';
			}
			if(theSecondImg){
				theImg.style.display = 'block';
				theImg.style.position = 'static';
				theImg.style.marginTop = '20px';
				theImg.style.textAlign = 'center';
			}

			theImg.innerHTML = "<img src=\"/resources/images/loading.gif\" alt=\"Loading Your Page...\" />";

			YAHOO.util.Connect.setForm(newRegForm);
			var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback);
			YE.onDOMReady(init);
			//var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
		}
	}

	function statsRequest(e){
		YE.stopEvent(e);

		sUrl = this;
		var linkIframe = document.createElement('iframe');
		var extra = document.getElementById('extra_1');
		extra.style.display = 'block';
		var registerForm = document.getElementById('registerForm');
		if(registerForm){
			registerForm.style.display = 'none';
		}
		var extra3 = document.createElement('div');
		extra.appendChild(extra3);
		extra3.setAttribute('id', 'extra_3');
		linkIframe = extra.appendChild(linkIframe);
		linkIframe.setAttribute('src', this);
		linkIframe.setAttribute('width', "780");
		linkIframe.setAttribute('height', "600");

		var linkDialog = new YAHOO.widget.Panel(extra3,
			{
				width: "800px",
				fixedcenter: true,
				modal: false,
				visible: false,
				draggable: true,
				iframe: false,
				close: true,
				effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:1}
			}
		);
		linkDialog.setHeader("IP Lookup Information - " + this.title);
		linkDialog.setBody(linkIframe);
		linkDialog.render();
		linkDialog.show();
	}

	function popWhisper(e){
		YE.stopEvent(e);

		var linkIframe = document.createElement('iframe');
		var extra = document.getElementById('extra_1');
		extra.style.display = 'block';
		var registerForm = document.getElementById('registerForm');
		if(registerForm){
			registerForm.style.display = 'none';
		}
		var extra3 = document.createElement('div');
		extra.appendChild(extra3);
		extra3.setAttribute('id', 'extra_3');
		linkIframe = extra.appendChild(linkIframe);
		linkIframe.setAttribute('src', '/whispers/#content');
		linkIframe.setAttribute('width', "790");
		linkIframe.setAttribute('height', "600");

		sUrl = window.location.href;

		var linkDialog = new YAHOO.widget.Panel(extra3,
			{
				width: "810px",
				fixedcenter: true,
				modal: false,
				visible: false,
				draggable: true,
				iframe: false,
				close: true,
				effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:1}
			}
		);
		linkDialog.setHeader("Your Whisper Messages");
		linkDialog.setBody(linkIframe);
		linkDialog.render();
		linkDialog.show();

		oClose = linkDialog.close;
        YE.on(oClose, "click", doIframeHide, this);

		function doIframeHide(e){
			//alert("Close Me!");
			callAjax(sUrl);
		}
	}

	function viewWhisper(e){
		YE.stopEvent(e);

		var whisperExists = document.getElementById('newTableTd');
		if(whisperExists){

			function removeWhisper(){
		   		var whisperContainer = Dom.getAncestorByTagName(whisperExists, 'tbody');
				whisperTr = whisperContainer.removeChild(whisperTr);
		   		var replyForm = document.getElementById('newReplyTableTd');
		   		if(replyForm){
				   	var replyFormTr = Dom.getAncestorByTagName(replyForm, 'tr');
		   			replyForm.setAttribute('style', 'overflow: hidden;');
		   			replyForm.style.cssText = 'overflow: hidden;';
					var replyFormTr = Dom.getAncestorByTagName(replyForm, 'tr');
					var trAnim = new YAHOO.util.Anim(replyForm, {
			  		  height: { from: 300, to: 0 },
			  		  opacity: { to: 0 }
			   		}, 2, YAHOO.util.Easing.easeOut);

			   		trAnim.animate();
				   	trAnim.onComplete.subscribe(whisperContainer.removeChild(replyFormTr));
				}
			}

			whisperExists.setAttribute('style', 'overflow: hidden;');
			whisperExists.style.cssText = 'overflow: hidden;';
			var whisperTr = Dom.getAncestorByTagName(whisperExists, 'tr');
			var trAnim = new YAHOO.util.Anim(whisperExists, {
	  		  height: { from: 300, to: 0 },
	  		  opacity: { to: 0 }
	   		}, 2, YAHOO.util.Easing.easeOut);

	   		trAnim.animate();
			trAnim.onComplete.subscribe(removeWhisper);
		}

		function getWhisper(){
			var whisperRequest = YAHOO.util.Connect.asyncRequest('POST', sUrl, viewCallback);
		}

		// Handle the call back options from the ajax request

		var handleViewSuccess = function(o){

			if(o.responseText !== undefined){
				loadingImg.style.display = 'none';
				newTableTd.innerHTML = o.responseText;
				var newWhisper = document.getElementById('whisperMessage');
				newTableTd.innerHTML = newWhisper.innerHTML;
				/*var hideLink = document.getElementById('hideWhisper');
				YE.on(hideLink, 'click', hideWhisper);*/
				var whisperBox = document.getElementById('whisperBox');
				whisperBox.style.width = '331px';

				var envelope = Dom.getLastChild(oldTableRow);
				envelope = Dom.getFirstChild(envelope);
				if(envelope.src = 'http://www.syst3m32.co.uk/resources/images/unread-email.png'){
					envelope.src = 'http://www.syst3m32.co.uk/resources/images/read-email.png';
				}
				var replyUrl = document.getElementById('replyLink');
				/*replyUrl = replyUrl.href;*/
				var replyLink = document.createElement('a');
				replyLink = newTableTd.appendChild(replyLink);
				replyLink.setAttribute('href', replyUrl);
				replyLink.setAttribute('class', 'replyWhisper');
				replyLink.setAttribute('className', 'replyWhisper');
				replyLink.setAttribute('style', 'clear: both; display: block; text-align: center;');
				replyLink.style.cssText = 'clear: both; display: block; text-align: center;';
				replyLink.appendChild(document.createTextNode('Reply To Whisper'));
				YE.on(replyLink, 'click', replyWhisper);
			}
		}

		var handleViewFailure = function(o){

			if(o.responseText !== undefined){
				alert("Ajax returned bad stuff");
			}
		}

		var viewCallback =
		{
		  success:handleViewSuccess,
		  failure:handleViewFailure
		};

		var sUrl = this;

		/*this.innerHTML = '';
		this.removeAttribute('class');
		this.setAttribute('id', 'hideWhisper');*/

		// Get table row that we want to replace after
		var oldTableRow = Dom.getAncestorByTagName(this, 'tr');
		// Create a new table row for our whisper to be viewed in
		var newTableRow = document.createElement('tr');
		// Add the new table row AFTER the old one
		newTableRow = Dom.insertAfter(newTableRow, oldTableRow);
		// Give the new table row the same style as the old table row
		oldTableRowStyle = oldTableRow.getAttribute('style');
		newTableRow.setAttribute('style', oldTableRowStyle + 'overflow: hidden;');
		newTableRow.style.cssText = oldTableRowStyle + 'overflow: hidden;';

		// Create a td for our content to be placed in and append it to the new table row

		var newTableTd = document.createElement('td');
		newTableTd = newTableRow.appendChild(newTableTd);
		newTableTd.setAttribute('id', 'newTableTd');
		//newTableTd.colSpan('colspan', '7');
		newTableTd.colSpan = 7;

		// Use a loading image within an animation to show the area the whisper is going to be put into

		var loadingImg = document.createElement('p');
		loadingImg = newTableTd.appendChild(loadingImg);
		loadingImg.setAttribute('class', 'mid');
		loadingImg.setAttribute('className', 'mid');
		loadingImg.innerHTML = "<img src=\"/resources/images/loadingAnimation.gif\" alt=\"Loading Your Page...\" style=\"float: none\" />";

		var trAnim = new YAHOO.util.Anim(newTableRow, {
  		  height: { to: 300 },
  		  opacity: { to: 100 }
   		}, 2, YAHOO.util.Easing.easeOut);

   		trAnim.animate();
		trAnim.onComplete.subscribe(getWhisper);
	}

	function removeWhisper(e){
		sweetTitles.tipOut();
		YE.stopEvent(e);
		sUrl = this.href;
		//alert(sUrl);
		var youSure = confirm("Are you sure you wish to remove this whisper?");
		if(youSure){
			callAjax(sUrl);
		} else {
			return false;
		}
	}

	function replyWhisper(e){
		YE.stopEvent(e);

		function getReplyForm(){
			var whisperRequest = YAHOO.util.Connect.asyncRequest('POST', sUrl, replyCallback);
		}

		var handleReplySuccess = function(o){

			if(o.responseText !== undefined){
				loadingImg.style.display = 'none';
				/*newTableTd.innerHTML = o.responseText;
				var newWhisper = document.getElementById('whisperFormWrap');
				newTableTd.innerHTML = newWhisper.innerHTML;*/

				var newForm = document.createElement('form');
				newForm.setAttribute('method', 'post');
				newForm.setAttribute('action', sUrl);
				newForm.setAttribute('id', 'replyForm');
				newForm = newTableTd.appendChild(newForm);
				newForm.innerHTML = o.responseText;

				var newWhisper = document.getElementById('whisperFormWrap');
				newForm.innerHTML = newWhisper.innerHTML;

			}
		}

		var handleReplyFailure = function(o){

			if(o.responseText !== undefined){
				alert("Ajax returned bad stuff");
			}
		}

		var replyCallback =
		{
		  success:handleReplySuccess,
		  failure:handleReplyFailure
		};

		var sUrl = this;

		// Get table row that we want to replace after
		var oldTableRow = Dom.getAncestorByTagName(this, 'tr');
		// Create a new table row for our whisper to be viewed in
		var newTableRow = document.createElement('tr');
		// Add the new table row AFTER the old one
		newTableRow = Dom.insertAfter(newTableRow, oldTableRow);
		// Give the new table row the same style as the old table row
		oldTableRowStyle = oldTableRow.getAttribute('style');
		newTableRow.setAttribute('style', oldTableRowStyle + 'overflow: hidden;');
		newTableRow.style.cssText = oldTableRowStyle + 'overflow: hidden;';

		// Create a td for our content to be placed in and append it to the new table row

		var newTableTd = document.createElement('td');
		newTableTd = newTableRow.appendChild(newTableTd);
		newTableTd.setAttribute('id', 'newReplyTableTd');
		//newTableTd.setAttribute('colspan', '7');
		newTableTd.colSpan = 7;

		// Use a loading image within an animation to show the area the whisper is going to be put into

		var loadingImg = document.createElement('p');
		loadingImg = newTableTd.appendChild(loadingImg);
		loadingImg.setAttribute('class', 'mid');
		loadingImg.setAttribute('className', 'mid');
		loadingImg.innerHTML = "<img src=\"/resources/images/loadingAnimation.gif\" alt=\"Loading Your Page...\" style=\"float: none\" />";

		var trAnim = new YAHOO.util.Anim(newTableRow, {
  		  height: { to: 300 },
  		  opacity: { to: 100 }
   		}, 2, YAHOO.util.Easing.easeOut);

   		trAnim.animate();
		trAnim.onComplete.subscribe(getReplyForm);
	}

	function sendWhisper(e){
		YE.stopEvent(e);

		var whisperExists = document.getElementById('newTableTd');
		if(whisperExists){

			function removeWhisper(){
		   		var whisperContainer = Dom.getAncestorByTagName(whisperExists, 'tbody');
				whisperTr = whisperContainer.removeChild(whisperTr);
			}

			whisperExists.setAttribute('style', 'overflow: hidden;');
			whisperExists.style.cssText = 'overflow: hidden;';
			var whisperTr = Dom.getAncestorByTagName(whisperExists, 'tr');
			var trAnim = new YAHOO.util.Anim(whisperExists, {
	  		  height: { to: 0 },
	  		  opacity: { to: 0 }
	   		}, 2, YAHOO.util.Easing.easeOut);

	   		trAnim.animate();
			trAnim.onComplete.subscribe(removeWhisper);
		}

		function getSendForm(){
			var whisperRequest = YAHOO.util.Connect.asyncRequest('POST', sUrl, sendCallback);
		}

		var handleSendSuccess = function(o){

			if(o.responseText !== undefined){
				loadingImg.innerHTML = '<h3 class="bloghead">' + heading + '</h3>';
				var newForm = document.createElement('form');
				newForm.setAttribute('method', 'post');
				newForm.setAttribute('action', sUrl);
				newForm.setAttribute('id', 'replyForm');
				newForm = newTableTd.appendChild(newForm);
				newForm.innerHTML = o.responseText;
				var newWhisper = document.getElementById('whisperFormWrap');
				newForm.innerHTML = newWhisper.innerHTML;

				var myDataSource = new YAHOO.widget.DS_JSArray(nameArray);
				var myAutoComp = new YAHOO.widget.AutoComplete("username","autoComplete", myDataSource);
				myAutoComp.animSpeed = 0.5;
				myAutoComp.useShadow = true;
				myAutoComp.typeAhead = true;
				myAutoComp.allowBrowserAutocomplete = false;
			}
		}

		var handleSendFailure = function(o){

			if(o.responseText !== undefined){
				alert("Ajax returned bad stuff");
			}
		}

		var sendCallback =
		{
		  success:handleSendSuccess,
		  failure:handleSendFailure
		};

		var sUrl = this;
		switch(this.innerHTML){
			case 'Send A Whisper':
				var heading = 'Send A Whisper';
				break;
			case 'Send To All':
				var heading = 'Send To All';
				break;
			case 'Send To The Band':
				var heading = 'Send To The Band';
				break;
		}

		// Get table row that we want to replace after
		var oldTableRow = Dom.getElementsByClassName('whisperHead');
		oldTableRow = oldTableRow[0];
		// Create a new table row for our whisper to be viewed in
		var newTableRow = document.createElement('tr');
		// Add the new table row AFTER the old one
		newTableRow = Dom.insertAfter(newTableRow, oldTableRow);
		// Give the new table row the same style as the old table row
		oldTableRowStyle = oldTableRow.getAttribute('style');
		newTableRow.setAttribute('style', oldTableRowStyle + 'overflow: hidden;');
		newTableRow.style.cssText = oldTableRowStyle + 'overflow: hidden;';

		// Create a td for our content to be placed in and append it to the new table row

		var newTableTd = document.createElement('td');
		newTableTd = newTableRow.appendChild(newTableTd);
		newTableTd.setAttribute('id', 'newTableTd');
		newTableTd.setAttribute('colspan', '7');

		// Use a loading image within an animation to show the area the whisper is going to be put into

		var loadingImg = document.createElement('p');
		loadingImg = newTableTd.appendChild(loadingImg);
		loadingImg.setAttribute('class', 'mid');
		loadingImg.setAttribute('className', 'mid');
		loadingImg.innerHTML = "<img src=\"/resources/images/loadingAnimation.gif\" alt=\"Loading Your Page...\" style=\"float: none\" />";

		var trAnim = new YAHOO.util.Anim(newTableRow, {
  		  height: { to: 300 },
  		  opacity: { to: 100 }
   		}, 2, YAHOO.util.Easing.easeOut);

   		trAnim.animate();
		trAnim.onComplete.subscribe(getSendForm);
	}

	function turnMeOn(sUrl){
		callAjax(sUrl);
	}

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function editGig(e){
		YE.stopEvent(e);

		function getGigEdit(){
			var gigRequest = YAHOO.util.Connect.asyncRequest('POST', sUrl, gigEditCallback);
		}

		var handleGigSuccess = function(o){

			if(o.responseText !== undefined){
				loadingImg.style.display = 'none';

				var newForm = document.createElement('form');
				newForm.setAttribute('method', 'post');
				newForm.setAttribute('action', newsUrl);
				newForm.setAttribute('id', 'replyForm');
				newForm = formDiv.appendChild(newForm);
				newForm.innerHTML = o.responseText;

				var newWhisper = document.getElementById('editGig');
				newForm.innerHTML = newWhisper.innerHTML;

				YE.onDOMReady(init);
			}
		}

		var handleGigFailure = function(o){

			if(o.responseText !== undefined){
				alert("Ajax returned bad stuff");
			}
		}

		var gigEditCallback =
		{
		  success:handleGigSuccess,
		  failure:handleGigFailure
		};

		var sUrl = this.href;
		var newsUrl = sUrl.split('/');
		newsUrl = newsUrl[0] + '//' + newsUrl[1] + newsUrl[2] + '/' + newsUrl[3] + '/' + newsUrl[4];

		var formDiv = document.createElement('div');
		var content = document.getElementById('content');
		content.appendChild(formDiv);

		var loadingImg = document.createElement('p');
		loadingImg = formDiv.appendChild(loadingImg);
		loadingImg.setAttribute('class', 'mid');
		loadingImg.setAttribute('className', 'mid');
		loadingImg.innerHTML = "<img src=\"/resources/images/loadingAnimation.gif\" alt=\"Loading Your Page...\" style=\"float: none\" />";

		var trAnim = new YAHOO.util.Anim(formDiv, {
  		  height: { to: 600 },
  		  opacity: { to: 100 }
   		}, 2, YAHOO.util.Easing.easeOut);

   		trAnim.animate();
		trAnim.onComplete.subscribe(getGigEdit);
	}

	function checkFormDetails(e){
		var inputs = Dom.getElementsByClassName('checkInput');
		var errorImgs = Dom.getElementsByClassName('errorImg');
		for(var i=0;i<errorImgs.length;i++){
			errorImgs[i].parentNode.removeChild(errorImgs[i]);
		}
		var errors = "";
		var regex = "";
		for(var i=0;i<inputs.length;i++){
			switch(inputs[i].name){
				case "checker":
					regex = document.getElementById('checkWord').innerHTML;
					break;
				case "name":
				case "town":
				case "county":
				case "country":
					regex = /^([ \u00c0-\u01ffa-zA-Z])+$/;
					break;
				case "email":
					regex = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
					break;
				case "topic":
					regex = "";
					break;
				case "price":
					regex = /^£([0-9]{1,2}).([0-9]{2})$/;
					break;
				case "day":
					regex = /^(([0-2][0-9])|30|31)$/;
					break;
				case "month":
					regex = /^((0[1-9])|10|11|12)$/;
					break;
				case "year":
					regex = /^(2([0-9]{3}))$/;
					break;
				case "mobile":
				case "tel":
					regex = /^(\+[0-9]{1,3})?([0-9]{10,11})$/;
					break;
				case "postcode":
					regex = /^([A-Za-z]{1,2})([0-9]{1,2})( )([0-9]{1})([A-Za-z]{2})$/;
					break;
				default:
					regex = "";
					break;
			}
			if(inputs[i].value == "" || !inputs[i].value.match(regex)){
				var field = inputs[i].name;
				errors += '  You need to add the '+ field +' field\n';
				inputs[i].setAttribute('class', 'checkInput errorInput');
				var newImg = document.createElement('img');
				newImg.setAttribute('src', '/resources/images/cross.gif');
				newImg.setAttribute('title', 'You have an error');
				newImg.setAttribute('class', 'errorImg');
				newImg.setAttribute('className', 'errorImg');
				inputs[i].parentNode.appendChild(newImg);
			} else {
				inputs[i].setAttribute('class', 'checkInput okayInput');
				var newImg = document.createElement('img');
				newImg.setAttribute('src', '/resources/images/tick.gif');
				newImg.setAttribute('title', 'This field is correct');
				newImg.setAttribute('class', 'errorImg');
				newImg.setAttribute('className', 'errorImg');
				inputs[i].parentNode.appendChild(newImg);
			}
		}
		if(errors !== ""){
			YE.stopEvent(e);
			//alert("Please correct the following errors:\n\n"+ errors);
		} else {
			commentRequest(e);
		}
	}

	/**
	 * This function does exactly the same as the above, but performs the checks on each key press on the keyboard. Will
	 * only fire a not errored state when the field passes all checks
	 *
	 **/

	function checkSingleFormDetails(e){

		var errorImgs = this.parentNode.getElementsByTagName('img');
		for(var i=0;i<errorImgs.length;i++){
			errorImgs[i].parentNode.removeChild(errorImgs[i]);
		}
		var errors = "";
		var regex = "";
		switch(this.name){
			case "checker":
				regex = document.getElementById('checkWord').innerHTML;
				break;
			case "name":
			case "town":
			case "county":
			case "country":
				regex = /^([ \u00c0-\u01ffa-zA-Z])+$/;
				break;
			case "email":
				regex = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
				break;
			case "topic":
				regex = "";
				break;
			case "price":
				regex = /^£([0-9]{1,2}).([0-9]{2})$/;
				break;
			case "day":
				regex = /^(([0-2][0-9])|30|31)$/;
				break;
			case "month":
				regex = /^((0[1-9])|10|11|12)$/;
				break;
			case "year":
				regex = /^(2([0-9]{3}))$/;
				break;
			case "mobile":
			case "tel":
				regex = /^(\+[0-9]{1,3})?([0-9]{10,11})$/;
				break;
			case "postcode":
				regex = /^([A-Za-z]{1,2})([0-9]{1,2})( )([0-9]{1})([A-Za-z]{2})$/;
				break;
			default:
				regex = "";
				break;
		}
		if(this.value == "" || !this.value.match(regex)){
			var field = this.name;
			errors += '  You need to add the '+ field +' field\n';
			this.setAttribute('class', 'checkInput errorInput');
			var newImg = document.createElement('img');
			newImg.setAttribute('src', '/resources/images/cross.gif');
			newImg.setAttribute('title', 'You have an error');
			newImg.setAttribute('class', 'errorImg');
			newImg.setAttribute('className', 'errorImg');
			this.parentNode.appendChild(newImg);
		} else {
			this.setAttribute('class', 'checkInput okayInput');
			var newImg = document.createElement('img');
			newImg.setAttribute('src', '/resources/images/tick.gif');
			newImg.setAttribute('title', 'This field is correct');
			newImg.setAttribute('class', 'errorImg');
			newImg.setAttribute('className', 'errorImg');
			this.parentNode.appendChild(newImg);
		}
	}

	function resetFormDetails(e){
		var errorInputs = Dom.getElementsByClassName('errorInput');
		for(var i=0;i<errorInputs.length;i++){
			errorInputs[i].removeAttribute('class');
			errorInputs[i].setAttribute('class', 'checkInput');
			errorInputs[i].setAttribute('className', 'checkInput');
		}
		var okayInputs = Dom.getElementsByClassName('okayInput');
		for(var i=0;i<okayInputs.length;i++){
			okayInputs[i].removeAttribute('class');
			okayInputs[i].setAttribute('class', 'checkInput');
			okayInputs[i].setAttribute('className', 'checkInput');
		}
		var errorImgs = Dom.getElementsByClassName('errorImg');
		for(var i=0;i<errorImgs.length;i++){
			errorImgs[i].setAttribute('src', '/resources/images/warn.png');
		}
	}

YE.onDOMReady(init);
YE.onDOMReady(updateInit);