var currentSearch = null; function setSelectionColor( element, in_Color ) { element.css("color", in_Color); } function setSearch( searchWord ) { document.getElementById('searchField').value = searchWord; document.search.submit(); } function doSearch( searchWord, searchFormField, searchSuggstionBox ) { if( currentSearch != searchWord ) return; $.get("/scripts/searchSuggestions.php", { searchWord: searchWord }, function( result ) { if( currentSearch != searchWord ) return; currentSearch = ""; if( $( searchFormField ).val() == searchWord ) { data = jQuery.parseJSON( result ); currentHtml = ""; if( data["sl"].length > 0 ) { for( i = 0; i < data["sl"].length; i++ ) { currentHtml += "
" + data["sl"][ i ]["Name"] + "Keyword
"; } } if( data["dl"].length > 0 ) { currentHtml += "
Direct link
"; for( i = 0; i < data["dl"].length; i++ ) { currentHtml += "
" + data["dl"][ i ]["Name"] + "" + ( data["dl"][ i ]["Type"] == 6 ? "Product group" : ( data["dl"][ i ]["Type"] == "7" ? "Product" : "Page" ) ) + "
"; } } $( searchSuggstionBox ).html( currentHtml ).show(); return; } } ); } $(window).load( function () { $(".searchSuggestion").hide(); // Search Suggestion Box $(".searchFormField").keyup( function( e ) { if( e.which == 9 || e.which == 40 ) { $(".searchSuggestion").focus(); } else if( $(".searchFormField").val().length <= 1) { $(".searchSuggestion").hide(); } else { currentSearch = $(".searchFormField").val(); setTimeout( function(){ doSearch( $(".searchFormField").val(), ".searchFormField", ".searchSuggestion" ); }, 50 ); } }); $(':input').keypress(function(e){ if(e.which == 13){ ti = $(this).attr('tabindex') + 1; $('input[tabindex='+ti+']').focus(); //try to use________ e.which = 9; return e.which; }else if(e.which == 9){ e.preventDefault(); //or return false; } }); // Suchvorschl´┐Żge verschwinden lassen, wenn woanders geklickt wird. $("html").click(function(){ $(".searchSuggestion").hide(); }); $(".searchSuggestion").click(function(event){ event.stopPropagation(); }); });