<!--

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function user_account_form_validator(theForm)
{

	if (theForm.user_first_name.value.length == 0)
	{
	  alert("Please enter your \"First Name\".");
	  theForm.user_first_name.focus();
	  return (false);
	}

	if (theForm.user_last_name.value.length == 0)
	{
	  alert("Please enter your \"Last Name\".");
	  theForm.user_last_name.focus();
	  return (false);
	}

	if (theForm.user_email_addr.value.length == 0)
	{
	  alert("Please enter your \"Email Address\".");
	  theForm.user_email_addr.focus();
	  return (false);
	}

	if (!check_email(theForm.user_email_addr.value))
	{
	  alert("Please enter a valid \"Email Address\".");
	  theForm.user_email_addr.focus();
	  return (false);
	}

	if (theForm.user_email_addr_confirm.value.length == 0)
	{
	  alert("Please confirm your \"Email Address\".");
	  theForm.user_email_addr_confirm.focus();
	  return (false);
	}

	 if (theForm.user_email_addr.value != theForm.user_email_addr_confirm.value)
	{

		alert("The Email Addresses that you typed in do not agree with one another. Please try again.");
		theForm.user_email_addr.focus();
		return (false);
	}

	// if the form is the sign up form, validate birthdate
	if (theForm.name == 'new_user_account_form')
	{

		if (theForm.user_birthdate_month.value.length == 0)
		{
			alert("Please select the \"Birth Month\" of your Birthday.");
			theForm.user_birthdate_month.focus();
			return (false);
		}

		if (theForm.user_birthdate_day.value.length == 0)
		{
			alert("Please select the \"Birth Day\" of your Birthday.");
			theForm.user_birthdate_day.focus();
			return (false);
		}

		if (theForm.user_birthdate_year.value.length == 0)
		{
			alert("Please select the \"Birth Year\" of your Birthday.");
			theForm.user_birthdate_year.focus();
			return (false);
		}

	}

	// default phone lengths (USA / Canada)
	var phone_num_area_code_min_length = 3;
	var phone_num_area_code_max_length = 3;
	var phone_num_prefix_min_length = 3;
	var phone_num_prefix_max_length = 3;
	var phone_num_suffix_min_length = 4;
	var phone_num_suffix_max_length = 4;
	var format = "NNN NNN NNNN";
	
	if (theForm.user_country.value == 'UK' || theForm.user_country.value == 'IE')
	{
		var phone_num_area_code_min_length = 2;
		var phone_num_area_code_max_length = 6;
		var phone_num_prefix_min_length = 1;
		var phone_num_prefix_max_length = 4;
		var phone_num_suffix_min_length = 1;
		var phone_num_suffix_max_length = 4;
		var format = "0 + phone number";
	}
	else if (theForm.user_country.value == 'AU')
	{
		var phone_num_area_code_min_length = 2;
		var phone_num_area_code_max_length = 2;
		var phone_num_prefix_min_length = 4;
		var phone_num_prefix_max_length = 4;
		var phone_num_suffix_min_length = 4;
		var phone_num_suffix_max_length = 4;
		var format = "0N NNNN NNNN";
	}	
	else if (theForm.user_country.value == 'NZ')
	{
		var phone_num_area_code_min_length = 2;
		var phone_num_area_code_max_length = 2;
		var phone_num_prefix_min_length = 1;
		var phone_num_prefix_max_length = 4;
		var phone_num_suffix_min_length = 1;
		var phone_num_suffix_max_length = 6;
		var format = "0 + phone number";
	}	

	
	if (theForm.user_phone_num_area_code.value.length < phone_num_area_code_min_length || theForm.user_phone_num_area_code.value.length > phone_num_area_code_max_length)
	{
	  alert("Please enter your \"Phone Number\" ("+format+").");
	  theForm.user_phone_num_area_code.focus();
	  return (false);
	}

	if (theForm.user_phone_num_prefix.value.length < phone_num_prefix_min_length || theForm.user_phone_num_prefix.value.length > phone_num_prefix_max_length)
	{
	  alert("Please enter your \"Phone Number\" ("+format+").");
	  theForm.user_phone_num_prefix.focus();
	  return (false);
	}

	if (theForm.user_phone_num_suffix.value.length < phone_num_suffix_min_length || theForm.user_phone_num_suffix.value.length > phone_num_suffix_max_length)
	{
	  alert("Please enter your \"Phone Number\" ("+format+").");
	  theForm.user_phone_num_suffix.focus();
	  return (false);
	}

	if (!check_numeric(theForm.user_phone_num_area_code.value) || !check_numeric(theForm.user_phone_num_prefix.value) || !check_numeric(theForm.user_phone_num_suffix.value))
	{
	  alert("Please enter a valid \"Phone Number\".");
	  theForm.user_phone_num_area_code.focus();
	  return (false);
	}

	if (theForm.user_addr_line_1.value.length == 0)
	{
	  alert("Please enter your \"Address\".");
	  theForm.user_addr_line_1.focus();
	  return (false);
	}

	if (theForm.user_city.value.length == 0)
	{
	  alert("Please enter your \"City\".");
	  theForm.user_city.focus();
	  return (false);
	}

	if (theForm.user_state.value.length == 0 )
	{
	  alert("Please select your \"State, Province, County, or Territory\".");
	  theForm.user_state.focus();
	  return (false);
	}

	if (theForm.user_postal_code.value.length == 0)
	{
	  alert("Please enter your \"Zip / Postal Code\".");
	  theForm.user_postal_code.focus();
	  return (false);
	}

	if ( (theForm.user_country.value == 'US' && (theForm.user_state.value != 'AA' && theForm.user_state.value != 'AE' && theForm.user_state.value != 'AL' && theForm.user_state.value != 'AK' && theForm.user_state.value != 'AP' && theForm.user_state.value != 'AS' && theForm.user_state.value != 'AZ' && theForm.user_state.value != 'AR' && theForm.user_state.value != 'CA' && theForm.user_state.value != 'CO' && theForm.user_state.value != 'CT' && theForm.user_state.value != 'DC' && theForm.user_state.value != 'DE' && theForm.user_state.value != 'FL' && theForm.user_state.value != 'FM' && theForm.user_state.value != 'GA' && theForm.user_state.value != 'GU' && theForm.user_state.value != 'HI' && theForm.user_state.value != 'ID' && theForm.user_state.value != 'IL' && theForm.user_state.value != 'IN' && theForm.user_state.value != 'IA' && theForm.user_state.value != 'KS' && theForm.user_state.value != 'KY' && theForm.user_state.value != 'LA' && theForm.user_state.value != 'ME' && theForm.user_state.value != 'MD' && theForm.user_state.value != 'MA' && theForm.user_state.value != 'MH' && theForm.user_state.value != 'MI' && theForm.user_state.value != 'MN' && theForm.user_state.value != 'MP' && theForm.user_state.value != 'MS' && theForm.user_state.value != 'MO' && theForm.user_state.value != 'MT' && theForm.user_state.value != 'NE' && theForm.user_state.value != 'NV' && theForm.user_state.value != 'NH' && theForm.user_state.value != 'NJ' && theForm.user_state.value != 'NM' && theForm.user_state.value != 'NY' && theForm.user_state.value != 'NC' && theForm.user_state.value != 'ND' && theForm.user_state.value != 'OH' && theForm.user_state.value != 'OK' && theForm.user_state.value != 'OR' && theForm.user_state.value != 'PA' && theForm.user_state.value != 'PR' && theForm.user_state.value != 'PW' && theForm.user_state.value != 'RI' && theForm.user_state.value != 'SC' && theForm.user_state.value != 'SD' && theForm.user_state.value != 'TN' && theForm.user_state.value != 'TX' && theForm.user_state.value != 'UT' && theForm.user_state.value != 'VI' && theForm.user_state.value != 'VT' && theForm.user_state.value != 'VA' && theForm.user_state.value != 'WA' && theForm.user_state.value != 'WV' && theForm.user_state.value != 'WI' && theForm.user_state.value != 'WY')) || (theForm.user_country.value == 'CA' && (theForm.user_state.value != 'AB' && theForm.user_state.value != 'BC' && theForm.user_state.value != 'MB' && theForm.user_state.value != 'NB' && theForm.user_state.value != 'NL' && theForm.user_state.value != 'NT' && theForm.user_state.value != 'NS' && theForm.user_state.value != 'NU' && theForm.user_state.value != 'ON' && theForm.user_state.value != 'PE' && theForm.user_state.value != 'QC' && theForm.user_state.value != 'SK' && theForm.user_state.value != 'YT')) )

	{
	  alert("You have selected a \"Country\" and \"State/Province\" that do no match.\n\nPlease correct your \"Country\" and/or your \"State/Province\".");
	  theForm.user_country.focus();
	  return (false);
	}

	// if the form is the sign up form, make sure they checked the privacy agreement
	if (theForm.name == 'new_user_account_form')
	{

		if (!theForm.user_agree_terms_privacy.checked)
		{ 
		  alert("You must agree to the \"Terms of Service\" and \"Privacy Policy\" before you can proceed.");
		  theForm.user_agree_terms_privacy.focus();
		  return (false);		
		}

	}

	document.getElementById('account_form_submit_button').disabled=true;
	document.getElementById('account_form_submit_button').value='Processing...'

} // end function order_form_validator(theForm)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-->

