Array.prototype.index=function(a){for(var j=0,i=this.length;j0&&h<=5&&o.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(h){if(h.isEmpty())return"none";if(h.total>i&&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>i&&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 j=function(i,b,e,n){var o=n||{};o=$.extend({query:i,offset:e},n);$.getJSON(a,o,function(q){b&&b(new PickyData(q))})};this.search=function(i,b,e,n,o){j(i,function(q){b&&b(o,q)},e,n)}},LiveBackend=function(a){var j=new PickyBackend(a);this.search=function(i,b,e,n,o){o=o||{};latestRequestTimestamp=new Date;o.live=latestRequestTimestamp;j.search(i,function(q,u){if(!q.live||q.live==latestRequestTimestamp)b&&b(u)},e,n,o)}},FullBackend=function(a){var j=new PickyBackend(a); this.search=function(i,b,e,n,o){o=o||{};latestRequestTimestamp=new Date;o.full=latestRequestTimestamp;j.search(i,function(q,u){if(!q.full||q.full==latestRequestTimestamp)b&&b(u)},e,n,o)}};var PickyController=function(a){var j=new PickyView(this,a),i=a.backends,b=a.before||function(){},e=a.success||function(){},n=a.after||function(){},o=function(d,f){d=e(d,f)||d;j.liveResultsCallback(d);n(d,f)},q,u=function(){var d=j.text();b({});var f=i.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;j.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=i.full;g&&g.search(d,p,f,c)};this.insert=function(d,f){j.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={},PickyClient=function(a){Localization.qualifiers=a.qualifiers||{};Localization.explanations=a.explanations||{};Localization.choices=a.choices||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var j=a.backends;if(j){j.live||alert("Both a full and live backend must be provided.");j.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 i=a.controller&&new a.controller(a)||new PickyController(a);var b=this.insert=function(e,n){i.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,j){this.remove=function(){j.find(".addination").remove()};this.render=function(i){var b=i.total,e;e=i.offset+20+0;var n=e+20;i=i.total;if(i"+t("results.addination.more")+"");b.bind("click",{offset:e.offset},a.addinationClicked);return b}else return""}};var PickyResultsRenderer=function(a,j){var i=j.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(i)})}};function AllocationRenderer(a,j){function i(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=i(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=j.groups||[],d=Localization.choices&&Localization.choices[q]||{};this.explanation=this.query=this.text="";var f=["street_number", "zipcode"];this.contract=i;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,j){var i=$("#picky .allocations"),b=i.find(".shown"),e=i.find(".more"),n=i.find(".hidden"),o=function(){i.hide()},q=new AllocationRenderer(function(m){o();a.allocationChosen(m)},j),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));i.show()}};