
// This function tests for a phone number
// Required value is either (xxx)xxx-xxxx
function isPhoneNumber(testString){
	// Allow (xxx)xxx-xxxx
	if (testString.search(/^\([0-9]{3}\)[0-9]{3}\-[0-9]{4}$/) == 0 ) return true;
	// Allow xxx-xxx-xxxx
	if (testString.search(/^[0-9]{3}\-[0-9]{3}\-[0-9]{4}$/) == 0 ) return true;
	// Allow xxxxxxxxxx
	if (testString.search(/^[0-9]{10}$/) == 0 ) return true;
	
	return false;
}

function isEmailAddr(email){
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

// trim removes spaces and other non-printable characters from the beginning and end of a string.
function trim(thisString){
	var newString = thisString;
	while (newString.charCodeAt(0) < 33){
		newString = newString.substring(1,newString.length);
	}
	
	while (newString.charCodeAt(newString.length - 1) < 33){
		newString = newString.substring(0, newString.length - 1);
	}
	return newString;
}

