
//these are defined before the js is included so that they can be localized
//ERROR_MISSING = "Please complete all required fields";
//ERROR_EMAIL_ADDRESS = "Please enter a valid email address";				

function submitform(action) 
{	
	if (action == "emailsubmit" && validateRegistration(document.emailpage))
	{
		document.modify.action.value="emailsubmit";
		document.modify.submit();
	}
}

function validateRegistration(theForm)
{	
	if (theForm.your_name.value == "")	
	{
		alert(ERROR_MISSING);
		theForm.your_name.focus();
		return (false);
	}

	if (theForm.your_email.value == "")
	{
		alert(ERROR_MISSING);
		theForm.your_email.focus();
		return (false);
	}

	if (theForm.friends_email.value == "")
	{
		alert(ERROR_MISSING);
		theForm.friends_email.focus();
		return (false);
	}

	else {
		var filter=/^([\w-+]+(?:\.[\w-+]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

		if (!filter.test(theForm.your_email.value)) {
			alert(ERROR_EMAIL_ADDRESS);
			theForm.your_email.focus();
			return false;
		}

		if (!filter.test(theForm.friends_email.value)) {
			alert(ERROR_EMAIL_ADDRESS);
			theForm.friends_email.focus();
			return false;
		}
	}
	popClose('email_page');
	popOpen('email_page_confirm');
	return (true);

}

