var sg24_search={id:false,bufferText:false,bufferTime:100,reseted:[],searchThemeDefault:"",resetInput:function(c){this.bufferText=false;var b=$(c);b.css("color","#000");if($.inArray(c.id,this.reseted)===-1){b.val("");this.reseted.push(c.id)}else if(this.reseted[c.id]===false){b.val("");if(c.id=="search_location"){$("#location_type").val("");$("#location_id").val("");$("#search_location").val("");if(this.themeSuggestionsOrg!==false)this.themeSuggestions=this.themeSuggestionsOrg}else this.resetTheme()}else c.id== "search_location"?$("#location-suggestlist").css("display","block"):$("#type-suggestlist").css("display","block")},locationSuggestions:false,themeSuggestionsOrg:false,themeSuggestions:false,modified:function(c){c=c.id;var b=$.trim($("#"+c).val());if(b!==""&&(b.length>1||b=="*"))setTimeout('sg24_search.compareBuffer("'+c+'","'+b+'");',this.bufferTime)},compareBuffer:function(c,b){var d=$("#"+c).val();if(b==d&&b!=this.bufferText){this.bufferText=b;sg24_search.buildList(c)}},hideList:function(c){c.id== "search_location"?window.setTimeout("$('#location-suggestlist').css('display','none')",1E3):window.setTimeout("$('#type-suggestlist').css('display','none')",1E3)},buildList:function(c){if(this.locationSuggestions!==false&&this.themeSuggestions!==false){var b=$.trim($("#"+c).val()).toLowerCase(),d=0,f=b=="*";if(c=="search_location"){var e=$("#location-suggestlist");e.html("").css("display","block");$.each(this.locationSuggestions.countries,function(g,a){if(f||$("<div/>").html(a.t.toLowerCase()).text().indexOf(b)!== -1){e.append("<div onclick=\"sg24_search.selectLocationSuggestion('countries','"+a.id+"','"+a.t+'\');" class="za'+d%2+'">'+a.t+" (Land)</div>");d++}});$.each(this.locationSuggestions.federalStates,function(g,a){if(f||$("<div/>").html(a.t.toLowerCase()).text().indexOf(b)!==-1){e.append("<div onclick=\"sg24_search.selectLocationSuggestion('federalStates','"+a.id+"','"+a.t+'\');" class="za'+d%2+'">'+a.t+" (Bundesland)</div>");d++}});$.each(this.locationSuggestions.regions,function(g,a){if(f||$("<div/>").html(a.t.toLowerCase()).text().indexOf(b)!== -1){e.append("<div onclick=\"sg24_search.selectLocationSuggestion('regions','"+a.id+"','"+a.t+'\');" class="za'+d%2+'">'+a.t+" (Region)</div>");d++}});$.each(this.locationSuggestions.cities,function(g,a){if(f||$("<div/>").html(a.t.toLowerCase()).text().indexOf(b)!==-1){e.append("<div onclick=\"sg24_search.selectLocationSuggestion('cities','"+a.id+"','"+a.t+'\');" class="za'+d%2+'">'+a.t+" (Stadt/Ort)</div>");d++}})}else{e=$("#type-suggestlist");e.html("").css("display","block");var h=[];$.each(sg24_search.themeSuggestions.offer, function(g,a){if(f||$("<div/>").html(a.t.toLowerCase()).text().indexOf(b)!==-1||$("<div/>").html(a.pt.toLowerCase()).text().indexOf(b)!==-1){if($.inArray(a.pid,h)===-1){h.push(a.pid);e.append("<div onclick=\"sg24_search.selectThemeSuggestion('t0','"+a.pid+"','"+a.pt+'\');" class="za'+d%2+'"><strong>'+a.pt+"</strong></div>");d++}e.append("<div onclick=\"sg24_search.selectThemeSuggestion('t1','"+a.id+"','"+a.t+'\');" class="za'+d%2+'">&nbsp;&nbsp;&nbsp;&nbsp;'+a.t+"</div>");d++}});h=[];$.each(sg24_search.themeSuggestions.provider, function(g,a){if(f||$("<div/>").html(a.t.toLowerCase()).text().indexOf(b)!==-1||$("<div/>").html(a.pc.toLowerCase()).text().indexOf(b)!==-1){if($.inArray(a.pt,h)===-1){h.push(a.pt);e.append("<div onclick=\"sg24_search.selectThemeSuggestion('c0','"+a.pt+"|0','"+a.pc+'\');" class="za'+d%2+'"><strong>'+a.pc+" (Anbietereintr\u00e4ge)</strong></div>");d++}e.append("<div onclick=\"sg24_search.selectThemeSuggestion('c1','"+a.pt+"|"+a.id+"','"+a.t+'\');" class="za'+d%2+'">&nbsp;&nbsp;&nbsp;&nbsp;'+a.t+"</div>"); d++}})}}},selectLocationSuggestion:function(c,b,d){$("#start-search-box-submit").focus();this.reseted.search_location=false;$("#location_type").val(c);$("#location_id").val(b);$("#search_location").val(d);this.resetTheme();this.themeSuggestionsOrg=this.themeSuggestions;$.getJSON("/lib/ajax.php",{ajaxAction:"getThemeSuggestJSON",location_type:c,location_id:b,location_title:d},function(f){sg24_search.themeSuggestions=f})},selectThemeSuggestion:function(c,b,d){$("#start-search-box-submit").focus();this.reseted.search_theme= false;$("#search_theme").val(d);$("#theme_id").val(b);$("#theme_type").val(c);document.getElementById("start-search-box-submit").click()},resetTheme:function(){$.inArray("search_theme",this.reseted)!==-1&&$("#search_theme").val("");$("#theme_id").val("");$("#theme_type").val("")}};
