/*
 * jQuery UI Autocomplete 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Autocomplete
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *	jquery.ui.position.js
 */

(function(d){var c=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,c;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(b){if(!a.options.disabled&&!a.element.propAttr("readOnly")){c=
!1;var f=d.ui.keyCode;switch(b.keyCode){case f.PAGE_UP:a._move("previousPage",b);break;case f.PAGE_DOWN:a._move("nextPage",b);break;case f.UP:a._move("previous",b);b.preventDefault();break;case f.DOWN:a._move("next",b);b.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:a.menu.active&&(c=!0,b.preventDefault());case f.TAB:if(!a.menu.active)break;a.menu.select(b);break;case f.ESCAPE:a.element.val(a.term);a.close(b);break;default:clearTimeout(a.searching),a.searching=setTimeout(function(){if(a.term!=
a.element.val())a.selectedItem=null,a.search(null,b)},a.options.delay)}}}).bind("keypress.autocomplete",function(a){c&&(c=!1,a.preventDefault())}).bind("focus.autocomplete",function(){if(!a.options.disabled)a.selectedItem=null,a.previous=a.element.val()}).bind("blur.autocomplete",function(b){if(!a.options.disabled)clearTimeout(a.searching),a.closing=setTimeout(function(){a.close(b);a._change(b)},150)});this._initSource();this.response=function(){return a._response.apply(a,arguments)};this.menu=d("<ul></ul>").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||
"body",b)[0]).mousedown(function(b){var c=a.menu.element[0];d(b.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(b){b.target!==a.element[0]&&b.target!==c&&!d.ui.contains(c,b.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(b,c){var d=c.item.data("item.autocomplete");!1!==a._trigger("focus",b,{item:d})&&/^key/.test(b.originalEvent.type)&&a.element.val(d.value)},selected:function(c,d){var e=d.item.data("item.autocomplete"),
h=a.previous;if(a.element[0]!==b.activeElement)a.element.focus(),a.previous=h,setTimeout(function(){a.previous=h;a.selectedItem=e},1);!1!==a._trigger("select",c,{item:e})&&a.element.val(e.value);a.term=a.element.val();a.close(c);a.selectedItem=e},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");
this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();a==="appendTo"&&this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&&b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,e;d.isArray(this.options.source)?(b=this.options.source,this.source=function(a,c){c(d.ui.autocomplete.filter(b,a.term))}):typeof this.options.source==="string"?
(e=this.options.source,this.source=function(b,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:e,data:b,dataType:"json",autocompleteRequest:++c,success:function(a){this.autocompleteRequest===c&&f(a)},error:function(){this.autocompleteRequest===c&&f([])}})}):this.source=this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);return this._trigger("search",b)===!1?void 0:this._search(a)},
_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)},_response:function(a){!this.options.disabled&&a&&a.length?(a=this._normalize(a),this._suggest(a),this._trigger("open")):this.close();this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},close:function(a){clearTimeout(this.closing);this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.deactivate(),this._trigger("close",a))},_change:function(a){this.previous!==
this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){return a.length&&a[0].label&&a[0].value?a:d.map(a,function(a){return typeof a==="string"?{label:a,value:a}:d.extend({label:a.label||a.value,value:a.value||a.label},a)})},_suggest:function(a){var b=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(b,a);this.menu.deactivate();this.menu.refresh();b.show();this._resizeMenu();b.position(d.extend({of:this.element},this.options.position));
this.options.autoFocus&&this.menu.next(new d.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(a,b){var c=this;d.each(b,function(b,d){c._renderItem(a,d)})},_renderItem:function(a,b){return d("<li></li>").data("item.autocomplete",b).append(d("<a></a>").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&
/^next/.test(a))this.element.val(this.term),this.menu.deactivate();else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(a,b){var c=RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(a){return c.test(a.label||a.value||a)})}})})(jQuery);
(function(d){d.widget("ui.menu",{_create:function(){var c=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){d(a.target).closest(".ui-menu-item a").length&&(a.preventDefault(),c.select(a))});this.refresh()},refresh:function(){var c=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
-1).mouseenter(function(a){c.activate(a,d(this).parent())}).mouseleave(function(){c.deactivate()})},activate:function(c,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,d=this.element.scrollTop(),g=this.element.height();b<0?this.element.scrollTop(d+b):b>=g&&this.element.scrollTop(d+b-g+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",c,{item:a})},deactivate:function(){if(this.active)this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),
this._trigger("blur"),this.active=null},next:function(c){this.move("next",".ui-menu-item:first",c)},previous:function(c){this.move("prev",".ui-menu-item:last",c)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(c,a,b){this.active?(c=this.active[c+"All"](".ui-menu-item").eq(0),c.length?this.activate(b,c):this.activate(b,this.element.children(a))):this.activate(b,this.element.children(a))},
nextPage:function(c){if(this.hasScroll())if(!this.active||this.last())this.activate(c,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});e.length||(e=this.element.children(".ui-menu-item:last"));this.activate(c,e)}else this.activate(c,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},
previousPage:function(c){if(this.hasScroll())if(!this.active||this.first())this.activate(c,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a+b-d(this).height();return c<10&&c>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(c,result)}else this.activate(c,this.element.children(".ui-menu-item").filter(!this.active||
this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[d.fn.prop?"prop":"attr"]("scrollHeight")},select:function(c){this._trigger("selected",c,{item:this.active})}})})(jQuery);
