function check_new_user_form(frm,no_password_check){
	errorColor = "#FFA";
  error = "";
	if (!frm["data[first_name]"].value){
    error += "  - First Name\n";
    frm["data[first_name]"].style.backgroundColor = errorColor;
  }
  else frm["data[first_name]"].style.backgroundColor = '';
  if (!frm["data[last_name]"].value){
    error += "  - Last Name\n";
    frm["data[last_name]"].style.backgroundColor = errorColor;
  }
  else frm["data[last_name]"].style.backgroundColor = '';
	if (!is_email(frm["data[email]"].value)){
    error += "  - Valid Email Address\n";
    frm["data[email]"].style.backgroundColor = errorColor;
  }
  else frm["data[email]"].style.backgroundColor = '';
	if (String(frm["data[password]"].value).length < 4 && !no_password_check){
    error += "  - Password\n";
    frm["data[password]"].style.backgroundColor = errorColor;
  }
  else frm["data[password]"].style.backgroundColor = '';
	if (frm["data[password]"].value != frm["password_check"].value && !no_password_check){
    error += "  - Passwords do not match\n";
    frm["password_check"].style.backgroundColor = errorColor;
  }
  else frm["password_check"].style.backgroundColor = '';
  
  if (error){
		alert("ERROR:\n\nYou have not completed all of the required fields correctly.\n\n"+error);
		return false;
	}else{
		return true;
	}
}

function toggleMailing(hide){
  displayVal = hide?'none':'';
  for (i = 0; i < 5; i++)
    document.getElementById("mailing"+i).style.display = displayVal;
}

function is_email (string) {
  var addressPattern = 
    /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,10}$/;
  return addressPattern.test(string);
}
