function checkPhone(textbox) {
	var num = textbox.value;
	
	//can't be more than 8 characters
	if (num.length > 8) {
		alert('Please enter phone number in the following format:\n\n555-5555');
		textbox.focus();
		event.returnValue = false;
		return false;
	//can't be less than 7 characters 
	} else if (num.length < 7) {
		alert('Please enter phone number in the following format:\n\n555-5555');
		textbox.focus();
		event.returnValue = false;
		return false;
	//must be either 7 or 8 characters long
	//if it's 8 chars...
	} else if (num.length == 8) {
		//must contain a dash in the fourth position
		if (num.indexOf('-') != 3) {
			alert('Please enter phone number in the following format:\n\n555-5555');
			textbox.focus();
			event.returnValue = false;
			return false;
		//the prefix before the dash must be numeric
		} else if (isNaN(num.substr(0, num.indexOf('-')))) {
			alert('Please enter phone number in the following format:\n\n555-5555');
			textbox.focus();
			event.returnValue = false;
			return false;
		//the suffix after the dash must be numeric
		} else if (isNaN(num.substr(num.indexOf('-')))) {
			alert('Please enter phone number in the following format:\n\n555-5555');
			textbox.focus();
			event.returnValue = false;
			return false;
		}
	//if it's 7 chars...
	} else if (num.length == 7) {
		//all 7 characters must be numeric
		if (isNaN(num)) {
			alert('Please enter phone number in the following format:\n\n555-5555');
			textbox.focus();
			event.returnValue = false;
			return false;
		//it's a valid number with no dash.  Just add the dash in.
		} else {
			textbox.value = num.substr(0, 3) + '-' + num.substr(3);
		}
	}
	
	//everything must have passed the test so return true
	return true;
}

function checkAreaCode(textbox) {
	var num = textbox.value;
	
	if (num.length != 3 || isNaN(num)) {
		alert('Please enter area code in the following format:\n\n555');
		textbox.focus();
		return false;
	}
	
	return true;
}

