var timer1;
var timer2;
var old_length=0;

function getPremenu() {
		req = new Request({
             method: 'get',
             url: '/ajax/pre-menu-resultat.php?search_mode=AND&match_osc_products_name%2Cproducts_description_osc_main='+($('match_osc_products_name,products_description').value),
             data: { 'do' : '1' },
             onComplete: function(response) { $('divID').set('html', response);  }
         }).send();
     }
	 
function getData() {
         var req = new Request({
             method: 'get',
             url: '/ajax/ajax-results.php?search_mode=AND&match_osc_products_name%2Cproducts_description_osc_main='+($('match_osc_products_name,products_description').value),
             data: { 'do' : '1' },
			 onRequest: function() { 
			 	$('blocResultatFormSearch').set('html', '<img src=/images/interface/loading.gif>');
			  },
             onComplete: function(response) { 
			 	$('blocResultatFormSearch').set('html', response);	 
		   }
         }).send();
     }

function ehandler(type){
 clearTimeout(timer1);
 clearTimeout(timer2);
 if ($('match_osc_products_name,products_description').value.length>1 && $('match_osc_products_name,products_description').value.length!=old_length && $('match_osc_products_name,products_description').value!='Tapez votre recherche ici') {

timer1=setTimeout(getPremenu,500);
if (type=='full') timer2=setTimeout(getData,500);
 old_length = $('match_osc_products_name,products_description').value.length;
 }
 return true;
}

window.addEvent('domready', function() {
/*
	$('match_osc_products_name,products_description').addEvent('keydown', function() {
	ehandler('full');
	});
	ehandler('');*/
});

