<!--

// javascript for form checking

// whitespace characters
var whitespace = " \t\n\r";


function checkForm() {

	if ( isBlank(document.contact.uname) ) {
		alert('The name field is required.');
		contact.uname.focus();
		return false;
	}

	if ( isBlank(document.contact.email) ) {
		alert('The email field is required.');
		contact.email.focus();
		return false;
	}
	
	if ( isBlank(document.contact.phone) ) {
		alert('Telephone details are required.');
		contact.phone.focus();
		return false;
	}

	if ( isBlank(document.contact.address) ) {
		alert('Address details are required.');
		contact.address.focus();
		return false;
	}

	if ( isBlank(document.contact.info) ) {
		alert('The Further Information box is required.');
		contact.info.focus();
		return false;
	}

	return true;
}


function isBlank(tocheck) {

	// check for all whitespace
	if ( isWhitespace(tocheck.value) ) {
		return true;
	}

	// check if zero length or just null value
	if ( tocheck.value.length == 0 || tocheck.value == null ) {
		return true;
	}

	return false;
}


function isWhitespace (s)
{
	var i;

	// Search through strings characters one by one
	// until we find a non-whitespace character
	// When we do, return false; if we dont, return true

	for (i = 0; i < s.length; i++)
	{
		// Check that current character is not whitespace
		var c = s.charAt(i);

		if (whitespace.indexOf(c) == -1) return false;
	}

	// All characters are whitespace
	return true;
}

//-->