function trim(s)
{
  while (s.substring(0,1) == ' ')
  {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ')
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function maxLength1(o,m)
{
   o.value = o.value.substr(0,m);
}

function maxLength2(e,o,m)
{
  // ponieważ Gecko zdarzenie onkeypress występuje
  // także po naciśnięciu klawiszy nie alfanumerycznych 
  // (event.keyCode!=0), naciśnięcia takiego klawisza 
  // nie jest anulowane
  if(!o.all&&e.keyCode!=0)return!0;
  // anulowanie lub nie w zależności od liczby znaków
  // z jednoczesnym odświerzeniem pola wyświetlającego 
  // liczbę znaków
  return (o.value.length)<m
}

function maxLength3(o,m)
{
   if (o.value.length > m) o.value = o.value.substr(0,m);
}
