var form_object

function ValidateTextBox(form_object) {

	//  Purpose:    To Check if text boxes are empty
	//  Parameters: form_object: The text object 

	if (form_object.value == "") {
		return(false);
	}
	else {
		return(true);
	}
}

function errorMsg(msg, form_object) {

	// Purpose:    To display an error msg and set focus on the errored field.
	// Parameters: msg      : Contains the error message.
	//	       form_object : the field in error.

	alert(msg);
	form_object.focus();
	if(form_object.type == "text") {
		form_object.select();
	}
	return(false);
}


function ValidateEMail(i_strEMailAddress) {

	// Purpose:    To Check that the supplied E-Mail is in the correct format
	// Parameters: i_strEMailAddress : EMail to validate
	
	// are regular expressions supported?

	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) {
			supported = 1;
		}
	}

	if (!supported) {
    		return (i_strEMailAddress.indexOf(".") > 2) && (i_strEMailAddress.indexOf("@") > 0);
    	}

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	var r3 = new RegExp("\'|\"");
	return (!r1.test(i_strEMailAddress) && r2.test(i_strEMailAddress) && !r3.test(i_strEMailAddress));
}