var RegisterWord; function RegisterWords(words,resultat){ clearTimeout(RegisterWord); if(words==$("#SearchForm").val()){ $.post("/sniffer_search.php",{words: words,resultat:resultat}, function(){ return true; }); } } function selectItem(li) { if (li.extra) { if(li.extra[0]=="Affiche Resultat"||li.extra[0]=="NombreTotal"){ if(li.extra[0]=="Affiche Resultat"&&li.extra[1]=="0") { return false; }else{ var v = $("#SearchForm").val(); RegisterWords(v,1); setTimeout( function(){ document.location.href = "/recherche/"+escape(v)+"/1"; }, 100 ); } }else{ var v = li.extra[2]; var v2 = $("#SearchForm").val(); var Ref = li.extra[6]; var Rewrite = li.extra[9]; var CatID = li.extra[8]; var ArtID = li.extra[7]; RegisterWords(v2,1); setTimeout( function(){ document.location.href = "/vins-"+Rewrite+"-Rech|"+CatID+"|"+escape($("#SearchForm").val())+"-"+ArtID+"/"; }, 100 ); } } } function formatItem(row) { if(row[0]=="Affiche Resultat"){ if(row[1]=="0"){ var v = $("#SearchForm").val(); if( v.length >= 5 ) { RegisterWord = setTimeout( function(){ RegisterWords(v,0); }, 800 ); } return " Résultats : Aucun produit"; }else return " Résultats : "+row[1]+" produits correspondants"; }else if(row[0]=="NombreTotal") { return " Voir tous les résultats ("+row[1]+") >"; }else { var m=""; m+="
"; m+="
"; if(row[3]!="") m+=""+row[1]+" - "+row[0]+""; else m+=" "; m+="
"; m+="
"; m+=""+row[0] + "
"; //if(row[1]!="") m+="" + row[1] + "
"; if(row[11]!="") m+="" + row[11] + "
"; if(row[12]!="") m += row[12]+" - "; if(row[10]!="") m+="" + row[10] +"
"; m+="

"+row[4]+" €"+"

"; m+="
 

"; m+="
"; return m; } } $(document).ready(function() { $("#SearchForm").autocomplete("search.php", { minChars:3, matchSubset:0, matchContains:0, cacheLength:0, onItemSelect:selectItem, formatItem:formatItem, selectOnly:1 }); });