function trimSearch ( inputStringTrim ) {
  fixedTrim = "";
  lastCh = " ";
  for (x=0; x < inputStringTrim.length; x++) {
    ch = inputStringTrim.charAt(x);
    if ((ch != " ") || (lastCh != " ")) {
     fixedTrim += ch;
    }
  lastCh = ch;
  }
  if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {
    fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1);
  }
  return fixedTrim;
}


function ValidateSearch(theForm)
{

  if (trimSearch(theForm.Criteria.value) == "")
  {
    alert("Please enter a value for the \"Search Criteria\" field.");
    theForm.Criteria.focus();
    return (false);
  }

  if (trimSearch(theForm.Criteria.value).length < 3)
  {
    alert("Please enter at least 3 characters in the \"Search Criteria\" field.");
    theForm.Criteria.focus();
    return (false);
  }

  if (trimSearch(theForm.Criteria.value).length > 25)
  {
    alert("Please enter at most 25 characters in the \"Search Criteria\" field.");
    theForm.Criteria.focus();
    return (false);
  }
  return (true);
}

