<!-- hide code

function FormValidate(theForm) {
	var retval = true;

	if (theForm.First_Name.value == "") {
		retval = false;
		alert("Please enter your first name.");
		theForm.First_Name.focus();
	} else if (theForm.Last_Name.value == "") {
		retval = false;
		alert("Please enter your last name.");
		theForm.Last_Name.focus();
	} else if (theForm.Company.value == "") {
		retval = false;
		alert("Please enter your company name.");
		theForm.Company.focus();
	} else if (theForm.Email.value == "" || !_MW_validate_email(theForm.Email.value)) {
		retval = false;
		alert("Please enter a valid Internet email address.");
		theForm.Email.focus();
	} else if (theForm.PrimaryPhone.value == "" || !_MW_validate_characters(theForm.PrimaryPhone.value, '0123456789 .-+()')) {
		retval = false;
		alert("Please enter a valid phone number.");
		theForm.PrimaryPhone.focus();
	} else if (!_MW_validate_characters(theForm.SecondaryPhone.value, '0123456789 .-+()')) {
		retval = false;
		alert("Please enter a valid fax number.");
		theForm.SecondaryPhone.focus();
	} else if (theForm.Address_Line_1.value == "") {
		retval = false;
		alert("Please enter your Address.");
		theForm.Address_Line_1.focus();
	} else if (theForm.City.value == "") {
		retval = false;
		alert("Please enter your city.");
		theForm.City.focus();
	} else if (theForm.State_Province.value == "") {
		retval = false;
		alert("Please enter your state / province.");
		theForm.State_Province.focus();
	} else if (theForm.Postal_Code.value == "") {
		retval = false;
		alert("Please enter your zip / postal code.");
		theForm.Postal_Code.focus();
	} else if (theForm.Country.value == "") {
		retval = false;
		alert("Please enter your country.");
		theForm.Country.focus();
	}

	return retval;
}

// function to strip the "invalid" characters out of "input"
function MW_stripChars(input, invalid) {
	var newString = "";
	for (i = 0;  i < input.length; i++) {
    	myChar = input.charAt(i);
        if (invalid.indexOf(myChar) == -1)
        	newString += myChar;
	}
	return newString;
}

// function that returns whether or not an email address is actually potentially valid
function _MW_validate_email(address) {
		// if the length is zero, return true...need to specify other validation to catch this error
		// this allows validation if something is entered, but allows blanks in the event that no entry is allowed
		if (address.length == 0) return true;
	
		var atPosition = address.indexOf('@');
		var dotPosition = address.lastIndexOf('.');
		var addressLength = address.length;

		if (addressLength < 5)  // definitely bad here!
			return false;
		else if (atPosition < 1)
			return false;
		else if ((dotPosition < 3) ||
				(dotPosition <= (atPosition + 1)))
			return false;

		return true;
}

// determines if the input string contains only the characters specified in "valid"
function _MW_validate_characters(input, valid) {
	// loop once for each character in the input string
	for (i = 0; i < input.length; i++) {
		if (valid.indexOf(input.substring(i, i+1)) == -1) {
			return false;
		}
	}
	return true;
}
// end code hiding -->
