/****************************************************************************/
/***		Client-side JavaScript function library														***/
/***		Copyright Apache Solutions Ltd 2005																***/
/***		(unauthorised use of this code will result in prosecution by law)	***/
/****************************************************************************/

//
// Validates the form:
//
function ValidateForm(form) {
	if (!CheckMandatory(form.name, "Please enter your Name.")) return false;
	if (!CheckMandatory(form.telephone, "Please enter your Phone Number.")) return false;
	if (!CheckMandatory(form.cpcode, "Please enter verification code.")) return false;
	return true;
}

//
//	Returns true if the given variable is blank:
//
function IsBlank(value) {
	// cast to string.
	var str = "" + value;
	return ((str == "") || (str == " ") || (str == "undefined") || (str == "null") || (str == null));
}

//
//	Checks whether the user has entered data in the given field, displaying the given message,
//	focusing the field and returning false if not:
//
function CheckMandatory(field, msg) {
	if (IsBlank(field.value)) {
		alert(msg);
		field.focus();
		return false;
	}
	return true;
}	

//-->