Array.prototype.index=function(b){for(var e=0,g=this.length;e0&&j<=5&&n.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(j){if(j.isEmpty())return"none";if(j.total>g&&j.allocations.length>1)return"support";return"ok"},v=function(j){r.attr("class","dashboard "+j)};this.insert=function(j){f.val(j);f.select()};this.fullResultsCallback=function(j){v(w(j));if(j.isEmpty()){c();q(0);s.show(); a()}else if(j.total>g&&j.allocations.length>1){c();a();o.show(j);q(j.total)}else if(j.offset==0){c();q(j.total);p.render(j);u.show();a();f.focus()}else{var y=$("#picky div.results div.addination:last").position().top;i.remove();p.render(j);$("body").animate({scrollTop:y-12},500)}};this.liveResultsCallback=function(j){v(w(j));q(j.total)};this.allocationChosen=function(j){j=j.data.query;f.val(j);b.allocationChosen(j)};this.addinationClicked=function(j){b.addinationClicked(m(),j)};(function(){f.keyup(function(j){if(m()== ""){h();b.searchTextCleared()}else{b.searchTextEntered(m(),j);a()}});n.click(function(){m()==""||b.searchButtonClicked(m())});k.click(function(){m()==""||b.searchButtonClicked(m())});d.click(function(){h("");b.clearButtonClicked();f.focus()})})();f.focus()};var PickyBackend=function(b){var e=function(g,f,d){var k=d||{};k=$.extend({query:g},d);$.getJSON(b,k,function(n){f&&f(new PickyData(n))})};this.search=function(g,f,d,k){e(g,function(n){f&&f(k,n)},d)}},LiveBackend=function(b){var e=b.live||alert("A live backend path must be provided."),g=new PickyBackend(e);this.search=function(f,d,k,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;k=$.extend({ids:b.liveResults||0,offset:0},k);g.search(f,function(r,u){if(!r.live||r.live==latestRequestTimestamp)d&& d(u)},k,n)}},FullBackend=function(b){var e=b.full||alert("A full backend path must be provided."),g=new PickyBackend(e);this.search=function(f,d,k,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;k=$.extend({ids:b.fullResults||20,offset:0},k);g.search(f,function(r,u){if(!r.full||r.full==latestRequestTimestamp)d&&d(u)},k,n)}};var PickyController=function(b){var e=new PickyView(this,b),g=b.backends,f=b.before||function(){},d=b.success||function(){},k=b.after||function(){},n=function(a){return(a=a&&a.match(/q=([^&]+)/))&&unescape(a[1]||"")};this.extractQuery=n;var r=function(){var a=window.History&&window.History.getState();return n(a&&a.url)};this.lastQuery=r;var u=function(a,c){a=d(a,c)||a;e.liveResultsCallback(a);k(a,c)},s,i=function(){var a=e.text(),c={};a=f(a,c)||a;var h=g.live;h&&h.search(a,u,c);clearInterval(s)}; s=setInterval(i,180);clearInterval(s);var o=function(a,c){a=d(a,c)||a;e.fullResultsCallback(a);k(a,c)},p=function(a,c){var h=c||{};clearInterval(s);if(a!=r()){var m="?q="+escape(a).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,m)}a=f(a,h)||a;(m=g.full)&&m.search(a,o,h)};this.insert=function(a,c,h){e.insert(a);h&&p(a,c)};this.clearButtonClicked=function(){clearInterval(s)};this.searchTextCleared=function(){clearInterval(s)}; this.searchTextEntered=function(a,c){if($.inArray(c.keyCode,[0,8,13,32,46,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(c.keyCode==13)p(a);else{clearInterval(s);s=setInterval(i,180)}};this.searchButtonClicked=function(a){p(a)};this.allocationChosen=function(a){p(a)};this.addinationClicked=function(a,c){p(a,{offset:c.data.offset})}};var Localization={},PickyClient=function(b){Localization.qualifiers=b.qualifiers||{};Localization.explanations=b.explanations||{};Localization.choices=b.choices||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var e=b.backends;if(e){e.live||alert("Both a full and live backend must be provided.");e.full||alert("Both a full and live backend must be provided.")}else b.backends={live:new LiveBackend(b),full:new FullBackend(b)};var g=b.controller&&new b.controller(b)|| new PickyController(b);var f=this.insert=function(d,k,n){g.insert(d,k||{},n||true)};this.insertFromURL=function(d){if(d&&d!="")f(d);else(d=g.lastQuery())&&f(d)};window.History&&window.History.Adapter.bind(window,"statechange",function(){var d=window.History.getState();(d=g.extractQuery(d.url))&&f(d)})};var PickyAddination=function(b,e){this.remove=function(){e.find(".addination").remove()};this.render=function(g){var f=g.total,d,k=g.renderedAmount();d=g.offset+k;k=d+k;g=g.total;if(g"+t("results.addination.more")+"");f.bind("click",{offset:d.offset},b.addinationClicked);return f}else return""}};var PickyResultsRenderer=function(b,e){var g=$(e.resultsSelector||"#picky div.results"),f=e.wrapResults||'
    ',d=["street_number","zipcode"],k=function(i){var o=i[i.length-1];i=i.slice(0,i.length-1);if(i==[])i=[i];if(!d.include(o[0]))if(o[1].match(/[^\*~]$/))o[1]+="*";i.push(o);return i},n=function(i){for(var o=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},p=[],a,c=0,h=i.length;c$1"),o].join(" ")},u=function(i,o){var p=Localization.explanation_delimiters[PickyI18n.locale],a=n(k(o)),c="",h=[];a=$.map(a,function(m){var q=m[0];m=m[1];if(c==""||q==c){m=m.replace(/[\w,]+:(.+)/,"$1");h.push(m);c=q}else{var w=r(c,h.join(" "));h=[];h.push(m);c=q;return w}});a.push(r(c,h.join(" ")));a=a.join(" "+p+" ");return''+i+" "+a+""},s=function(i,o){var p= '
    ';p+=u(o.type,o.combination);if(i.offset>0)p+='';return p};this.render=function(i){i.allocations.each(function(o,p){if(p.entries.length>0){g.append(s(i,p)).append(p.entries.join(""));g.children("li").wrapAll(f)}});g.append(b.render(i))}};function AllocationRenderer(b,e){function g(a){var c={},h={},m=[],q;q=0;for(l=a.length;q=0;q--)a.remove(m[q]);return a}function f(a){return $.map(a,function(c,h){return"%"+(h+1)+"$s"}).join(" ")}function d(a){if(a.length==0)return"";var c=a=g(a);c.sort(function(x,z){return x[0]=0;a--){x=c[a];if(x.length>0)break}x=x[x.length-1];p.include(x[0])||(x[1]+="...");return $.map(c,function(z){return d(z)})}function n(a){var c=[],h,m;for(m in a){h=a[m][0];h=u[h]||h;c[m]=h+":"+a[m][2]}return c.join(" ")}var r=PickyI18n.locale,u=Localization.qualifiers&&Localization.qualifiers[r]||{},s=Localization.explanations&&Localization.explanations[r]||{},i=e.groups||[],o=Localization.choices&&Localization.choices[r]||{};this.explanation=this.query=this.text="";var p=["street_number", "zipcode"];this.contract=g;this.rendered=d;this.groupify=k;this.querify=n;this.render=function(a){var c=a.combination,h=a.count;a=n(c);c=k(c).join(" ");c=$('
  1. '+c+'
    '+h+"
  2. ");c.bind("click",{query:a},b);return c}};var PickyAllocationsCloud=function(b,e){var g=$(e.allocationsSelector||"#picky .allocations"),f=g.find(".shown"),d=g.find(".more"),k=g.find(".hidden"),n=function(){g.hide()},r=new AllocationRenderer(function(i){n();b.allocationChosen(i)},e),u=function(i){var o=[];i.each(function(p,a){o.push(r.render(a))});return o},s=function(i){if(i.length==0)return $("#search .allocations").hide();f.empty();d.hide();k.empty().hide();if(i.length>3){$.each(i.slice(0,2),function(o,p){f.append(p)});$.each(i.slice(2), function(o,p){k.append(p)});d.show()}else $.each(i,function(o,p){f.append(p)});return $("#search .allocations").show()};d.click(function(){d.hide();k.show()});this.hide=n;this.show=function(i){s(u(i.allocations));g.show()}};