Array.prototype.index=function(a){for(var b=0,h=this.length;b0&&e<=5&&v.fadeTo("fast",0.5).fadeTo("fast",1)},u=function(e){if(e.isEmpty())return"none";if(e.total>h&&e.allocations.length>1)return"support";return"ok"};this.insert=function(e){i.val(e);i.select()};this.fullResultsCallback=function(e){var c=u(e);x.attr("class",c);m.hide();f.hide();n.fadeTo(166,1);c=e.total;v.text(c);o(c);if(e.isEmpty()){w.empty();f.show()}else if(e.total> h&&e.allocations.length>1){j&&p(e);m.show(e)}else{p(e);k&&m.show(e)}};this.liveResultsCallback=function(e){var c=u(e);x.attr("class",c);e=e.total;v.text(e);o(e)};this.allocationChosen=function(e){e=e.data.query;a.insert(e);a.allocationChosen(e)};this.addinationClicked=function(e){a.addinationClicked(d(),e)};(function(){i.keyup(function(e){if(d()==""){g();a.searchTextCleared()}else n.fadeTo(166,1);a.searchTextEntered(d(),e)});v.click(function(){a.searchButtonClicked(d())});s.click(function(){a.searchButtonClicked(d())}); n.click(function(){g();a.clearButtonClicked();i.focus()})})();i.focus()};var PickyBackend=function(a){var b=function(h,j,k){var i=k||{};i=$.extend({query:h},k);$.getJSON(a,i,function(n){j&&j(new PickyData(n))})};this.search=function(h,j,k,i){b(h,function(n){j&&j(i,n)},k)}},LiveBackend=function(a){var b=a.live||alert("A live backend path must be provided."),h=new PickyBackend(b);this.search=function(j,k,i,n){n=n||{};var s=new Date;n.live=s;i=$.extend({ids:a.liveResults||0,offset:0},i);h.search(j,function(v,x){if(!v.live||v.live==s)k&&k(x,j)},i,n)}},FullBackend=function(a){var b= a.full||alert("A full backend path must be provided."),h=new PickyBackend(b);this.search=function(j,k,i,n){n=n||{};var s=new Date;n.full=s;i=$.extend({ids:a.fullResults||20,offset:0},i);h.search(j,function(v,x){if(!v.full||v.full==s)k&&k(x,j)},i,n)}};var PickyController=function(a){var b=new PickyView(this,a),h=a.backends,j=a.beforeInsert||function(c){return c},k=a.beforeParams||function(c){return c},i=a.before||function(c){return c},n=a.success||function(c){return c},s=a.after||function(c){return c},v=a.searchOnEmpty||false,x=a.liveRendered||false,A=a.liveSearchInterval||180,w,f=function(c){return(c=c&&c.match(/q=([^&]+)/))&&decodeURIComponent(c[1].replace(/\+/g," "))||""};this.extractQuery=f;var l=function(){var c=window.History&&window.History.getState(); return f(c&&c.url)};this.lastFullQuery=l;var m=function(c,r,B,y){if(!v&&r=="")b.reset();else{y=k(y);var z=i(r,y);if(z!=undefined)r=z;w=[c,r,B,y];z=r;if(z!=l()){z=!v&&z==""?"/":"?q="+encodeURIComponent(z);window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}(c=h[c])&&c.search(r,B,y)}};this.resend=function(){w&&m.apply(this,w)};var q=function(c,r){(c=n(c,r))&&b.fullResultsCallback(c);s(c,r)},g=function(c,r){clearInterval(p);m("full",c,q,r||{})}; a=function(c,r){(c=n(c,r))&&b.liveResultsCallback(c);s(c,r)};var d=x?q:a,p,o=function(){var c=b.text();m("live",c,d,{});clearInterval(p)};p=setInterval(o,A);clearInterval(p);var u=function(c,r,B){var y=j(c);if(y!=undefined)c=y;b.insert(c);B&&g(c,r)};this.insert=u;this.clearButtonClicked=function(){clearInterval(p)};this.searchTextCleared=function(){clearInterval(p)};var e=[1,2,3,4,5,6,7,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];this.searchTextEntered=function(c,r){if($.inArray(r.keyCode, e)<0)if(r.keyCode==13)g(c);else{clearInterval(p);p=setInterval(o,A)}};this.searchButtonClicked=function(c){g(c)};this.allocationChosen=function(c){g(c)};this.addinationClicked=function(c,r){g(c,{offset:r.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var c=window.History.getState();c=f(c.url);c!=undefined&&c!=(w&&w.length>1&&w[1])&&u(c,{},true)})};var PickyI18n={},PickyClient=function(a){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en";a.locale=a.locale||PickyI18n.locale;a.qualifiers=a.qualifiers||{};a.explanations=a.explanations||{};a.choices=a.choices||{};var b=a.backends;if(b){b.live||alert("Both a full and live backend must be provided.");b.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};b=a.enclosingSelector||".picky";var h=a.formSelector||b+" form"; a.form=$(h);a.input=$(a.inputSelector||h+" input[type=search]");a.reset=$(a.resetSelector||h+" div.reset");a.button=$(a.buttonSelector||h+" input[type=button]");a.counter=$(a.counterSelector||h+" div.status");a.results=$(a.resultsSelector||b+" div.results");a.noResults=$(a.noResultsSelector||b+" div.no_results");a.moreSelector=a.moreSelector||b+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||b+" .allocations");a.shownAllocations=$(a.shownAllocations||a.allocations.find(".shown")); a.showMoreAllocations=$(a.showMoreAllocations||a.allocations.find(".more"));a.hiddenAllocations=$(a.hiddenAllocations||a.allocations.find(".hidden"));a.maxSuggestions=a.maxSuggestions||3;a.results=$(a.resultsSelector||b+" div.results");a.resultsDivider=a.resultsDivider||"";a.nonPartial=a.nonPartial||[];a.wrapResults=a.wrapResults||"
    ";var j=a.controller&&new a.controller(a)||new PickyController(a);var k=this.insert=function(i,n,s){j.insert(i,n||{},s||true)};this.resend=j.resend;this.insertFromURL= function(i){if(i)k(i);else(i=j.lastFullQuery())&&k(i)}};var PickyAddination=function(a,b){this.remove=function(){b.find(".addination").remove()};this.render=function(h){var j=h.total,k,i=h.renderedAmount();k=h.offset+i;i=k+i;h=h.total;if(h"+t("results.addination.more")+"");j.bind("click",{offset:k.offset},a.addinationClicked);return j}else return""}};var PickyResultsRenderer=function(a,b){var h=b.locale,j=b.explanations||{},k=b.explanationDelimiter||{ch:"und",de:"und",en:"and",fr:"et",it:"e"},i=b.explanationTokenDelimiter||{},n=b.explanationTokenCallback,s=b.resultsDivider,v=b.wrapResults,x=b.nonPartial,A=function(g){var d=g[g.length-1];if(d===undefined)return[];g=g.slice(0,g.length-1);if(g==[])g=[g];if(!x.include(d[0]))if(d[1].match(/[^\*~]$/))d[1]+="*";g.push(d);return g};this.asteriskifyLastToken=A;var w=function(g){for(var d=j[h]||{},p=[], o,u=0,e=g.length;u"+g+"",d].join(" ")};this.strongify=f;var l=function(g,d,p){var o=n&&n(g,p);return o?o:f(d,p.join((i[h]||{})[g]||" "))},m=function(g,d){var p=k[h]||"&",o="",u=[],e=[];w(A(d)).each(function(c,r){var B=r[0],y=r[1],z=r[2];z=z.replace(/[\w,]+:(.+)/,"$1");if(o==""||B==o){u.push(z);o=B;lastExplainedCategory=y}else{var C=l(o,lastExplainedCategory,u);u=[];u.push(z); o=B;lastExplainedCategory=y;e.push(C)}});e.push(l(o,lastExplainedCategory,u));e=e.join(" "+p+" ");return e=''+g+" "+e+""};this.explain=m;var q=function(g,d){var p='
    ';p+=m(d.type,d.combination);if(g.offset>0)p+='';p+="
    ";return p};this.renderHeader=q;this.render=function(g,d){d.allocations.each(function(p,o){if(o.entries.length>0){g.append(q(d, o)).append(o.entries.join(s));g.children("li").wrapAll(v)}});g.append(a.render(d))}};function AllocationRenderer(a){function b(f){var l={},m={},q={},g=[],d,p;d=0;for(p=f.length;d=0;d--)f.remove(g[d]);return f}function h(f){f.map(function(l){return"%"+(l+1)+"$s"});return f.join(" ")}function j(f){if(f.length==0)return"";f=b(f);for(var l=[],m=0,q=f.length;m=0;f--){e=l[f];if(e.length>0)break}e=e[e.length-1];w.include(e[0])||(e[1]=e[1].valueOf()+"*");return l}function i(f){var l=[];k(f).each(function(m,q){var g=j(q);g&&l.push(g)});return l.join(" ")}var n=a.locale,s=a.qualifiers&&a.qualifiers[n]|| {},v=a.explanations&&a.explanations[n]||{},x=a.groups||[],A=a.choices&&a.choices[n]||{},w=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=b;this.makeUpMissingFormat=h;this.rendered=j;this.groupify=k;this.querify=function(f){var l=[],m,q,g;for(g in f){m=f[g][0];m=s[m]||m;q=(q=f[g][1])||"";q=q.charAt(q.length-1)=="*"?"*":"";l[g]=m+":"+f[g][2]+q}return l.join(" ")};this.suggestify=i;this.render=function(f){return i(f.combination)}};var PickyAllocationsCloud=function(a,b){var h=b.allocations,j=b.shownAllocations,k=b.showMoreAllocations,i=b.hiddenAllocations,n=b.maxSuggestions,s=function(){h.hide()},v=function(f){s();a.allocationChosen(f)},x=new AllocationRenderer(b),A=function(f){var l=[];f.each(function(m,q){var g=x.querify(q.combination),d=x.render(q);d=$('
  1. '+d+'
    '+q.count+"
  2. ");d.bind("click",{query:g},v);l.push(d)});return l},w=function(f){if(f.length==0)return h.hide(); j.empty();k.hide();i.empty().hide();if(f.length>n){$.each(f.slice(0,n-1),function(l,m){j.append(m)});$.each(f.slice(n-1),function(l,m){i.append(m)});k.show()}else $.each(f,function(l,m){j.append(m)});return h.show()};k.click(function(){k.hide();i.show()});this.hide=s;this.show=function(f){w(A(f.allocations));h.show()}};