function isEmail(s) {
	var invalid = "<>:;!\"£#$^*()'[]{}~+=?/,`|\\";       // invalid email address characters
	var result = true;
	for (var i = 0; i < invalid.length; i++) {
		result = result && (s.indexOf(invalid.substring(i,i+1)) < 0)
	} // for (i)
	if (s.indexOf("@") == -1 || s.indexOf(".") == -1 || s.indexOf("@") != s.lastIndexOf("@")) result = false;
	return result;
} // public function Boolean isEmail(Object s)

function isEmail_RE(s) {
	s += '';
	var re = /^[\w!#$%'*+\-\/=?^`{}|~][\w\.!#$%'*+\-\/=?^`{}|~]+\@[A-Z0-9\-]+\.[A-Z0-9\.\-]+[A-Z]$/i;
	return (s != '' && s.search(re) != -1);
} // public function Boolean isEmail_RE(String s)

function validateForm() {
	var allowSubmit = true;
	var txtError = 'Please check that the following fields are\ncompleted correctly before proceeding:\n\n'
	
	if (document.getElementById("yourName")) {
		if (document.getElementById("yourName").value.length <= 1) {
			txtError += '- Your name\n';
			allowSubmit = false;	
		}		
	}

	if (document.getElementById("yourEmail")) {
		if (!isEmail_RE(document.getElementById("yourEmail").value)) {
			txtError += '- Your email address\n';
			allowSubmit = false;	
		}
	}
	
	if (document.getElementById("friendsName")) {
		if (document.getElementById("friendsName").value.length <= 1) {
			txtError += '- Your friend\'s name\n';
			allowSubmit = false;	
		}
	}
	
	if (document.getElementById("friendsEmail")) {
		if (!isEmail_RE(document.getElementById("friendsEmail").value)) {
			txtError += '- Your friend\'s email address\n';
			allowSubmit = false;	
		}
	}
	
	if (document.getElementById("message")) {
		if (document.getElementById("message").value.length <= 1) {
			txtError += '- Your message\n';
			allowSubmit = false;	
		}
	}
	
	if (!allowSubmit) alert(txtError);
	
	return allowSubmit;
}