function Validator(theForm)
{
	var strName = new String;
	var myindex;
	// Validate that a marketing source selection was made
	if (theForm.MktSrc.options[0].selected)
		{
			alert("Please make a selection of how you heard about Vital Nutrients.");
			theForm.MktSrc.focus();
			return (false);
		}
	else
	    {
	       if (theForm.MktSrc.options[theForm.MktSrc.selectedIndex].value == "Other")
	          {
  	             // If user chose a marketing source of 'Other' then ensure they type something in.
//  	             alert(theForm.MktSrcOther.value.length);
	             if (theForm.MktSrcOther.value.length == 0)
	                {
					   alert("Please indicate how you heard about us.");
					   theForm.MktSrcOther.focus();
					   return (false);
	                }
	          }
	    }
	
	// Validate the User Name field
	if (theForm.username.value == "")
		{
			alert("Please enter your desired Practitioner User Name");
			theForm.username.focus();
			return (false);
		}
		
	// Validate the Password field
	if (theForm.password.value == "")
		{
			alert("Please enter your desired Password");
			theForm.password.focus();
			return (false);
		}
	else
		{
			if (theForm.password.value.length < 4)
				{
					alert("A minimum length of 4 is required for your password");
					theForm.password.focus();
					return (false);
				}
		}
		

	if (isSpecVars(theForm.password.value) == false)
		{
			alert("Special Characters and Spaces are not allowed in the Password field.");
			theForm.password.focus();
			return (false);
		}
		
		
	// Validate the Verify Password field
	if (theForm.verify_password.value == "")
		{
			alert("Please Verify your password");
			theForm.verify_password.focus();
			return (false);
		}
	else
		{
			if (theForm.verify_password.value != theForm.password.value)
				{
					alert("The Password and Verify Password you entered did not match");
					theForm.verify_password.focus();
					return (false);
				}
		}
		
	// Validate the Practitioner Company field
	if (theForm.company.value == "")
		{
			alert("Please enter your Company Name");
			theForm.company.focus();
			return (false);
		}
		
		
	// Validate the First Name field
	if (theForm.firstname.value == "")
		{
			alert("Please enter your First Name");
			theForm.firstname.focus();
			return (false);
		}
		
	// Validate the Last Name field
	if (theForm.lastname.value == "")
		{
			alert("Please enter your Last Name");
			theForm.lastname.focus();
			return (false);
		}
		
	// Validate the EMail Address field
	if (theForm.EmailAddress.value == "")
		{
			alert("Please a valid EMail Address");
			theForm.EmailAddress.focus();
			return (false);
		}
	else
		{
			if (isValidEmail(theForm.EmailAddress.value) == false)
				{
					alert("Please enter a valid EMail Address");
					theForm.EmailAddress.focus();
					return (false);
				}
		}

		
	// Validate the Address field
	if (theForm.Address.value == "")
		{
			alert("Please enter your Street Address");
			theForm.Address.focus();
			return (false);
		}
		
	// Validate the City field
	if (theForm.City.value == "")
		{
			alert("Please enter the name of your City");
			theForm.City.focus();
			return (false);
		}
	
	// Validate the State field
	if (theForm.State.value == "")
		{
			alert("Please enter the name of your State");
			theForm.State.focus();
			return (false);
		}

	// Validate the Zipcode field
	if (theForm.postalcode.value == "")
		{
			alert("Please enter your Zipcode");
			theForm.postalcode.focus();
			return (false);
		}
		
	if (theForm.PostalCodePlus.value.length > 0) 
		{
			if (theForm.PostalCodePlus.value.length != 4)
				{
					alert("Zipcode Plus must be 4-digits.");
					theForm.PostalCodePlus.focus();
					return (false);
				}
		}
		
	if (isNumeric(theForm.PostalCodePlus.value) == false)
		{
			alert("Numbers only allowed in Zipcode Plus.");
			theForm.PostalCodePlus.focus();
			return (false);
		}

	// Validate the Country field
	if (theForm.Country.value == "")
		{
			alert("Please enter your Country");
			theForm.Country.focus();
			return (false);
		}
	
	if (theForm.pract_type.options[0].selected)
		{
			alert("Please make a valid Practitioner Type selection");
			theForm.pract_type.focus();
			return (false);
		}
	
	if (theForm.Phone.value == "")
		{
			alert("Please enter your Phone Number");
			theForm.Phone.focus();
			return (false);
		}
			
	if (theForm.AddressType.options[0].selected)
		{
			alert("Please make a valid Address Type selection");
			theForm.AddressType.focus();
			return (false);
		}
	
	if (theForm.PhoneType.options[0].selected)
		{
			alert("Please make a valid Phone Type selection");
			theForm.PhoneType.focus();
			return (false);
		}
	
	return (true);
}

///////////////////////////////////////////////////////
// Function to check for a valid email address entered.
function isValidEmail(str) {
   return (str.indexOf("@") > 0);
//   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}


///////////////////////////////////////////////////////
// Function to check string for special vars.
function isSpecVars(str)
{
var iChars = "!@#$%^&*()-+=[]\\\';,./{}|\":<>? ";
  for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) != -1) {
  	return false;
  	}
  }
  
  return true;
}

///////////////////////////////////////////////////////
// Function to check string for special vars.
function isNumeric(str)
{
var iChars = "0123456789";
  for (var i = 0; i < str.length; i++) {
  	if (iChars.indexOf(str.charAt(i)) == -1) {
  	return false;
  	}
  }
  
  return true;
}

