	
	/* Validate the form */
	function validateContact(f){
		// Set the flag to indicate if all ok
		var bPass = true;
		
		// Check that the required fields have data present
		bPass = CheckForInput(f.first_name, "") 	? bPass : false;
		bPass = CheckForInput(f.email, "") 	? bPass : false;
		bPass = CheckForInput(f.tel, "") 	? bPass : false;
		bPass = CheckForInput(f.company_name, "") 	? bPass : false;
	
		// Validate form and email
		if(!bPass) { alert('Please complete the highlighted fields as these are mandatory.'); return false; }
		if(!validateEmail(f.email.value))	{ alert('Please enter a valid email.'); document.f.email.focus(); return false; }
	
		// If all ok, return true
		return true;
	}

	/* Called to check that a required field is present */
	// Returns true/false depending on if data present
	function CheckForInput(inp, value2check){
		// Check that there is data
		if(stripWhitespace(inp.value) == value2check){
			// Highlight the background color if fail
			inp.style.backgroundColor = 'lightpink';
			return false;
		}else{
			// Remove the background color if ok
			inp.style.backgroundColor = 'white';
			return true;
		}
	}
	
	/* Remove white space from start & end of string */
	function stripWhitespace(str) {
		str = this != window ? this : str;
		return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	}
	
	/* Function to validate an email address */
	function validateEmail(email) {
		var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
		return regex.test(email);
	}
	

