lastw = '';
ajax = null;
window.onload = function () {
  $('input').focus();
  Event.observe('input', 'keyup', function(event) { refresh(''); } );
};
function refresh(word) {
  if(word == '')
    word = $F('input');
  if(word != lastw) {
    Element.update('result', '');
    if(ajax)
      ajax.options.onSuccess = function() { void(0); };
    lastw = word;
    if(word) {
      ajax = new Ajax.Request('lookup.php?w='+word, { method:'get', onSuccess: function(transport){
          var response = transport.responseText || '';
            Element.update('result', response);
        } } );
    }
  }
}