function validate_form(the_form) {
  if (the_form.form_name.value == "") {
    alert("Please enter a value for the \"Name\" field.");
    the_form.form_name.focus();
    return false;
  }

  if (the_form.form_email.value == "") {
    alert("Please enter a value for the \"Email Address\" field.");
    the_form.form_email.focus();
    return false;
  }

  if (!is_email(the_form.form_email.value)) {
    alert("Please enter a correct address in the \"Email Address\" field.");
    the_form.form_email.focus();
    return false;
  }

  if (the_form.form_phone.value == "") {
    alert("Please enter a value for the \"Phone Number\" field.");
    the_form.form_phone.focus();
    return false;
  }

  if (the_form.form_phone.value.length < 10) {
    alert("Please enter at least 10 characters in the \"Phone Number\" field.");
    the_form.form_phone.focus();
    return false;
  }

  var check_ok = "0123456789-";
  var check_string = the_form.form_phone.value;
  var all_valid = true;
  var valid_groups = true;
  
  for (i = 0; i < check_string.length; i++) {
    ch = check_string.charAt(i);
    for (j = 0; j < check_ok.length; j++) {
      if (ch == check_ok.charAt(j)) {
        break;
      }
    }  
    if (j == check_ok.length) {
      all_valid = false;
      break;
    }
  }

  if (!all_valid) {
    alert("Please enter only digit characters in the \"Phone Number\" field.");
    the_form.form_phone.focus();
    return false;
  }
  
  return true;
}

function is_email(arg_value) {
  if (arg_value.indexOf(" ") != -1) {
    return false;
  } else if (arg_value.indexOf("@") == -1) {
    return false;
  } else if (arg_value.indexOf("@") == 0) {
    return false;
  } else if (arg_value.indexOf("@") == (arg_value.length-1)) {
    return false;
  }

  // array_string = arg_value.split("@"); (works only in netscape3 and above.)
  var retSize = custom_split(arg_value, "@", "array_string");

  if (array_string[1].indexOf(".") == -1) {
    return false;
  } else if (array_string[1].indexOf(".") == 0) {
    return false;
  } else if (array_string[1].charAt(array_string[1].length-1) == ".") {
    return false;
  }

  return true;
}

function custom_split(string_value, separator, array_name) {
  var n = 0;

  if (separator.length != 0) {
    while (string_value.indexOf(separator) != -1) {
      eval("arr" + n + " = string_value.substring(0, string_value.indexOf(separator));");
      string_value = string_value.substring(string_value.indexOf(separator) + separator.length, string_value.length + 1);
      n++;
    }
    eval("arr" + n + " = string_value;");
    array_size = n + 1;
  } else {
    for (var x = 0; x < string_value.length; x++) {
      eval("arr" + n +" = \"" + string_value.substring(x, x + 1) + "\";");
      n++;
    }
    array_size = n;
  }

  eval(array_name + " = new make_array(array_size);");

  for (var i = 0; i < array_size; i++) {
    eval(array_name + "[" + i + "] = arr" + i + ";");
  }

  return array_size;
}

function make_array(IntarrSize) {
  for (var n = 0; n < IntarrSize; n++)
    this[n] = "";
  return this;
}