(function(a){if(typeof a.fn.each2=="undefined"){a.fn.extend({each2:function(f){var d=a([0]),e=-1,b=this.length;while(++e=112&&H<=123}};D=j(document);u=(function(){var H=1;return function(){return H++}}());function b(J,K){var I=0,H=K.length;for(;I=0){I(K)}})}function r(H){if(H[0]===document.activeElement){return}window.setTimeout(function(){var J=H[0],K=H.val().length,I;H.focus();if(J.setSelectionRange){J.setSelectionRange(K,K)}else{if(J.createTextRange){I=J.createTextRange();I.collapse(true);I.moveEnd("character",K);I.moveStart("character",K);I.select()}}},0)}function d(H){H.preventDefault();H.stopPropagation()}function F(H){H.preventDefault();H.stopImmediatePropagation()}function z(I){if(!a){var H=I[0].currentStyle||window.getComputedStyle(I[0],null);a=j(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:H.fontSize,fontFamily:H.fontFamily,fontStyle:H.fontStyle,fontWeight:H.fontWeight,letterSpacing:H.letterSpacing,textTransform:H.textTransform,whiteSpace:"nowrap"});a.attr("class","select2-sizer");j("body").append(a)}a.text(I.val());return a.width()}function y(I,M,H){var K,L=[],J;K=I.attr("class");if(typeof K==="string"){j(K.split(" ")).each2(function(){if(this.indexOf("select2-")===0){L.push(this)}})}K=M.attr("class");if(typeof K==="string"){j(K.split(" ")).each2(function(){if(this.indexOf("select2-")!==0){J=H(this);if(typeof J==="string"&&J.length>0){L.push(this)}}})}I.attr("class",L.join(" "))}function i(M,L,J,H){var K=M.toUpperCase().indexOf(L.toUpperCase()),I=L.length;if(K<0){J.push(H(M));return}J.push(H(M.substring(0,K)));J.push("");J.push(H(M.substring(K,K+I)));J.push("");J.push(H(M.substring(K+I,M.length)))}function p(J){var M,I=0,K=null,N=J.quietMillis||100,L=J.url,H=this;return function(O){window.clearTimeout(M);M=window.setTimeout(function(){I+=1;var Q=I,S=J.data,P=L,U=J.transport||j.ajax,R=J.type||"GET",T={};S=S?S.call(H,O.term,O.page,O.context):null;P=(typeof P==="function")?P.call(H,O.term,O.page,O.context):P;if(null!==K){K.abort()}if(J.params){if(j.isFunction(J.params)){j.extend(T,J.params.call(H))}else{j.extend(T,J.params)}}j.extend(T,{url:P,dataType:J.dataType,data:S,type:R,cache:false,success:function(W){if(Q=0){break}}if(O<0){break}K=P.substring(0,O);P=P.substring(O+M.length);if(K.length>0){K=H.createSearchChoice(K,Q);if(K!==l&&K!==null&&H.id(K)!==l&&H.id(K)!==null){R=false;for(L=0,J=Q.length;L\|])/g,"\\$1");this.container.attr("id",this.containerId);this.body=E(function(){return K.element.closest("body")});y(this.container,this.opts.element,this.opts.adaptContainerCssClass);this.container.css(t(K.containerCss));this.container.addClass(t(K.containerCssClass));this.elementTabIndex=this.opts.element.attr("tabIndex");this.opts.element.data("select2",this).addClass("select2-offscreen").bind("focus.select2",function(){j(this).select2("focus")}).attr("tabIndex","-1").before(this.container);this.container.data("select2",this);this.dropdown=this.container.find(".select2-drop");this.dropdown.addClass(t(K.dropdownCssClass));this.dropdown.data("select2",this);this.results=J=this.container.find(L);this.search=I=this.container.find("input.select2-input");I.attr("tabIndex",this.elementTabIndex);this.resultsPage=0;this.context=null;this.initContainer();v(this.results);this.dropdown.delegate(L,"mousemove-filtered touchstart touchmove touchend",this.bind(this.highlightUnderEvent));f(80,this.results);this.dropdown.delegate(L,"scroll-debounced",this.bind(this.loadMoreIfNeeded));if(j.fn.mousewheel){J.mousewheel(function(Q,R,O,N){var P=J.scrollTop(),M;if(N>0&&P-N<=0){J.scrollTop(0);d(Q)}else{if(N<0&&J.get(0).scrollHeight-J.scrollTop()+N<=J.height()){J.scrollTop(J.get(0).scrollHeight-J.height());d(Q)}}})}B(I);I.bind("keyup-change input paste",this.bind(this.updateResults));I.bind("focus",function(){I.addClass("select2-focused")});I.bind("blur",function(){I.removeClass("select2-focused")});this.dropdown.delegate(L,"mouseup",this.bind(function(M){if(j(M.target).closest(".select2-result-selectable").length>0){this.highlightUnderEvent(M);this.selectHighlighted(M)}}));this.dropdown.bind("click mouseup mousedown",function(M){M.stopPropagation()});if(j.isFunction(this.opts.initSelection)){this.initSelection();this.monitorSource()}if(K.element.is(":disabled")||K.element.is("[readonly='readonly']")){this.disable()}},destroy:function(){var H=this.opts.element.data("select2");if(this.propertyObserver){delete this.propertyObserver;this.propertyObserver=null}if(H!==l){H.container.remove();H.dropdown.remove();H.opts.element.removeClass("select2-offscreen").removeData("select2").unbind(".select2").attr({tabIndex:this.elementTabIndex}).show()}},prepareOpts:function(L){var J,I,H,K;J=L.element;if(J.get(0).tagName.toLowerCase()==="select"){this.select=I=L.element}if(I){j.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in L){throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a ",""].join(""));return H},disable:function(){if(!this.enabled){return}this.parent.disable.apply(this,arguments);this.focusser.attr("disabled","disabled")},enable:function(){if(this.enabled){return}this.parent.enable.apply(this,arguments);this.focusser.removeAttr("disabled")},opening:function(){this.parent.opening.apply(this,arguments);this.focusser.attr("disabled","disabled");this.opts.element.trigger(j.Event("open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments);this.focusser.removeAttr("disabled");r(this.focusser)},focus:function(){if(this.opened()){this.close()}else{this.focusser.removeAttr("disabled");this.focusser.focus()}},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments);this.focusser.removeAttr("disabled");this.focusser.focus()},initContainer:function(){var J,I=this.container,K=this.dropdown,H=false;this.showSearch(this.opts.minimumResultsForSearch>=0);this.selection=J=I.find(".select2-choice");this.focusser=I.find(".select2-focusser");this.search.bind("keydown",this.bind(function(L){if(!this.enabled){return}if(L.which===c.PAGE_UP||L.which===c.PAGE_DOWN){d(L);return}switch(L.which){case c.UP:case c.DOWN:this.moveHighlight((L.which===c.UP)?-1:1);d(L);return;case c.TAB:case c.ENTER:this.selectHighlighted();d(L);return;case c.ESC:this.cancel(L);d(L);return}}));this.focusser.bind("keydown",this.bind(function(L){if(!this.enabled){return}if(L.which===c.TAB||c.isControl(L)||c.isFunctionKey(L)||L.which===c.ESC){return}if(this.opts.openOnEnter===false&&L.which===c.ENTER){d(L);return}if(L.which==c.DOWN||L.which==c.UP||(L.which==c.ENTER&&this.opts.openOnEnter)){this.open();d(L);return}if(L.which==c.DELETE||L.which==c.BACKSPACE){if(this.opts.allowClear){this.clear()}d(L);return}}));B(this.focusser);this.focusser.bind("keyup-change input",this.bind(function(L){if(this.opened()){return}this.open();if(this.showSearchInput!==false){this.search.val(this.focusser.val())}this.focusser.val("");d(L)}));J.delegate("abbr","mousedown",this.bind(function(L){if(!this.enabled){return}this.clear();F(L);this.close();this.selection.focus()}));J.bind("mousedown",this.bind(function(L){H=true;if(this.opened()){this.close()}else{if(this.enabled){this.open()}}d(L);H=false}));K.bind("mousedown",this.bind(function(){this.search.focus()}));J.bind("focus",this.bind(function(L){d(L)}));this.focusser.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")})).bind("blur",this.bind(function(){if(!this.opened()){this.container.removeClass("select2-container-active")}}));this.search.bind("focus",this.bind(function(){this.container.addClass("select2-container-active")}));this.initContainerWidth();this.setPlaceholder()},clear:function(){var H=this.selection.data("select2-data");this.opts.element.val("");this.selection.find("span").empty();this.selection.removeData("select2-data");this.setPlaceholder();this.opts.element.trigger({type:"removed",val:this.id(H),choice:H});this.triggerChange({removed:H})},initSelection:function(){var I;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.close();this.setPlaceholder()}else{var H=this;this.opts.initSelection.call(null,this.opts.element,function(J){if(J!==l&&J!==null){H.updateSelection(J);H.close();H.setPlaceholder()}})}},prepareOpts:function(){var H=this.parent.prepareOpts.apply(this,arguments);if(H.element.get(0).tagName.toLowerCase()==="select"){H.initSelection=function(I,K){var J=I.find(":selected");if(j.isFunction(K)){K({id:J.attr("value"),text:J.text(),element:J})}}}else{if("data" in H){H.initSelection=H.initSelection||function(I,K){var J=I.val();H.query({matcher:function(L,N,M){return q(J,H.id(M))},callback:!j.isFunction(K)?j.noop:function(L){K(L.results.length?L.results[0]:null)}})}}}return H},getPlaceholder:function(){if(this.select){if(this.select.find("option").first().text()!==""){return l}}return this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var H=this.getPlaceholder();if(this.opts.element.val()===""&&H!==l){if(this.select&&this.select.find("option:first").text()!==""){return}this.selection.find("span").html(this.opts.escapeMarkup(H));this.selection.addClass("select2-default");this.selection.find("abbr").hide()}},postprocessResults:function(L,I){var K=0,H=this,M=true;this.findHighlightableChoices().each2(function(N,O){if(q(H.id(O.data("select2-data")),H.opts.element.val())){K=N;return false}});this.highlight(K);if(I===true){var J=this.opts.minimumResultsForSearch;M=J<0?false:h(L.results)>=J;this.showSearch(M)}},showSearch:function(H){this.showSearchInput=H;this.dropdown.find(".select2-search")[H?"removeClass":"addClass"]("select2-search-hidden");j(this.dropdown,this.container)[H?"addClass":"removeClass"]("select2-with-searchbox")},onSelect:function(J,I){var H=this.opts.element.val();this.opts.element.val(this.id(J));this.updateSelection(J);this.opts.element.trigger({type:"selected",val:this.id(J),choice:J});this.close();if(!I||!I.noFocus){this.selection.focus()}if(!q(H,this.id(J))){this.triggerChange()}},updateSelection:function(J){var H=this.selection.find("span"),I;this.selection.data("select2-data",J);H.empty();I=this.opts.formatSelection(J,H);if(I!==l){H.append(this.opts.escapeMarkup(I))}this.selection.removeClass("select2-default");if(this.opts.allowClear&&this.getPlaceholder()!==l){this.selection.find("abbr").show()}},val:function(){var K,I=false,J=null,H=this;if(arguments.length===0){return this.opts.element.val()}K=arguments[0];if(arguments.length>1){I=arguments[1]}if(this.select){this.select.val(K).find(":selected").each2(function(L,M){J={id:M.attr("value"),text:M.text()};return false});this.updateSelection(J);this.setPlaceholder();if(I){this.triggerChange()}}else{if(this.opts.initSelection===l){throw new Error("cannot call val() if initSelection() is not defined")}if(!K&&K!==0){this.clear();if(I){this.triggerChange()}return}this.opts.element.val(K);this.opts.initSelection(this.opts.element,function(L){H.opts.element.val(!L?"":H.id(L));H.updateSelection(L);H.setPlaceholder();if(I){H.triggerChange()}})}},clearSearch:function(){this.search.val("");this.focusser.val("")},data:function(I){var H;if(arguments.length===0){H=this.selection.data("select2-data");if(H==l){H=null}return H}else{if(!I||I===""){this.clear()}else{this.opts.element.val(!I?"":this.id(I));this.updateSelection(I)}}}});G=x(e,{createContainer:function(){var H=j(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["
    ","
  • "," ","
  • ","
",""].join(""));return H},prepareOpts:function(){var H=this.parent.prepareOpts.apply(this,arguments);if(H.element.get(0).tagName.toLowerCase()==="select"){H.initSelection=function(I,K){var J=[];I.find(":selected").each2(function(L,M){J.push({id:M.attr("value"),text:M.text(),element:M[0]})});K(J)}}else{if("data" in H){H.initSelection=H.initSelection||function(I,K){var J=m(I.val(),H.separator);H.query({matcher:function(L,N,M){return j.grep(J,function(O){return q(O,H.id(M))}).length},callback:!j.isFunction(K)?j.noop:function(L){K(L.results)}})}}}return H},initContainer:function(){var H=".select2-choices",I;this.searchContainer=this.container.find(".select2-search-field");this.selection=I=this.container.find(H);this.search.bind("input paste",this.bind(function(){if(!this.enabled){return}if(!this.opened()){this.open()}}));this.search.bind("keydown",this.bind(function(K){if(!this.enabled){return}if(K.which===c.BACKSPACE&&this.search.val()===""){this.close();var L,J=I.find(".select2-search-choice-focus");if(J.length>0){this.unselect(J.first());this.search.width(10);d(K);return}L=I.find(".select2-search-choice:not(.select2-locked)");if(L.length>0){L.last().addClass("select2-search-choice-focus")}}else{I.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")}if(this.opened()){switch(K.which){case c.UP:case c.DOWN:this.moveHighlight((K.which===c.UP)?-1:1);d(K);return;case c.ENTER:case c.TAB:this.selectHighlighted();d(K);return;case c.ESC:this.cancel(K);d(K);return}}if(K.which===c.TAB||c.isControl(K)||c.isFunctionKey(K)||K.which===c.BACKSPACE||K.which===c.ESC){return}if(K.which===c.ENTER){if(this.opts.openOnEnter===false){return}else{if(K.altKey||K.ctrlKey||K.shiftKey||K.metaKey){return}}}this.open();if(K.which===c.PAGE_UP||K.which===c.PAGE_DOWN){d(K)}}));this.search.bind("keyup",this.bind(this.resizeSearch));this.search.bind("blur",this.bind(function(J){this.container.removeClass("select2-container-active");this.search.removeClass("select2-focused");if(!this.opened()){this.clearSearch()}J.stopImmediatePropagation()}));this.container.delegate(H,"mousedown",this.bind(function(J){if(!this.enabled){return}if(j(J.target).closest(".select2-search-choice").length>0){return}this.clearPlaceholder();this.open();this.focusSearch();J.preventDefault()}));this.container.delegate(H,"focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active");this.clearPlaceholder()}));this.initContainerWidth();this.clearSearch()},enable:function(){if(this.enabled){return}this.parent.enable.apply(this,arguments);this.search.removeAttr("disabled")},disable:function(){if(!this.enabled){return}this.parent.disable.apply(this,arguments);this.search.attr("disabled",true)},initSelection:function(){var I;if(this.opts.element.val()===""&&this.opts.element.text()===""){this.updateSelection([]);this.close();this.clearSearch()}if(this.select||this.opts.element.val()!==""){var H=this;this.opts.initSelection.call(null,this.opts.element,function(J){if(J!==l&&J!==null){H.updateSelection(J);H.close();H.clearSearch()}})}},clearSearch:function(){var H=this.getPlaceholder();if(H!==l&&this.getVal().length===0&&this.search.hasClass("select2-focused")===false){this.search.val(H).addClass("select2-default");this.resizeSearch()}else{this.search.val("").width(10)}},clearPlaceholder:function(){if(this.search.hasClass("select2-default")){this.search.val("").removeClass("select2-default")}},opening:function(){this.parent.opening.apply(this,arguments);this.clearPlaceholder();this.resizeSearch();this.focusSearch();this.opts.element.trigger(j.Event("open"))},close:function(){if(!this.opened()){return}this.parent.close.apply(this,arguments)},focus:function(){this.close();this.search.focus();this.opts.element.triggerHandler("focus")},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(K){var J=[],I=[],H=this;j(K).each(function(){if(b(H.id(this),J)<0){J.push(H.id(this));I.push(this)}});K=I;this.selection.find(".select2-search-choice").remove();j(K).each(function(){H.addSelectedChoice(this)});H.postprocessResults()},tokenize:function(){var H=this.search.val();H=this.opts.tokenizer(H,this.data(),this.bind(this.onSelect),this.opts);if(H!=null&&H!=l){this.search.val(H);if(H.length>0){this.open()}}},onSelect:function(I,H){this.addSelectedChoice(I);this.opts.element.trigger({type:"selected",val:this.id(I),choice:I});if(this.select||!this.opts.closeOnSelect){this.postprocessResults()}if(this.opts.closeOnSelect){this.close();this.search.width(10)}else{if(this.countSelectableResults()>0){this.search.width(10);this.resizeSearch();if(this.val().length>=this.getMaximumSelectionSize()){this.updateResults(true)}this.positionDropdown()}else{this.close();this.search.width(10)}}this.triggerChange({added:I});if(!H||!H.noFocus){this.focusSearch()}},cancel:function(){this.close();this.focusSearch()},addSelectedChoice:function(K){var I=!K.locked,O=j("
  • "),N=j("
  • ");var H=I?O:N,M=this.id(K),L=this.getVal(),J;J=this.opts.formatSelection(K,H.find("div"));if(J!=l){H.find("div").replaceWith("
    "+this.opts.escapeMarkup(J)+"
    ")}if(I){H.find(".select2-search-choice-close").bind("mousedown",d).bind("click dblclick",this.bind(function(P){if(!this.enabled){return}j(P.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(j(P.target));this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus");this.close();this.focusSearch()})).dequeue();d(P)})).bind("focus",this.bind(function(){if(!this.enabled){return}this.container.addClass("select2-container-active");this.dropdown.addClass("select2-drop-active")}))}H.data("select2-data",K);H.insertBefore(this.searchContainer);L.push(M);this.setVal(L)},unselect:function(I){var K=this.getVal(),J,H;I=I.closest(".select2-search-choice");if(I.length===0){throw"Invalid argument: "+I+". Must be .select2-search-choice"}J=I.data("select2-data");if(!J){return}H=b(this.id(J),K);if(H>=0){K.splice(H,1);this.setVal(K);if(this.select){this.postprocessResults()}}I.remove();this.opts.element.trigger({type:"removed",val:this.id(J),choice:J});this.triggerChange({removed:J})},postprocessResults:function(){var J=this.getVal(),K=this.results.find(".select2-result"),I=this.results.find(".select2-result-with-children"),H=this;K.each2(function(M,L){var N=H.id(L.data("select2-data"));if(b(N,J)>=0){L.addClass("select2-selected");L.find(".select2-result-selectable").addClass("select2-selected")}});I.each2(function(M,L){if(!L.is(".select2-result-selectable")&&L.find(".select2-result-selectable:not(.select2-selected)").length===0){L.addClass("select2-selected")}});if(this.highlight()==-1){H.highlight(0)}},resizeSearch:function(){var M,K,J,H,I,L=n(this.search);M=z(this.search)+10;K=this.search.offset().left;J=this.selection.width();H=this.selection.offset().left;I=J-(K-H)-L;if(I1){I=arguments[1]}if(!K&&K!==0){this.opts.element.val("");this.updateSelection([]);this.clearSearch();if(I){this.triggerChange()}return}this.setVal(K);if(this.select){this.opts.initSelection(this.select,this.bind(this.updateSelection));if(I){this.triggerChange()}}else{if(this.opts.initSelection===l){throw new Error("val() cannot be called if initSelection() is not defined")}this.opts.initSelection(this.opts.element,function(M){var L=j(M).map(H.id);H.setVal(L);H.updateSelection(M);H.clearSearch();if(I){H.triggerChange()}})}this.clearSearch()},onSortStart:function(){if(this.select){throw new Error("Sorting of elements is not supported when attached to instead.")}this.search.width(0);this.searchContainer.hide()},onSortEnd:function(){var I=[],H=this;this.searchContainer.show();this.searchContainer.appendTo(this.searchContainer.parent());this.resizeSearch();this.selection.find(".select2-search-choice").each(function(){I.push(H.opts.id(j(this).data("select2-data")))});this.setVal(I);this.triggerChange()},data:function(I){var H=this,J;if(arguments.length===0){return this.selection.find(".select2-search-choice").map(function(){return j(this).data("select2-data")}).get()}else{if(!I){I=[]}J=j.map(I,function(K){return H.opts.id(K)});this.setVal(J);this.updateSelection(I);this.clearSearch()}}});j.fn.select2=function(){var K=Array.prototype.slice.call(arguments,0),L,J,M,I,H=["val","destroy","opened","open","close","focus","isFocused","container","onSortStart","onSortEnd","enable","disable","positionDropdown","data"];this.each(function(){if(K.length===0||typeof(K[0])==="object"){L=K.length===0?{}:j.extend({},K[0]);L.element=j(this);if(L.element.get(0).tagName.toLowerCase()==="select"){I=L.element.attr("multiple")}else{I=L.multiple||false;if("tags" in L){L.multiple=I=true}}J=I?new G():new w();J.init(L)}else{if(typeof(K[0])==="string"){if(b(K[0],H)<0){throw"Unknown method: "+K[0]}M=l;J=j(this).data("select2");if(J===l){return}if(K[0]==="container"){M=J.container}else{M=J[K[0]].apply(J,K.slice(1))}if(M!==l){return false}}else{throw"Invalid arguments to select2 plugin: "+K}}});return(M===l)?this:M};j.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:true,openOnEnter:true,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(I,J,L,H){var K=[];i(I.text,L.term,K,H);return K.join("")},formatSelection:function(I,H){return I?I.text:l},sortResults:function(I,H,J){return I},formatResultCssClass:function(H){return l},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(H,I){var J=I-H.length;return"Please enter "+J+" more character"+(J==1?"":"s")},formatInputTooLong:function(I,H){var J=I.length-H;return"Please enter "+J+" less character"+(J==1?"":"s")},formatSelectionTooBig:function(H){return"You can only select "+H+" item"+(H==1?"":"s")},formatLoadMore:function(H){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(H){return H.id},matcher:function(H,I){return I.toUpperCase().indexOf(H.toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:A,escapeMarkup:function(H){var I={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(H).replace(/[&<>"'/\\]/g,function(J){return I[J[0]]})},blurOnChange:false,selectOnBlur:false,adaptContainerCssClass:function(H){return H},adaptDropdownCssClass:function(H){return null}};window.Select2={query:{ajax:p,local:s,tags:o},util:{debounce:g,markMatch:i},"class":{"abstract":e,single:w,multi:G}}}(jQuery));