function check_phone_number() {

  /* Set whether the user should use a -, a space, or one long number without divisions.
     Use the following values to set:
	 1 = Use - (i.e 123-456-7890)
	 2 = Use a space (i.e. 123 456 7890)
	 3 = Use none (i.e. 1234567890)
  */	 
  var num_division = 1;
  
  if (document.getElementById && document.createTextNode) {	
    
	var phone_num_OK = false; 
	var the_delim = "";
	var the_ph_test = "";
	var ph_err_msg ="";
    var the_phone_num = document.getElementById("q[2]").value;
	
	if (num_division == 1) {
		the_delim = "-";
		the_ph_test = /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/;
	   	phone_num_OK = the_ph_test.test(the_phone_num);
	}
	else if (num_division == 2) {
		the_delim = " ";
		the_ph_test = /^[0-9]{3} [0-9]{3} [0-9]{4}$/;
	    phone_num_OK = the_ph_test.test(the_phone_num);
	}
	else if (num_division == 3) {
		the_delim = "";
		the_ph_test = /^[0-9]{10}$/;
	    phone_num_OK = the_ph_test.test(the_phone_num);
	}
	else {
		window.alert("Cannot validate.");
		return false;	
	}
	
    if (phone_num_OK) {
	  return true;	
	}
	else {
	    ph_err_msg="Please enter a valid phone number in the following format:\n123"+the_delim+"456"+the_delim+"7890";
	    window.alert(ph_err_msg);
	    return false;
	}
	
  }
  
}

