
	function validateContactForm(theForm) {
		var problems = '';
		theForm.buttonSubmit.disabled = true;

		if (theForm.txtFirstName.value.length == 0) {
			problems = problems + '- The First Name is blank. Please enter your first name\n';
		};
		if (theForm.txtLastName.value.length == 0) {
			problems = problems + '- The Last Name is blank. Please enter your last name\n';
		};
		if (theForm.txtTelephone.value.length == 0 || theForm.txtTelephone.value == '###-###-####') {
			problems = problems + '- The Phone number is blank. Please enter a phone number\n';
		} else if (!(checkInternationalPhone(theForm.txtTelephone.value))) {
			problems = problems + '- The Phone number should contain only numbers and dashes\n';
		};
		if (!(IsEmail(theForm.txtEmail.value))) {
			problems = problems + '- The Email address you entered is blank or not formatted correctly. Addresses should be formatted as account@domain.com\n';
		};
		if (theForm.txtMessage.value.length == 0) {
			problems = problems + '- The Message is blank. Please enter a message\n';
		} else if (theForm.txtMessage.value.indexOf('<') >= 0 || theForm.txtMessage.value.indexOf('>') >= 0) {
			problems = problems + '- The Message contains invalid characters. Please remove any HTML or JavaScript code from your message\n';
		};
		if (theForm.txtSecurityCode.value.length != 5) {
			problems = problems + '- The Security Code is not the correct number of characters. Please enter the security code\n';
		};
		if (problems.length == 0) {
			theForm.buttonSubmit.disabled = false;
			return true;
		} else {

			alert('The form cannot be submitted because of the following problems.\n\n' + problems + '\nPlease correct these problems and submit the form again.');
			theForm.buttonSubmit.disabled = false;
			return false;
		}
	}


	function IsEmail(str) {
		// 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 (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

		    // IF EMAIL ADDRESS HAS A '@' CHARACTER
		    if (checkString.indexOf("@") != -1) {
		      at = true;

		    // IF EMAIL ADDRESS HAS A '.' CHARACTER
		    } else if (checkString.indexOf(".") != -1) {
		      dot = true;
		    }
		    // PARSE REMAINDER OF STRING
		    for (var i = 0; i < checkString.length; i++) {
		        ch = checkString.substring(i, i + 1)
		        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
		                || (ch == "@") || (ch == ".") || (ch == "_")
		                || (ch == "-") || (ch >= "0" && ch <= "9")) {
		                newstr += ch;
		                if (ch == "@") {
		                    at=true;
		                }
		                if (ch == ".") {
		                    dot=true;
		                }
		        }
		    }
		    if ((at == true) && (dot == true)) {
		        return true;
		    }
		    else {
		      return false;
		    }
		}
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(str) && r2.test(str));
	}


	/**
	 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
	 */

	// Declaring required variables
	var digits = "0123456789";

	// non-digit characters which are allowed in phone numbers
	var phoneNumberDelimiters = "()- ";

	// characters which are allowed in international phone numbers
	// (a leading + is OK)

	var validWorldPhoneChars = phoneNumberDelimiters + "+";
	// Minimum no of digits in an international phone no.

	var minDigitsInIPhoneNumber = 10;

	function isInteger(s)
	{   var i;
	    for (i = 0; i < s.length; i++)
	    {
	        // Check that current character is number.
	        var c = s.charAt(i);
	        if (((c < "0") || (c > "9"))) return false;
	    }
	    // All characters are numbers.
	    return true;
	}

	function stripCharsInBag(s, bag)
	{   var i;
	    var returnString = "";
	    // Search through string's characters one by one.
	    // If character is not in bag, append to returnString.
	    for (i = 0; i < s.length; i++)
	    {
	        // Check that current character isn't whitespace.
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) returnString += c;
	    }
	    return returnString;
	}

	function checkInternationalPhone(strPhone){
		s=stripCharsInBag(strPhone,validWorldPhoneChars);
		return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
	}


