/* <![CDATA[ */
var okColour = 'white';
var okText = 'black';
var errorColour = 'red';
var errorText = 'white';
var validated = true;

function validateRequired(fieldName) {
	if (document.getElementById(fieldName).value == '') {
		document.getElementById(fieldName).style.background = errorColour;
		document.getElementById(fieldName).style.color = errorText;
		validated = false;
		} else {
		document.getElementById(fieldName).style.background = okColour;
		document.getElementById(fieldName).style.color = okText;
		}
	}
	
function validateEmail(fieldName) {
	with (document.getElementById(fieldName)) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {
			document.getElementById(fieldName).style.background = errorColour;
			document.getElementById(fieldName).style.color = errorText;
			validated = false;
			} else {
			document.getElementById(fieldName).style.background = okColour;
			document.getElementById(fieldName).style.color = okText;
			}
		}
	}	

function submitForm() {
	// Set validated to true
	validated = true;
	
	// Validate the fields
	validateRequired('message');
	validateRequired('name');
	validateEmail('email');
	
	// If there were no errors, submit the form
	if (validated == true) {		
		// Finally, submit the form
		document.getElementById('enquiry').submit();
		//document.enquiry.submit();
		}
	
	}
	
/* ]]> */


