function isValidFirstName(strName) {
	if (/[^A-Za-z -]/.test(strName)) { return false; }
	return true;
}

function isValidLastName(strName) {
	if (/[^A-Za-z -]/.test(strName)) { return false; }
	return true;
}

function isValidStreetAddress(strAddress) {
	if (strAddress.length < 3) { return false; }
	if (strAddress.replace(/[^0-9]/g, "").length < 1) { return false; }
	if (strAddress.replace(/[^A-Za-z]/g, "").length < 1) { return false; }
	return true;
}

function isValidCity(strCity) {
	if (strCity.length < 2) { return false; }
	if (/[^A-Za-z -]/.test(strCity)) { return false; }
	return true;
}

function isValidEntirePhone(strPhone) {
	var bparsedStr = trimString(strPhone);
	var parsedStr = getParsedPhoneStr(bparsedStr);
	if (parsedStr.length < 10) { return false; }
	if (parsedStr.length > 17) { return false; }
	if (/^[01]/.test(parsedStr)) { return false; }
	var npa = parsedStr.substring(0,3);
	if (!isValidPhoneNPA(npa)) {
		return false;
	}
	var nxx = parsedStr.substring(3,6);
	if (!isValidPhoneNXX(nxx)) {
		return false;
	}

	return true;
}

function isValidPhoneNPA(strNPA) {
	if (strNPA.length < 3) { return false; }
	if (/[^0-9]/.test(strNPA)) { return false; }
	if (/^[01]/.test(strNPA)) { return false; }
	if ("200,222,300,333,400,444,500,555,600,666,700,777,900,999".indexOf(strNPA) != -1) { return false; }
	return true;
}

function isValidPhoneNXX(strNXX) {
	if (strNXX.length < 3) { return false; }
	if (/[^0-9]/.test(strNXX)) { return false; }
	if (/^[01]/.test(strNXX)) { return false; }
	return true;
}

function trimString(strIn) {
	if (/^\s/.test(strIn)) { strIn = strIn.replace(/^\s{1,}/, ""); }
	if (/\s$/.test(strIn)) { strIn = strIn.replace(/\s{1,}$/, ""); }
	return strIn;
}
function getParsedPhoneStr(strIn) {
	strIn = strIn.replace(/\.|-| |\(|\)/g,"");
	return strIn;
}
function isValidEmail(strEmail) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

	if (strEmail.length < 5) { return false; }

	if (!strEmail.match(re)) { return false; }

	return true;
}

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter correct zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}


function checkABA(s) {
  var i, n, t;
  t = "";
  for (i = 0; i < s.length; i++) {
    c = parseInt(s.charAt(i), 10);
    if (c >= 0 && c <= 9)
      t = t + c;
  }

  if (t.length != 9)
    return false;

  n = 0;
  for (i = 0; i < t.length; i += 3) {
    n += parseInt(t.charAt(i),     10) * 3
      +  parseInt(t.charAt(i + 1), 10) * 7
      +  parseInt(t.charAt(i + 2), 10);
  }

  if (n != 0 && n % 10 == 0)
    return true;
  else
    return false;
}
