// JavaScript Document

function SearchForm_Validator(theForm)
{

  if (theForm.SearchFor.value == "")
  {
    alert("Please enter a value for the \"SearchFor\" field.");
    theForm.SearchFor.focus();
    return (false);
  }

  if (theForm.SearchFor.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"SearchFor\" field.");
    theForm.SearchFor.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789- \t\r\n\f";
  var checkStr = theForm.SearchFor.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit and whitespace characters in the \"SearchFor\" field.");
    theForm.SearchFor.focus();
    return (false);
  }
  return (true);
}
