text: /* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */
  
  !function(e){var t=function(){};e.extend(t.prototype,{name:"autosuggest",options:{prefill:"",allowDuplicates:true,inputName:"term[]",resultsHighlight:true,addButtonText:"Add"},initialize:function(t,i){this.options=e.extend({},this.options,i);var s=this;this.input=t;e.extend(e.expr[":"],{focus:function(e){return e==document.activeElement}});t.addClass("as-input").wrap('<ul class="as-selections">').wrap('<li class="as-original">').autocomplete(e.extend({select:function(e,t){s.addItem(t.item);t.item.value=t.item.label=""}},this.options)).bind("blur",function(e){s.selections_holder.addClass("blur").find("li.as-selection-item").removeClass("selected")}).bind("focus",function(){s.selections_holder.removeClass("blur")}).bind("keydown",function(i){switch(i.which){case 8:if(t.val()==""){i.preventDefault();li=e("li.as-selection-item:last");li.is(".selected")?s.removeItem(li):s.selectItem(li)}break;case 9:case 188:i.preventDefault();s.addItem(t.val());break}});this.selections_holder=t.closest("ul.as-selections").bind("click",function(){if(t.not(":focus")){t.focus()}});this.original=this.selections_holder.find("li.as-original");e('<li class="add-tag-button" >').insertAfter(this.original).text(this.options.addButtonText).bind("click",function(){e.each(t.val().split(","),function(e,t){s.addItem(t)})});if(typeof this.options.prefill=="string"){e.each(this.options.prefill.split(","),function(e,t){s.addItem(t)})}else{s.addItem(this.options.prefill)}t.is(":focus")?t.focus():t.blur();this.selections_holder.delegate("a.as-close","click",function(){s.removeItem(e(this).parent())}).delegate("li.as-selection-item","click",function(){s.selectItem(this)})},addItem:function(t){if(typeof t=="string")t={label:t.trim(),value:t.trim()};if(t.value!=""&&(this.options.allowDuplicates||!this.itemExists(t))){var i=e('<li class="as-selection-item">').text(t.label).data("item",t).insertBefore(this.original);e('<a class="as-close">&times;</a>').appendTo(i);e('<input type="hidden" class="as-value">').attr("name",this.options.inputName).val(t.value).appendTo(i)}this.input.val("");this.input.trigger("addItem",i)},removeItem:function(e){e.remove()},itemExists:function(t){var i=false;this.selections_holder.find("li.as-selection-item").each(function(){if(e(this).data("item")&&e(this).data("item").value.toLowerCase()==t.value.toLowerCase()){i=true;return}});return i},selectItem:function(t){e("li.as-selection-item",this.selections_holder).not(t).removeClass("selected");e(t).addClass("selected");if(this.input.not(":focus"))this.input.focus()}});e.fn[t.prototype.name]=function(){var i=arguments;var s=i[0]?i[0]:null;return this.each(function(){var a=e(this);if(t.prototype[s]&&a.data(t.prototype.name)&&s!="initialize"){a.data(t.prototype.name)[s].apply(a.data(t.prototype.name),Array.prototype.slice.call(i,1))}else if(!s||e.isPlainObject(s)){var n=new t;if(t.prototype["initialize"]){n.initialize.apply(n,e.merge([a],i))}a.data(t.prototype.name,n)}else{e.error("Method "+s+" does not exist on jQuery."+t.name)}})}}(jQuery);