jQuery.s=function(av,af,tt){var ak=this;var ab=jQuery(av).attr("autocomplete","off");if(af.inputClass){ab.addClass(af.inputClass)}var aj=document.createElement("div");var aq=jQuery(aj);var ttt="absolute";if (tt==1){ttt="fixed";}aq.hide().addClass(af.resultsClass).css("position",ttt);if(af.width>0){aq.css("width",af.width)}jQuery("body").append(aj);av.ca=ak;var S=null;var ac="";var R=-1;var ap={};var Z=false;var ao=false;var ay=null;function an(){ap={};ap.data={};ap.length=0}an();if(af.data!=null){var ah="",i={},am=[];if(typeof af.url!="string"){af.cacheLength=1}for(var O=0;O<af.data.length;O++){am=((typeof af.data[O]=="string")?[af.data[O]]:af.data[O]);if(am[0].length>0){ah=am[0].substring(0,1).toLowerCase();if(!i[ah]){i[ah]=[]}i[ah].push(am)}}for(var P in i){af.cacheLength++;au(P,i[P])}}ab.keydown(function(a){ay=a.keyCode;switch(a.keyCode){case 38:a.preventDefault();W(-1);break;case 40:a.preventDefault();W(1);break;case 9:case 13:if(U()){ab.get(0).blur();a.preventDefault()}break;default:R=-1;if(S){clearTimeout(S)}S=setTimeout(function(){ag()},af.delay);break}}).focus(function(){ao=true}).blur(function(){ao=false;aw()});ae();function ag(){if(ay==46||(ay>8&&ay<32)){return aq.hide()}var a=ab.val();if(a==ac){return}ac=a;if(a.length>=af.minChars){ab.addClass(af.loadingClass);X(a)}else{ab.removeClass(af.loadingClass);aq.hide()}}function W(a){var b=jQuery("li",aj);if(!b){return}R+=a;if(R<0){R=0}else{if(R>=b.size()){R=b.size()-1}}b.removeClass("ac_over");jQuery(b[R]).addClass("ac_over")}function U(){var b=jQuery("li.ac_over",aj)[0];if(!b){var a=jQuery("li",aj);if(af.selectOnly){if(a.length==1){b=a[0]}}else{if(af.selectFirst){b=a[0]}}}if(b){ai(b);return true}else{return false}}function ai(b){if(!b){b=document.createElement("li");b.extra=[];b.selectValue=""}var a=jQuery.trim(b.selectValue?b.selectValue:b.innerHTML);av.lastSelected=a;ac=a;aq.html("");ab.val(a);ae();if(af.onItemSelect){setTimeout(function(){af.onItemSelect(b)},1)}}function ax(c,a){var d=ab.get(0);if(d.createTextRange){var b=d.createTextRange();b.collapse(true);b.moveStart("character",c);b.moveEnd("character",a);b.select()}else{if(d.setSelectionRange){d.setSelectionRange(c,a)}else{if(d.selectionStart){d.selectionStart=c;d.selectionEnd=a}}}d.focus()}function ad(a){if(ay!=8){ab.val(ab.val()+a.substring(ac.length));ax(ac.length,a.length)}}function V(){var a=aa(av);var b=(af.width>0)?af.width:ab.width();aq.css({width:parseInt(b)+"px",top:(a.y+av.offsetHeight)+"px",left:a.x+"px"}).show()}function aw(){if(S){clearTimeout(S)}S=setTimeout(ae,200)}function ae(){if(S){clearTimeout(S)}ab.removeClass(af.loadingClass);if(aq.is(":visible")){aq.hide()}if(af.mustMatch){var a=ab.val();if(a!=av.lastSelected){ai(null)}}}function ar(a,b,c){if(b){ab.removeClass(af.loadingClass);aj.innerHTML="";if(!ao||b.length==0){return ae()}if(jQuery.browser.msie){aq.append(document.createElement("iframe"))}aj.appendChild(Q(b,a,c));if(af.autoFill&&(ab.val().toLowerCase()==a.toLowerCase())){ad(b[0][0])}V()}else{ae()}}function at(c){if(!c){return null}var a=[];var d=c.split(af.lineSeparator);for(var e=0;e<d.length;e++){var b=jQuery.trim(d[e]);if(b){a[a.length]=b.split(af.cellSeparator)}}return a}function Q(g,e,l){var c=document.createElement("ul");var d=g.length;if((af.maxItemsToShow>0)&&(af.maxItemsToShow<d)){d=af.maxItemsToShow}for(var f=0;f<d;f++){var a=g[f];if(!a){continue}var b=document.createElement("li");if(af.formatItem){b.innerHTML=af.formatItem(a,f,d,l);b.selectValue=a[0]}else{b.innerHTML=a[0];b.selectValue=a[0]}var j=null;if(a.length>1){j=[];for(var h=1;h<a.length;h++){j[j.length]=a[h]}}b.extra=j;c.appendChild(b);jQuery(b).hover(function(){jQuery("li",c).removeClass("ac_over");jQuery(this).addClass("ac_over");R=jQuery("li",c).indexOf(jQuery(this).get(0))},function(){jQuery(this).removeClass("ac_over")}).click(function(m){m.preventDefault();m.stopPropagation();ai(this)})}return c}function X(a){var c=a;if(!af.matchCase){a=a.toLowerCase()}var b=af.cacheLength?k(a):null;if(b){ar(a,b,c)}else{if((typeof af.url=="string")&&(af.url.length>0)){jQuery.get(al(a),function(d){d=at(d);au(a,d);ar(a,d,c)})}else{ab.removeClass(af.loadingClass)}}}function al(b){var a=af.url+"?q="+encodeURI(b);for(var c in af.extraParams){a+="&"+c+"="+encodeURI(af.extraParams[c])}return a}function k(c){if(!c){return null}if(ap.data[c]){return ap.data[c]}if(af.matchSubset){for(var e=c.length-1;e>=af.minChars;e--){var h=c.substr(0,e);var b=ap.data[h];if(b){var d=[];for(var g=0;g<b.length;g++){var a=b[g];var f=a[0];if(Y(f,c)){d[d.length]=a}}return d}}}return null}function Y(b,c){if(!af.matchCase){b=b.toLowerCase()}var a=b.indexOf(c);if(a==-1){return false}return a==0||af.matchContains}this.flushCache=function(){an()};this.setExtraParams=function(a){af.extraParams=a};this.findValue=function(){var a=ab.val();if(!af.matchCase){a=a.toLowerCase()}var b=af.cacheLength?k(a):null;if(b){T(a,b)}else{if((typeof af.url=="string")&&(af.url.length>0)){jQuery.get(al(a),function(c){c=at(c);au(a,c);T(a,c)})}else{T(a,null)}}};function T(c,d){if(d){ab.removeClass(af.loadingClass)}var f=(d)?d.length:0;var h=null;for(var e=0;e<f;e++){var b=d[e];if(b[0].toLowerCase()==c.toLowerCase()){h=document.createElement("li");if(af.formatItem){h.innerHTML=af.formatItem(b,e,f);h.selectValue=b[0]}else{h.innerHTML=b[0];h.selectValue=b[0]}var a=null;if(b.length>1){a=[];for(var g=1;g<b.length;g++){a[a.length]=b[g]}}h.extra=a}}if(af.onFindValue){setTimeout(function(){af.onFindValue(h)},1)}}function au(a,b){if(!b||!a||!af.cacheLength){return}if(!ap.length||ap.length>af.cacheLength){an();ap.length++}else{if(!ap[a]){ap.length++}}ap.data[a]=b}function aa(a){var c=a.offsetLeft||0;var b=a.offsetTop||0;while(a=a.offsetParent){c+=a.offsetLeft;b+=a.offsetTop}return{x:c,y:b}}};jQuery.fn.s=function(d,e,f,tt){e=e||{};e.url=d;e.data=((typeof f=="object")&&(f.constructor==Array))?f:null;e.inputClass=e.inputClass||"ac_input";e.resultsClass=e.resultsClass||"ac_results";e.lineSeparator=e.lineSeparator||"\n";e.cellSeparator=e.cellSeparator||"|";e.minChars=e.minChars||1;e.delay=e.delay||400;e.matchCase=e.matchCase||0;e.matchSubset=e.matchSubset||1;e.matchContains=e.matchContains||0;e.cacheLength=e.cacheLength||1;e.mustMatch=e.mustMatch||0;e.extraParams=e.extraParams||{};e.loadingClass=e.loadingClass||"ac_loading";e.selectFirst=e.selectFirst||false;e.selectOnly=e.selectOnly||false;e.maxItemsToShow=e.maxItemsToShow||-1;e.autoFill=e.autoFill||false;e.width=parseInt(e.width,10)||0;this.each(function(){var a=this;new jQuery.s(a,e,tt)});return this};jQuery.fn.autocompleteArray=function(c,d){return this.s(null,d,c)};jQuery.fn.indexOf=function(c){for(var d=0;d<this.length;d++){if(this[d]==c){return d}}return -1};function findValue(d){if(d==null){return alert(":(")}if(!!d.extra){var c=d.extra[0]}else{var c=d.selectValue}}function selectItem(b){findValue(b)}function formatItem(a,h,i,b){var j=a[0].replace(b,"<b>"+b+"</b>");j=a[0].replace(b,"<b>"+b+"</b>");j=j.replace(b.charAt(0).toUpperCase()+b.substr(1),"<b>"+b.charAt(0).toUpperCase()+b.substr(1)+"</b>");if(a[1]!=undefined)j=j+"<span>"+a[1]+"</span>";return j.replace(b.toLowerCase(),"<b><i>"+b.toLowerCase()+"</i></b>")};(function($){var cache=[];$.pli=function(){var args_len=arguments.length;for(var i=args_len;i--;){var cacheImage=document.createElement('img');cacheImage.src = arguments[i];cache.push(cacheImage);}}})(jQuery)

