// $Id: help_contact.js 10219 2011-05-12 09:00:31Z tal $
// Functions to support validation of find_tellFriend

// Variables to be populated in the HTML: 
// none, but valStrings should come from requiredFields.js

// A fall-back to prevent failure in case the function emailCheck doesn't exist.
if (typeof checkEmail == "undefined") {
	function checkEmail () {
		return true;
	}
}

// Username validation
function checkUsername (formElement) {
	valStrings["username"] = formElement.value;
	if (!formElement.value.match(/^\w{3,20}$/) && formElement.value) {
		alert(valStrings["usernameLength"]); 
		formElement.value = formElement.value.replace(/\W/g, '');
		if (formElement.value.length < 3) {
			formElement.value = '';
		}
		formElement.focus();
		return false;
	} else {
		return true;
	}
}

// Conditions for form submission
function submitContact (checkForm) {
	return (checkRequiredFields(checkForm) 
	     && checkEmail (checkForm.email));
}

