function verify(theForm) {
  var why = "";
  why += checkUrl(theForm.domain.value);
  if(theForm.partner_fname.value == ""){
    why += "Please enter your first name.\n";
  }
  if(theForm.partner_lname.value == ""){
    why += "Please enter your last name.\n";
  }
  if(theForm.checkname.value == ""){
    why += "Please enter a name to print on checks.\n";
  }
  why += checkUsername(theForm.login_id.value);
  if (theForm.login_id.value == theForm.password.value){
    why += "Your username and password cannot be the same.\n";
  }
  why += checkPassword(theForm.password.value);
  if (!(theForm.password.value == theForm.password1.value)){
    why += "Password confirmation does not match.\n";
  }
  if(theForm.mail_address1.value == ""){
    why += "Please enter your address.\n";
  }
  if(theForm.mail_city.value == ""){
    why += "Please enter a city.\n";
  }
  if(theForm.mail_state.options[theForm.mail_state.selectedIndex].value == "XX" && theForm.otherstate.value == ""){
    why += "Please enter a state.\n";
  }
  if(theForm.mail_zipcode.value == ""){
    why += "Please enter a zipcode.\n";
  }
  why += checkEmail(theForm.email.value);
  if(theForm.mail_country.options[theForm.mail_country.selectedIndex].value == "US" && theForm.tax_id.value == ""){
    why += "Please enter a tax id or SSN.\n";
  }

  if (why != ""){
    alert(why);
    return false;
  }

  return true;
}

function checkUrl (strng) {
  var error = "";
  if (strng == ""){
    error = "Please enter a site url.\n";
    return error;
  }

  var urlFilter = /\w+:\/\/\w+/;
  if (!(urlFilter.test(strng))){
    error += "Please enter a valid site url.\n";
  }
  //test email for illegal characters
  var illegalChars= /[\(\)\<\>\,\;\\\"\[\]]/
  if (strng.match(illegalChars)) {
    error += "Your site url contains illegal characters.\n";
  }
  return error;
}

function checkEmail (strng) {
  var error = "";
  if (strng == "") {
    error = "Please enter an email address.\n";
    return error;
  }

  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(strng))) {
    error += "Please enter a valid email address.\n";
  }
  //test email for illegal characters
  var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
  if (strng.match(illegalChars)) {
    error += "Your email address contains illegal characters.\n";
  }
  return error;
}

function checkPassword (strng) {
  var error = "";
  if (strng == "") {
    error = "Please choose a password.\n";
    return error;
  }

  var illegalChars = /[\W_]/; // allow only letters and numbers

  if ((strng.length < 6) || (strng.length > 15)) {
    error += "Your password must be between 6 and 15 characters in length.\n";
  }
  if (illegalChars.test(strng)) {
    error += "Your password contains illegal characters (letters and numbers only).\n";
  }
  var alphaChars = /[a-zA-Z]/;
  var numChars = /[0-9]/;
  if (!(alphaChars.test(strng)) || !(numChars.test(strng))) {
    error += "Your password must contain both letters and numbers.\n";
  }
  return error;
}

function checkUsername (strng) {
  var error = "";
  if (strng == "") {
    error = "Please choose a username.\n";
    return error;
  }

  var illegalChars = /\W/; // allow letters, numbers, and underscores

  if ((strng.length < 6) || (strng.length > 15)) {
    error += "Your username must be between 6 and 15 characters in length.\n";
  }
  if (illegalChars.test(strng)) {
    error += "The username contains illegal characters (letters, numbers and underscore only).\n";
  }
  return error;
}