Array.prototype.index=function(a){for(var b=0,h=this.length;b0&&c<=5&&u.fadeTo("fast",0.5).fadeTo("fast",1)},e=function(c){if(c.isEmpty())return"none";if(c.total>h&&c.allocations.length>1)return"support";return"ok"};this.insert=function(c){g.val(c);g.select()};this.fullResultsCallback=function(c){var s=e(c);v.attr("class",s);m.hide();f.hide();n.fadeTo(166,1);s=c.total;u.text(s);o(s);if(c.isEmpty()){x.empty();f.show()}else if(c.total> h&&c.allocations.length>1){j&&q(c);m.show(c)}else{q(c);k&&m.show(c)}};this.liveResultsCallback=function(c){var s=e(c);v.attr("class",s);c=c.total;u.text(c);o(c)};this.allocationChosen=function(c){c=c.data.query;a.insert(c);a.allocationChosen(c)};this.addinationClicked=function(c){a.addinationClicked(d(),c)};(function(){g.keyup(function(c){if(d()==""){i();a.searchTextCleared()}else n.fadeTo(166,1);a.searchTextEntered(d(),c)});u.click(function(){a.searchButtonClicked(d())});r.click(function(){a.searchButtonClicked(d())}); n.click(function(){i();a.clearButtonClicked();g.focus()})})();g.focus()};var PickyBackend=function(a){var b=function(h,j,k){var g=k||{};g=$.extend({query:h},k);$.getJSON(a,g,function(n){j&&j(new PickyData(n))})};this.search=function(h,j,k,g){b(h,function(n){j&&j(g,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,g,n){n=n||{};var r=new Date;n.live=r;g=$.extend({ids:a.liveResults||0,offset:0},g);h.search(j,function(u,v){if(!u.live||u.live==r)k&&k(v,j)},g,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,g,n){n=n||{};var r=new Date;n.full=r;g=$.extend({ids:a.fullResults||20,offset:0},g);h.search(j,function(u,v){if(!u.full||u.full==r)k&&k(v,j)},g,n)}};var PickyController=function(a){var b=new PickyView(this,a),h=a.backends,j=a.beforeInsert||function(e){return e},k=a.before||function(e){return e},g=a.success||function(e){return e},n=a.after||function(e){return e},r=a.searchOnEmpty||false,u=a.liveRendered||false,v=a.liveSearchInterval||180,w,x=function(e){return(e=e&&e.match(/q=([^&]+)/))&&decodeURIComponent(e[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=x;var f=function(){var e=window.History&&window.History.getState();return x(e&& e.url)};this.lastFullQuery=f;var l=function(e,c,s,y){var z=k(c,y);if(z!=undefined)c=z;w=[e,c,s,y];z=c;if(z!=f()){z=!r&&z==""?"/":"?q="+escape(z).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}if(!r&&c=="")b.reset();else(e=h[e])&&e.search(c,s,y)};this.resend=function(){w&&l.apply(this,w)};var m=function(e,c){(e=g(e,c))&&b.fullResultsCallback(e);n(e,c)},p=function(e,c){clearInterval(d);l("full",e,m,c||{})};a=function(e, c){(e=g(e,c))&&b.liveResultsCallback(e);n(e,c)};var i=u?m:a,d,q=function(){var e=b.text();l("live",e,i,{});clearInterval(d)};d=setInterval(q,v);clearInterval(d);var o=function(e,c,s){var y=j(e);if(y!=undefined)e=y;b.insert(e);s&&p(e,c)};this.insert=o;this.clearButtonClicked=function(){clearInterval(d)};this.searchTextCleared=function(){clearInterval(d)};this.searchTextEntered=function(e,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(e);else{clearInterval(d);d=setInterval(q,v)}};this.searchButtonClicked=function(e){p(e)};this.allocationChosen=function(e){p(e)};this.addinationClicked=function(e,c){p(e,{offset:c.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var e=window.History.getState();e=x(e.url);e!=undefined&&e!=(w&&w.length>1&&w[1])&&o(e,{},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(g,n,r){j.insert(g,n||{},r||true)};this.resend=j.resend;this.insertFromURL= function(g){if(g)k(g);else(g=j.lastFullQuery())&&k(g)}};var PickyAddination=function(a,b){this.remove=function(){b.find(".addination").remove()};this.render=function(h){var j=h.total,k,g=h.renderedAmount();k=h.offset+g;g=k+g;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"},g=b.explanationTokenDelimiter||{},n=b.explanationTokenCallback,r=b.resultsDivider,u=b.wrapResults,v=b.nonPartial,w=function(i){var d=i[i.length-1];if(d===undefined)return[];i=i.slice(0,i.length-1);if(i==[])i=[i];if(!v.include(d[0]))if(d[1].match(/[^\*~]$/))d[1]+="*";i.push(d);return i};this.asteriskifyLastToken=w;var x=function(i){for(var d=j[h]||{},q=[], o,e=0,c=i.length;e"+i+"",d].join(" ")};this.strongify=f;var l=function(i,d,q){var o=n&&n(i,q);return o?o:f(d,q.join((g[h]||{})[i]||" "))},m=function(i,d){var q=k[h]||"&",o="",e=[],c=[];x(w(d)).each(function(s,y){var z=y[0],A=y[1],B=y[2];B=B.replace(/[\w,]+:(.+)/,"$1");if(o==""||z==o){e.push(B);o=z;lastExplainedCategory=A}else{var C=l(o,lastExplainedCategory,e);e=[];e.push(B); o=z;lastExplainedCategory=A;c.push(C)}});c.push(l(o,lastExplainedCategory,e));c=c.join(" "+q+" ");return c=''+i+" "+c+""};this.explain=m;var p=function(i,d){var q='
    ';q+=m(d.type,d.combination);if(i.offset>0)q+='';q+="
    ";return q};this.renderHeader=p;this.render=function(i,d){d.allocations.each(function(q,o){if(o.entries.length>0){i.append(p(d, o)).append(o.entries.join(r));i.children("li").wrapAll(u)}});i.append(a.render(d))}};function AllocationRenderer(a){function b(f){var l={},m={},p={},i=[],d,q;d=0;for(q=f.length;d=0;d--)f.remove(i[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,p=f.length;m=0;f--){c=l[f];if(c.length>0)break}c=c[c.length-1];x.include(c[0])||(c[1]=c[1].valueOf()+"*");return l}function g(f){var l=[];k(f).each(function(m,p){var i=j(p);i&&l.push(i)});return l.join(" ")}var n=a.locale,r=a.qualifiers&&a.qualifiers[n]|| {},u=a.explanations&&a.explanations[n]||{},v=a.groups||[],w=a.choices&&a.choices[n]||{},x=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,p,i;for(i in f){m=f[i][0];m=r[m]||m;p=(p=f[i][1])||"";p=p.charAt(p.length-1)=="*"?"*":"";l[i]=m+":"+f[i][2]+p}return l.join(" ")};this.suggestify=g;this.render=function(f){return g(f.combination)}};var PickyAllocationsCloud=function(a,b){var h=b.allocations,j=b.shownAllocations,k=b.showMoreAllocations,g=b.hiddenAllocations,n=b.maxSuggestions,r=function(){h.hide()},u=function(f){r();a.allocationChosen(f)},v=new AllocationRenderer(b),w=function(f){var l=[];f.each(function(m,p){var i=v.querify(p.combination),d=v.render(p);d=$('
  1. '+d+'
    '+p.count+"
  2. ");d.bind("click",{query:i},u);l.push(d)});return l},x=function(f){if(f.length==0)return h.hide(); j.empty();k.hide();g.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){g.append(m)});k.show()}else $.each(f,function(l,m){j.append(m)});return h.show()};k.click(function(){k.hide();g.show()});this.hide=r;this.show=function(f){x(w(f.allocations));h.show()}};