function validatePhone( vField, vEdits ) {
//Author: Mark Thompson			
//Purpose: Validate 10 digit Phone Number that includes an area code,  then reformat 
//      the number
//Subroutines used: alertBox, strip_chars
//strip input of spaces, hyphens, underscores, parenthesis, and slashes to prepare for validation testing

	var ph_str = strip_chars(vField.value, " -_()/ \\");
  	var ph_len = ph_str.length;

	var msg = "Please enter a valid Phone Number with area code.  It can only contain numbers and dashes. Do not include '1' for long distance.  International phone numbers are not valid for this field.";

//test if there is no input (not required)

	if (vEdits != null) {

		if ( (vEdits.indexOf("nr") > -1) || (vEdits.indexOf("NR") > -1) ) {

			if (ph_str == ""){
				vField.value = "";
				return true;
			}
		}
	}
//test for leading zero or 1
	if ((ph_str.substring(0,1) == 0) || (ph_str.substring(0,1) == 1)) {
		alertBox (vField, msg, "text");
		return false;
	}
//test the phone number has 10 digits
	if (ph_len != 10) {
		alertBox (vField, msg, "text");
		return false;
	}
//if the phone number is not empty, and has 10 digits, test for numerics (ch is assigned a numeric value)
//loop:  as long as j equals numerics, add one to j and test the next value till you reach 
//   the length of the string
	for (var j = 0; j < ph_len; j++) {
		var ch = ph_str.substring(j, j+1);
		if ((ch < "0") || ( ch > "9")) {
			alertBox (vField, msg, "text");
 			return false;  
		}
	}
//reformat phone number (area code) 123-4567
	vField.value = "("+ ph_str.substring(0,3) + ") " + ph_str.substring(3,6) +  
		"-" + ph_str.substring(6,10); 
     return true;
}
function ValidatePhone( vField, vEdits ) {
	return validatePhone( vField, vEdits ) }
