
	function highlightNewsRow(item) {
		item.style.backgroundColor = 'white';
		item.style.color = 'rgb(246,134,32)';
		item.style.cursor = 'pointer';	
	}
	function unhighlightNewsRow(item) {
		item.style.backgroundColor = 'transparent';
		item.style.color = 'rgb(29,87,174)';
	}
	
	
	
	function newsURL(ID) {
		location.href = "news.php?page=" + ID;
	}
	function editNewsURL(ID) {
		location.href = "newsEdit.php?page=" + ID;
	}
	function editResultURL(ID) {
		location.href = "editResult.php?page=" + ID;
	}
	
	
	function preloadImages() {
		image1 = new Image();
		image1.src = "logos/lendalSmallOVER.jpg";
		image2 = new Image();
		image2.src = "logos/rasdexSmallOVER.jpg";
		image3 = new Image();
		image3.src = "logos/ddCarbonSmallOVER.jpg";
		image4 = new Image();
		image4.src = "logos/gbCanoeingOVER.jpg";
		image5 = new Image();
		image5.src = "logos/ukSportSmallOVER.jpg";
		image6 = new Image();
		image6.src = "logos/scotInstSmallOVER.jpg";
		image7 = new Image();
		image7.src = "logos/laceMarketSmallOVER.jpg";
		image8 = new Image();
		image8.src = "logos/boaOVER.jpg";
		image9 = new Image();
		image9.src = "logos/zigzagOVER.jpg";
		image10 = new Image();
		image10.src = "logos/hellyOVER.jpg";
		image11 = new Image();
		image11.src = "logos/bodyFuelOVER.jpg";
	}
	
	
	
	
	
	
	
	function validateForm(formName, numElements) {
		
		//check a value was entered in the first 'numElements' number of inputs 
		//(hence, any optional inputs should be put at the end of the form)
		var fields = formName.elements;
		for (var i=0; i<numElements; i++) {
			if (!fields[i].value) {
				alert("Please enter something in the field.");
				fields[i].focus();
				return false;	
			}	
		}
		
		//if an email was entered, check its the correct format 
		//(this accounts for both compulsary and optional email inputs)
		if (formName.From.value){
			//check value entered is format of an email address
			var filter=/^.+@.+\..{2,4}$/;
			if (!(filter.test(formName.From.value))) {
				alert("Please enter a valid email address (eg. user@domain.com)");
				formName.From.select();
				return false;
			}
			//check it contains no illegal characters
			else {
				var illegalChars=/[\(\)\<\>\,\;\:\\\"\[\]]/
				if (formName.From.value.match(illegalChars)) {
					alert("The email address contains illegal characters. Please enter a valid email address (eg. user@domain.com)");
					formName.From.select();
					return false;
				}
			}
		}
			
		//everything is ok so return true.
		return true;
	}
	
	
	
	function highlightInput(object) {
		
		object.style.borderColor='#555';
		object.style.borderStyle='solid';
		object.style.borderWidth='1px';
		object.style.color='#111';
	}
	
	function unhighlightInput(object) {
		
		if (object.value) {
			object.style.color='#555';
		}
		object.style.borderColor='#AAA';
		object.style.borderWidth='1px';	
	}
	
	
	
	
	
	
