function activateSearch() {
  if( $('searchform') ) {
    $('searchform').onsubmit = function() {
      doSearch();
      return false;
    };
    anim = new Fx.Style( 'search-results', 'height', {duration: 400} );
    anim.hide();
    new Form.Element.Observer( 's', 1, doSearch );
    is_searching = false;
  }
}

function doSearch() {
  // If search is in progress, do nothing
  if( is_searching ) return false;
//  s = decodeURIComponent( $F('s') );
  s = $F('s');
  anim.hide();
  // If search input is empty..
  if( s == '') return false;
  is_searching = true;
  //Element.show( $('wait') );
  // Setup the parameters and make the ajax call
//  pars = encodeURIComponent( Form.serialize('searchform') );
  pars = Form.serialize('searchform');
  var myAjax = new Ajax.Request( 'http://www.frontscheibe.de/livesearch.php', {method: 'get', parameters: pars, onComplete:doSearchResponse} );
}

function doSearchResponse( response ) {
  $('search-results').innerHTML = response.responseText;
  anim.toggle();
  //Element.hide( $('wait') );
  is_searching = false;
}

Event.observe( window, 'load', activateSearch, false );
