(function(a){a.fn.extend({liveSearch:function(b){return this.each(function(){var c=b=a.extend({},a.liveSearch.defaults,b||{});new a.liveSearch(this,c)})}});a.liveSearch=function(c,b){this.init(c,b)};a.extend(a.liveSearch.prototype,{init:function(d,c){var b=this;this.options=c;this.timer=null;this.cache=null;this.element=jQuery(d);this.list=jQuery(this.options.list);this.delay=this.options.delay;this.filterList=jQuery(this.options.filter||this.list);if(this.filterList.length){this.cache=this.filterList.map(this.options.data);this.element.keyup(function(){var e=this;if(b.timer){clearTimeout(b.timer)}b.timer=setTimeout(function(){b.options.before.apply(b);b.filter();b.options.after.apply(b)},b.delay)}).parents("form").submit(function(){return false})}return this},filter:function(){var b=this,c=[],d=this.list;this.term=a.trim(this.element.val().toLowerCase()).match(/(\w|\s|[*])*/g).join("");if(!this.term){d.each(function(){b.options.show.apply(this)})}else{d.each(function(){b.options.hide.apply(this)});this.cache.each(function(f,e){var g=new RegExp(b.term.replace("*",""),"g");if(g.test(e)||b.options.exclude.apply(d[f])){c.push(f)}});a.each(c,function(){b.options.show.apply(jQuery(d[this]))})}}});a.extend(a.liveSearch,{defaults:{delay:250,show:function(){a(this).show()},hide:function(){a(this).hide()},data:function(){return a(this)[0].innerHTML.toLowerCase()},exclude:function(){return false},before:function(){},after:function(){}}})})(jQuery);