jQuery(document).ready(function(a){var e=a("#SearchForm form"),i=e[0],d=a("#SearchForm .submit input"),b=a("#CompanyKeyword"),f=a("#ShortKeywordMessage");keywordCache={};isSubmit=!1;d.attr("disabled",!0);a.getJSON("/search/getKeywords/",{"short":null},function(g){a.each(g,function(a,c){keywordCache[c]=g});d.attr("disabled",!1)});f.dialog({autoOpen:!1,height:130,width:360,resizable:!1,modal:!0,show:"fade",buttons:{OK:function(){a(this).dialog("close")}}});e.submit(function(){var a=b.val().replace(/%/g,
" ").replace(/\bs\.a\.?/i,"").replace(/^ +/,"").replace(/ +$/,"");if(isSubmit)return!1;b.val(a);if(3>a.length&&!(a in keywordCache))return f.dialog("open"),!1;d.attr("disabled",!0);return isSubmit=!0});b.autocomplete({source:function(g,b){var c=g.term.replace(/^ +/,"").replace(/ +$/,"");if(""==c)return!1;if(c in keywordCache)b(keywordCache[c]);else{for(var e=c.length,d=e,h=c,f=[];0<--d;)if(h=c.substring(0,d),h in keywordCache){a.each(keywordCache[h],function(a,b){b.substring(0,e)==c&&f.push(b)});
b(f);return}a.getJSON("/search/getKeywords/",g,function(a){keywordCache[c]=a;b(keywordCache[c])})}},select:function(a,d){b.val(d.item.value);e.submit();i.submit()}});b.focus()});

