// validates that the field value string has one or more characters in it
function isNotEmpty(elem, strelem) {
	var str = elem.value;
	if( str == null || str.length ==0)
	{
		alert( "Please fill in the "+strelem+" field.");
		return( "Please fill in the "+strelem+" field.");
	}
	else
		return "";
}
// validates that the entry is formatted as an email address
function isEmailAddr(elem) {
	var str = elem.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	//alert(re);
	if( !str.match(re))
	{
		alert("Verify the email address format");
		return("Verify the email address format");
	}
	else
		return "";
}
// validates that two elements are the same;
function isEqual(elem1, elem2, errormsg) {
	var str1 = elem1.value;
	var str2 = elem2.value;
	if( str1 != str2) 
	{
		alert(errormsg);
		return( errormsg )
	}
	else
		return "";
}

function validateJoin( form ) {
	if( isEmailAddr(form.Join1_EmailBox) == "")
	{
		if( isNotEmpty(form.Join1_PasswordBox1, "Password") == "")
		{
			if( isEqual(form.Join1_PasswordBox1, form.Join1_PasswordBox2,"Verify that the passwords are the same") == "" )
			{
				if( isNotEmpty( form.Join1_AliasBox, "Alias" ) == "")
				{
					if( isNotEmpty( form.Join1_FirstnameBox, "First name") == "")
					{
						if( isNotEmpty( form.Join1_LastnameBox, "Last name") == "")
						{
							if( isNotEmpty( form.Join1_ZipcodeBox, "Zipcode") == "")
							{
								return true;
							}
						}
					}
				}
			}
		}
	}
	return false;
}
