/* **************************************************** *
 * *  This function will ensure the Telephone Number  * *
 * *  is in the format of 999-999-9999.               * *
 * **************************************************** */
function validate_phone(that, fphone)
{
	var phonemsgString = "Please enter your telephone number with area code\nin the format of \"999-999-9999\".";
	// If the Telephone Number field is blank, it cannot be in the format 999-999-9999.
	if (fphone == "")
	{
		alert(phonemsgString);
		that.focus();
		return false;
	}
	else
	{
		// If the length is not 12 characters, it cannot be in the format 999-999-9999.
		if (fphone.length != 12)
		{
			alert(phonemsgString);
			that.focus();
			return false;
		}
		else
		{
			//	Rules for the telephone number regular expression:
			//	1. The start of the telephone number must consist of three digits followed by a hyphen.
			//	2. After the first hyphen, three more digits followed by a hyphen must appear.
			//	3. After the second hyphen, four more digits must appear.
			var re;
			re = /^\d{3}\-\d{3}\-\d{4}/;
			if (re.test(fphone) == false)
			{
				alert(phonemsgString);
				that.focus();
				return false;
			}
		}
	}
	return true;
}

