jQuery.autocomplete=function(D,S){var N=this;var Y=jQuery(D).attr("id");var W=jQuery(D).attr("autocomplete","off");if(S.inputClass){W.addClass(S.inputClass)}var O=document.createElement("div");var H=jQuery(O);H.hide().addClass(S.resultsClass).css("position","absolute");if(S.width>0){H.css("width",S.width)}jQuery("body").append(O);D.autocompleter=N;var g=null;var V="";var h=-1;var I={};var a=false;var J=false;var A=null;function K(){I={};I.data={};I.length=0}K();if(S.data!=null){var Q="",o={},L=[];if(typeof S.url!="string"){S.cacheLength=1}for(var m=0;m<S.data.length;m++){L=((typeof S.data[m]=="string")?[S.data[m]]:S.data[m]);if(L[0].length>0){Q=L[0].substring(0,1).toLowerCase();if(!o[Q]){o[Q]=[]}o[Q].push(L)}}for(var l in o){S.cacheLength++;E(l,o[l])}}W.keydown(function(i){A=i.keyCode;switch(i.keyCode){case 38:i.preventDefault();c(-1);break;case 40:i.preventDefault();c(1);break;case 9:case 13:if(e()){W.get(0).blur();i.preventDefault()}break;default:h=-1;if(g){clearTimeout(g)}g=setTimeout(function(){R()},S.delay);break}}).focus(function(){J=true}).blur(function(){J=false;C()});T();function R(){if(A==46||(A>8&&A<32)){return H.hide()}var i=W.val();if(i==V){return}V=i;if(i.length>=S.minChars){W.addClass(S.loadingClass);b(i)}else{W.removeClass(S.loadingClass);H.hide()}}function c(k){var i=jQuery("li",O);if(!i){return}h+=k;if(h<0){h=0}else{if(h>=i.size()){h=i.size()-1}}i.removeClass("ac_over");jQuery(i[h]).addClass("ac_over")}function e(){var i=jQuery("li.ac_over",O)[0];if(!i){var k=jQuery("li",O);if(S.selectOnly){if(k.length==1){i=k[0]}}else{if(S.selectFirst){i=k[0]}}}if(i){P(i);return true}else{return false}}function P(i){if(!i){i=document.createElement("li");i.extra=[];i.selectValue=""}var k=jQuery.trim(i.selectValue?i.selectValue:i.innerHTML);D.lastSelected=k;V=k;H.html("");W.val(k);T();if(S.onItemSelect){setTimeout(function(){S.onItemSelect(i)},1)}}function B(q,k){var p=W.get(0);if(p.createTextRange){var i=p.createTextRange();i.collapse(true);i.moveStart("character",q);i.moveEnd("character",k);i.select()}else{if(p.setSelectionRange){p.setSelectionRange(q,k)}else{if(p.selectionStart){p.selectionStart=q;p.selectionEnd=k}}}p.focus()}function U(i){if(A!=8){W.val(W.val()+i.substring(V.length));B(V.length,i.length)}}function d(){var q=X(D);var i=0;var k=0;if(Y=="nemoInput"){i=10;k=10}else{if(!esIE6()){i=0;k=-9}else{i=10;k=0}}if(!jQuery.browser.msie){i=0;k=0}var p=(S.width>0)?S.width:W.width();H.css({width:parseInt(p)+"px",top:((q.y+i)+D.offsetHeight)+"px",left:(q.x+k)+"px"}).show()}function C(){if(g){clearTimeout(g)}g=setTimeout(T,200)}function T(){if(g){clearTimeout(g)}W.removeClass(S.loadingClass);if(H.is(":visible")){H.hide()}if(S.mustMatch){var i=W.val();if(i!=D.lastSelected){P(null)}}}function G(k,i){if(i){W.removeClass(S.loadingClass);O.innerHTML="";if(!J||i.length==0){return T()}O.appendChild(j(i));if(esIE6()){H.bgiframe()}if(S.autoFill&&(W.val().toLowerCase()==k.toLowerCase())){U(i[0][0])}d()}else{T()}}function F(r){if(!r){return null}var k=[];var q=r.split(S.lineSeparator);for(var p=0;p<q.length;p++){var s=jQuery.trim(q[p]);if(s){k[k.length]=s.split(S.cellSeparator)}}return k}function j(u){var t=document.createElement("ul");var r=u.length;if((S.maxItemsToShow>0)&&(S.maxItemsToShow<r)){r=S.maxItemsToShow}for(var s=0;s<r;s++){var v=u[s];if(!v){continue}var p=document.createElement("li");if(S.formatItem){p.innerHTML=S.formatItem(v,s,r);p.selectValue=v[0]}else{p.innerHTML=v[0];p.selectValue=v[0]}var k=null;if(v.length>1){k=[];for(var q=1;q<v.length;q++){k[k.length]=v[q]}}p.extra=k;t.appendChild(p);jQuery(p).hover(function(){jQuery("li",t).removeClass("ac_over");jQuery(this).addClass("ac_over");h=jQuery("li",t).indexOf(jQuery(this).get(0))},function(){jQuery(this).removeClass("ac_over")}).click(function(i){i.preventDefault();i.stopPropagation();P(this)})}return t}function b(k){if(!S.matchCase){k=k.toLowerCase()}var i=S.cacheLength?n(k):null;if(i){G(k,i)}else{if((typeof S.url=="string")&&(S.url.length>0)){jQuery.get(M(k),function(p){p=F(p);E(k,p);G(k,p)})}else{W.removeClass(S.loadingClass)}}}function M(r){var k=S.url+"?q="+encodeURI(r);for(var p in S.extraParams){k+="&"+p+"="+encodeURI(S.extraParams[p])}return k}function n(v){if(!v){return null}if(I.data[v]){return I.data[v]}if(S.matchSubset){for(var t=v.length-1;t>=S.minChars;t--){var p=v.substr(0,t);var w=I.data[p];if(w){var u=[];for(var r=0;r<w.length;r++){var k=w[r];var s=k[0];if(Z(s,v)){u[u.length]=k}}return u}}}return null}function Z(q,p){if(!S.matchCase){q=q.toLowerCase()}var k=q.indexOf(p);if(k==-1){return false}return k==0||S.matchContains}this.flushCache=function(){K()};this.setExtraParams=function(i){S.extraParams=i};this.findValue=function(){var k=W.val();if(!S.matchCase){k=k.toLowerCase()}var i=S.cacheLength?n(k):null;if(i){f(k,i)}else{if((typeof S.url=="string")&&(S.url.length>0)){jQuery.get(M(k),function(p){p=F(p);E(k,p);f(k,p)})}else{f(k,null)}}};function f(v,u){if(u){W.removeClass(S.loadingClass)}var s=(u)?u.length:0;var p=null;for(var t=0;t<s;t++){var w=u[t];if(w[0].toLowerCase()==v.toLowerCase()){p=document.createElement("li");if(S.formatItem){p.innerHTML=S.formatItem(w,t,s);p.selectValue=w[0]}else{p.innerHTML=w[0];p.selectValue=w[0]}var k=null;if(w.length>1){k=[];for(var r=1;r<w.length;r++){k[k.length]=w[r]}}p.extra=k}}if(S.onFindValue){setTimeout(function(){S.onFindValue(p)},1)}}function E(k,i){if(!i||!k||!S.cacheLength){return}if(!I.length||I.length>S.cacheLength){K();I.length++}else{if(!I[k]){I.length++}}I.data[k]=i}function X(k){var p=k.offsetLeft||0;var i=k.offsetTop||0;while(k=k.offsetParent){p+=k.offsetLeft;i+=k.offsetTop}return{x:p,y:i}}};jQuery.fn.autocomplete=function(B,A,C){A=A||{};A.url=B;A.data=((typeof C=="object")&&(C.constructor==Array))?C:null;A.inputClass=A.inputClass||"ac_input";A.resultsClass=A.resultsClass||"ac_results";A.lineSeparator=A.lineSeparator||"\n";A.cellSeparator=A.cellSeparator||"|";A.minChars=A.minChars||1;A.delay=A.delay||400;A.matchCase=A.matchCase||0;A.matchSubset=A.matchSubset||1;A.matchContains=A.matchContains||0;A.cacheLength=A.cacheLength||1;A.mustMatch=A.mustMatch||0;A.extraParams=A.extraParams||{};A.loadingClass=A.loadingClass||"ac_loading";A.selectFirst=A.selectFirst||false;A.selectOnly=A.selectOnly||false;A.maxItemsToShow=A.maxItemsToShow||-1;A.autoFill=A.autoFill||false;A.width=parseInt(A.width,10)||0;this.each(function(){var D=this;new jQuery.autocomplete(D,A)});return this};jQuery.fn.autocompleteArray=function(B,A){return this.autocomplete(null,A,B)};jQuery.fn.indexOf=function(B){for(var A=0;A<this.length;A++){if(this[A]==B){return A}}return -1};function esIE6(){var C=false;if(navigator.appName=="Microsoft Internet Explorer"){var B=navigator.appVersion;var E=B.indexOf("MSIE");E=E+5;var A=B.substring(E,(E+3));var D=parseFloat(A);if(D<7){C=true}}return C};