jQuery.expr[":"].Contains=function(e,t,l){return 0<=(e.textContent||e.innerText||"").toUpperCase().indexOf(l[3].toUpperCase())},function(i){"use strict";i.fn.fancySelect=function(s){function l(e){return this.select=e,this.container=s.generateContainer(),this.results=s.generateResultsContainer().css({position:"absolute",display:"none"}),this.init()}return s=jQuery.extend({containerClass:"fancy-select",resultsClass:"fancy-select-results",placeholderClass:"fancy-select-replaced",itemHoverClass:"fancy-select-hover",selectOpenClass:"fancy-select-open",selectHoverClass:"fancy-select-hovered",allowTextFilter:!1,onItemEnter:function(){i(this).addClass(s.itemHoverClass)},onItemLeave:function(){i(this).removeClass(s.itemHoverClass)},onOptionSelect:function(){},onSelectOpen:function(){i(this).addClass(s.selectOpenClass),i(this).siblings(s.getResultsSelector()).show()},onSelectClose:function(){i(this).siblings(s.getResultsSelector()).hide(),i(this).removeClass(s.selectOpenClass)},onSelectEnter:function(){i(this).addClass(s.selectHoverClass)},onSelectLeave:function(){i(this).removeClass(s.selectHoverClass)},getResultsSelector:function(){return"."+s.resultsClass},getPlaceholderSelector:function(){return"."+s.placeholderClass},generateResultsContainer:function(){return i("
").addClass(s.resultsClass)},generatePlaceholderContainer:function(){return i("").addClass(s.placeholderClass)},generateReplacedRow:function(e){return i("").text(i(e).text()).data("value",i(e).val())},generateFilterInput:function(e){return i('').addClass("fancy-placeholder fancy-placeholder-input")},generateContainer:function(){return i("").addClass(s.containerClass)}},s),i(document).click(function(e){void 0===e&&(e=window.event),0"),t=this;return this.select.children("option").each(function(e,t){l.append(s.generateReplacedRow(i(t)))}),this.results.append(l),e=i("option:selected",this.select),this.placeholder_p=i('').append(e.text()).data("default",e.text()),this.placeholder=s.generatePlaceholderContainer(s).click(function(){var e=t.results.is(":hidden");i(s.getPlaceholderSelector()).each(function(){s.onSelectClose.call(this)}),e&&(s.onSelectOpen.call(this),s.allowTextFilter)&&t.focus()}).hover(function(){s.onSelectEnter.call(this)},function(){s.onSelectLeave.call(this)}).append(this.placeholder_p),s.allowTextFilter&&this.placeholder.append(this.createFilterInput()),this.container.append(this.placeholder),this.container.append(this.results),this.container.append(this.val),this.container.hide(),this.select.after(this.container),this.select.hide(),this.container.show(),this},l.prototype.setSelectedItem=function(e){var t;s.allowTextFilter&&((t=this.placeholder.find(".fancy-placeholder-input")).clearingOnSelection=!0,t.blur(),t.clearingOnSelection=!1,t.val("")),this.placeholder.find(".fancy-placeholder-text").text(i(e).text()),this.select.val(i(e).data("value"))},l.prototype.focus=function(){i(this.placeholder).find("input").focus()},l.prototype.createFilterInput=function(){var l=this;return this.input=s.generateFilterInput(l),this.input.keydown(function(e){/37|38|39|40|13/.test(e.keyCode)||l.placeholder_p.text(""),l.results.is(":hidden")&&s.onSelectOpen.call(l.placeholder)}).keyup(function(e){var t=i(this).val().replace(/[\(|\)]/gi,"");t.length<1?(l.placeholder_p.text(l.placeholder_p.data("default")),i("li",l.results).show()):(l.placeholder_p.text(""),i("li:not(:Contains("+t+"))",l.results).hide().removeClass(s.itemHoverClass),(t=i("li:Contains("+t+")",l.results)).show(),i(":first",t).addClass(s.itemHoverClass)),i("li."+s.itemHoverClass+":hidden",l.results).each(function(){s.onItemLeave(this)})}).blur(function(){i(this).val()<1&&!this.clearingOnSelection&&l.placeholder_p.text(l.placeholder_p.data("default"))}),l.input.attr("tabIndex",l.select.tabIndex),l.input},this.each(function(){var t=new l(i(this)),e=t.results;i("li",e).click(function(e){return t.setSelectedItem(this),s.onOptionSelect.call(this),s.onSelectClose.call(t.placeholder),e.preventDefault()}).hover(function(){i("li:visible",e).each(function(){s.onItemLeave.call(this)}),s.onItemEnter.call(this)},function(){s.onItemLeave.call(this)})})}}(jQuery);