var substringMatcher=function(s){return function(e,t){var r;r=[],substrRegex=new RegExp(e,"i"),$.each(s,function(s,e){substrRegex.test(e)&&(address_format=$("#address").val().toLowerCase(),str_format=e.toLowerCase(),match_place=str_format.indexOf(address_format),third_char=parseInt(address_format.substr(2,1).trim()),1==isNaN(third_char)?0==match_place&&r.push(e):match_place>=8&&r.push(e))}),t(r)}}; $("#address").typeahead({hint:!0,highlight:!0,minLength:4,limit:2},{name:"street-search",source:substringMatcher(data)}),$("#address").change(function(s){ setTimeout(function(){$("#address_results").load("/site/custom_scripts/mynearest/set/results.php",{validcheck:!0,address:$("#address").val(),rdm:Math.random()},function(){$("#address_results title").remove(),0==$("#address_results").text().includes("we could not identify your address")&&($(".lookup_container").hide(),$("#address_results").prepend("Cancel search"))}).show()},200)}),$("#address_button").click(function(){$("#address").change()}),$("#address").focus(); function address_set() { $("#address_set").css("display", "block"); $("#address_view").css("display", "none"); setTimeout(function() { $("#address").focus(); }, 250); } setTimeout(function() { $("#address").focus(); }, 250); $("#address_set").css("display", "block"); $("#address_view").css("display", "none");