// Test du navigateur
var W3CDOM = (document.getElementsByTagName && document.createElement);

// Une variable globale nécessaire pour le délai (pour les débutants, mieux vaut long: 3  sec)
var typeAheadInfo = {last:0,
			                     delay:1000,
							     timeout:null,
			                     reset:function() {
			                     	document.requete.submit();
			                     	}
			                    };

function typeahead() {
   var now = new Date();
   // Create a timer on keypres for automatic submission
   if (typeAheadInfo.last == 0) {
	// update the timestamp
	typeAheadInfo.last = now;
	// create a new timer
	typeAheadInfo.timeout = setTimeout("typeAheadInfo.reset()", typeAheadInfo.delay);
	// exit
        return false;
   }
   // Renew the timer upon another keypress within a delay
   if (now - typeAheadInfo.last < typeAheadInfo.delay) {
	// stop any previous timeout timer
        clearTimeout(typeAheadInfo.timeout);
	// update the timestamp
	typeAheadInfo.last = now;
	// create a new timer
	typeAheadInfo.timeout = setTimeout("typeAheadInfo.reset()", typeAheadInfo.delay);
   }
}
