Array.prototype.index=function(a){for(var i=0,j=this.length;i0&&h<=5&&o.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(h){if(h.isEmpty())return"none";if(h.total>j&&h.allocations.length>1)return"support";return"ok"},v=function(h){q.attr("class","dashboard "+h)};this.insert=function(h){b.val(h);b.select()};this.fullResultsCallback=function(h){v(w(h));if(h.isEmpty()){g();s(0);p.show();c()}else if(h.total>j&&h.allocations.length>1){g();c();d.show(h);s(h.total)}else if(h.offset==0){g();s(h.total);f.render(h);u.show();c(); b.focus()}else{m.remove();f.render(h);$("body").animate({scrollTop:$("#picky div.results div.header:last").position().top-12},500)}};this.liveResultsCallback=function(h){v(w(h));s(h.total)};this.allocationChosen=function(h){h=h.data.query;b.val(h);a.allocationChosen(h)};this.addinationClicked=function(h){a.addinationClicked(r(),h)};(function(){b.keyup(function(h){if(r()==""){k();a.searchTextCleared()}else{a.searchTextEntered(r(),h);c()}});o.click(function(){r()==""||a.searchButtonClicked(r())});n.click(function(){r()== ""||a.searchButtonClicked(r())});e.click(function(){k("");a.clearButtonClicked();b.focus()})})();b.focus()};var PickyBackend=function(a){var i=function(j,b,e,n){var o=n||{};o=$.extend({query:j,offset:e},n);$.getJSON(a,o,function(q){b&&b(new PickyData(q))})};this.search=function(j,b,e,n,o){i(j,function(q){b&&b(o,q)},e,n)}},LiveBackend=function(a){var i=new PickyBackend(a);this.search=function(j,b,e,n,o){o=o||{};latestRequestTimestamp=new Date;o.live=latestRequestTimestamp;i.search(j,function(q,u){if(!q.live||q.live==latestRequestTimestamp)b&&b(u)},e,n,o)}},FullBackend=function(a){var i=new PickyBackend(a); this.search=function(j,b,e,n,o){o=o||{};latestRequestTimestamp=new Date;o.full=latestRequestTimestamp;i.search(j,function(q,u){if(!q.full||q.full==latestRequestTimestamp)b&&b(u)},e,n,o)}};var PickyController=function(a){var i=new PickyView(this,a),j=a.backends,b=a.before||function(){},e=a.success||function(){},n=a.after||function(){},o=function(d,f){d=e(d,f)||d;i.liveResultsCallback(d);n(d,f)},q,u=function(){var d=i.text();b({});var f=j.live;f&&f.search(d,o,0,void 0);clearInterval(q)};q=setInterval(u,180);clearInterval(q);var p=function(d,f){d=e(d,f)||d;i.fullResultsCallback(d);n(d,f)},m=function(d,f,c){c=c||{};f=f||0;clearInterval(q);$.address&&$.address.parameter("q",d);c=b(c,d, f)||c;var g=j.full;g&&g.search(d,p,f,c)};this.insert=function(d,f){i.insert(d);f&&m(d)};this.clearButtonClicked=function(){clearInterval(q)};this.searchTextCleared=function(){clearInterval(q)};this.searchTextEntered=function(d,f){if($.inArray(f.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(f.keyCode==13)m(d);else{clearInterval(q);q=setInterval(u,180)}};this.searchButtonClicked=function(d){m(d)};this.allocationChosen= function(d){m(d)};this.addinationClicked=function(d,f){m(d,f.data.offset)}};var Localization={location_delimiters:{de:"in",fr:"\u00e0",it:"a",en:"in",ch:"in"},explanation_delimiters:{de:"und",fr:"et",it:"e",en:"and",ch:"und"}},PickyClient=function(a){Localization.qualifiers=a.qualifiers||{};Localization.explanations=a.explanations||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var i=a.backends;if(i){i.live||alert("Both a full and live backend must be provided.");i.full||alert("Both a full and live backend must be provided.")}else a.backends= {live:a.live&&new LiveBackend(a.live)||alert("A live backend path must be provided."),full:a.full&&new FullBackend(a.full)||alert("A live backend path must be provided.")};var j=a.controller&&new a.controller(a)||new PickyController(a);var b=this.insert=function(e,n){j.insert(e,n||true)};this.insertFromURL=function(e){if(e&&e!="")b(e);else $.address&&b($.address.parameter("q"))};$.address&&$.address.externalChange(function(e){(e=e.parameters.q)&&b(e)})};var PickyAddination=function(a,i){this.remove=function(){i.find(".addination").remove()};this.render=function(j){var b=j.total,e;e=j.offset+20+0;var n=e+20;j=j.total;if(j"+t("results.addination.more")+"");b.bind("click",{offset:e.offset},a.addinationClicked);return b}else return""}};var PickyResultsRenderer=function(a,i){var j=i.wrapResults||'
    ',b=["street_number","zipcode"],e=function(p){var m=p[p.length-1];p=p.slice(0,p.length-1);if(p==[])p=[p];if(!b.include(m[0]))if(m[1].match(/[^\*~]$/))m[1]+="*";p.push(m);return p},n=function(p){for(var m=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},d=[],f,c=0,g=p.length;c$1"),m].join(" ")},q=function(p,m){var d=Localization.explanation_delimiters[PickyI18n.locale],f=n(e(m)),c="",g=[];f=$.map(f,function(k){var r=k[0];k=k[1];if(c==""||r==c){g.push(k);c=r}else{var s=o(c,g.join(" "));g=[];g.push(k);c=r;return s}});f.push(o(c,g.join(" ")));f=f.join(" "+d+" ");return''+p+" "+f+""},u=function(p,m){var d='
    ';d+=q(m.type,m.combination);if(p.offset>0)d+=''; return d};this.render=function(p){var m=$("#picky div.results");p.allocations.each(function(d,f){m.append(u(p,f)).append(f.entries.join("")).append(a.render(p));m.children("li").wrapAll(j)})}};function AllocationRenderer(a,i){function j(c){var g={},k={},r=[],s;s=0;for(l=c.length;s=0;s--)c.remove(r[s]);return c}function b(c){return $.map(c,function(g,k){return"%"+(k+1)+"$s"}).join(" ")}function e(c){if(c.length==0)return"";var g=c=j(c);g.sort(function(x,y){return x[0]=0;c--){x=g[c];if(x.length>0)break}x=x[x.length-1];f.include(x[0])||(x[1]+="...");return $.map(g,function(y){return e(y)})}function o(c){var g=[],k,r;for(r in c){k=c[r][0];k=u[k]||k;g[r]=k+":"+c[r][1]}return g.join(" ")}var q=PickyI18n.locale,u=Localization.qualifiers&&Localization.qualifiers[q]||{},p=Localization.explanations&&Localization.explanations[q]||{},m=i.groups||[],d=i.choices||{};this.explanation=this.query=this.text="";var f=["street_number","zipcode"];this.contract= j;this.rendered=e;this.groupify=n;this.querify=o;this.render=function(c){var g=c.combination,k=c.count;c=o(g);g=n(g).join(" ");g=$('
  1. '+g+'
    '+k+"
  2. ");g.bind("click",{query:c},a);return g}};var PickyAllocationsCloud=function(a,i){var j=$("#picky .allocations"),b=j.find(".shown"),e=j.find(".more"),n=j.find(".hidden"),o=function(){j.hide()},q=new AllocationRenderer(function(m){o();a.allocationChosen(m)},i),u=function(m){var d=[];m.each(function(f,c){d.push(q.render(c))});return d},p=function(m){if(m.length==0)return $("#search .allocations").hide();b.empty();e.hide();n.empty().hide();if(m.length>3){$.each(m.slice(0,2),function(d,f){b.append(f)});$.each(m.slice(2),function(d,f){n.append(f)}); e.show()}else $.each(m,function(d,f){b.append(f)});return $("#search .allocations").show()};e.click(function(){e.hide();n.show()});this.hide=o;this.show=function(m){p(u(m.allocations));j.show()}};