// NARZ validation | 25/07/2005
// In-use as data is posted via SalesForce.
// AP.
<!--
	// check required fields are not empty
	function isNotEmpty(elem, fieldname) {
	var error = "";
	var str = elem.value;
	var re = /.+/;
	if(!str.match(re)) {
		error = "* " + fieldname + " is required.\n";
		}
	else {
		error = "";
	}
	return error;
}
	// validate email address
	function isEmailAddr(elem, fieldname) {
		var error = "";
		var str = elem.value;
		var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		if (str == "") {
			error = "* Email address is required.\n";
			return error;
			}
		if (!str.match(re)) {
			error = "* Email address is not valid.\n";
			}
		else
			{
			error = "";
		}
		return error;
	}

	function isNumeric(elem, fieldname)
	//  check for valid numeric strings	
	{
	var strString = elem.value;
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	if (strString.length == 0) return false;
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
		{
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1)
			{
				alert (fieldname + " requires a numerical value.");
				blnResult = false;
			}
		}
	return blnResult;
	}

	//returns a string message for use in a combined error string
	function isNumericMessage(elem, fieldname)
	//  check for valid numeric strings	
	{
	var error = "";
	var strString = elem.value;
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	if (strString.length != 0) 
		{
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
		{
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1) {
    		        error = "* " + fieldname + ".\n";
		        }
			else {
				error = "";
			}
		}
		}
	return error;
	}

   function elemExists(elem) {
		return (document.forms[0].elements[elem] != null && (typeof(document.forms[0].elements[elem]) == "object"));
    }

	function validateForm(form) {
		var strReason = "";
		strReason += isNotEmpty(form.first_name, "First name");
		strReason += isNotEmpty(form.last_name, "Last name");
		strReason += isNotEmpty(form.company, "Company name");
		strReason += isEmailAddr(form.email, "Email address");

		if (elemExists('noOfEmployees')) strReason += isNotEmpty(form.noOfEmployees, "No. of employees");
		if (elemExists('noOfEmployees')) strReason += isNumericMessage(form.noOfEmployees, "Please enter the number of employees as numerical values only");

		if (strReason != "") {
			alert("We were unable to process your details\nbecause of the following:\n\n" + strReason);
		return false;
		}
	return true;
	}
	function validateContactForm(form) {
		var strReason = "";
		strReason += isNotEmpty(form.first_name, "First name");
		strReason += isNotEmpty(form.last_name, "Last name");
		strReason += isNotEmpty(form.company, "Company name");
		strReason += isEmailAddr(form.email, "Email address");
		// strReason += isNotEmpty(form.description, "Your Message");
		if (strReason != "") {
			alert("We were unable to process your details\nbecause of the following:\n\n" + strReason);
		return false;
		}
	return true;
	}
	function isUndefined(a) {
		return typeof a == 'undefined';
	}
	//get the referrer and populate the hidden referrer field on the form
	function getReferrer(){
		var strReferrer = '';
		var strQS = String(window.location);
		var s = strQS.split("referrer=");
		strReferrer = s[1];
		if(isUndefined(strReferrer)==false){
			document.frmMain.lead_source.value = strReferrer;
		}
	}
//->
