function cAutocomplete(a){this.init(a)}cAutocomplete.CS_NAME="Autocomplete component";cAutocomplete.CS_OBJ_NAME="AC_COMPONENT";cAutocomplete.CS_LIST_PREFIX="ACL_";cAutocomplete.CS_BUTTON_PREFIX="ACB_";cAutocomplete.CS_INPUT_PREFIX="";cAutocomplete.CS_HIDDEN_INPUT_PREFIX="ACH_";cAutocomplete.CS_INPUT_CLASSNAME="dropdown";cAutocomplete.CB_AUTOINIT=true;cAutocomplete.CB_AUTOCOMPLETE=false;cAutocomplete.CB_FORCECORRECT=false;cAutocomplete.CB_MATCHSUBSTRING=false;cAutocomplete.CS_SEPARATOR=",";cAutocomplete.CS_ARRAY_SEPARATOR=",";cAutocomplete.CB_MATCHSTRINGBEGIN=true;cAutocomplete.CN_OFFSET_TOP=2;cAutocomplete.CN_OFFSET_LEFT=-1;cAutocomplete.CN_LINE_HEIGHT=19;cAutocomplete.CN_NUMBER_OF_LINES=10;cAutocomplete.CN_HEIGHT_FIX=2;cAutocomplete.CN_CLEAR_TIMEOUT=300;cAutocomplete.CN_SHOW_TIMEOUT=400;cAutocomplete.CN_REMOTE_SHOW_TIMEOUT=1e3;cAutocomplete.CN_MARK_TIMEOUT=400;cAutocomplete.hListDisplayed=null;cAutocomplete.nCount=0;cAutocomplete.autoInit=function(){var a=0;var b=null;var c;for(a=0;a<document.getElementsByTagName("INPUT").length;a++){if(document.getElementsByTagName("INPUT")[a].type.toLowerCase()=="text"){c=document.getElementsByTagName("INPUT")[a].getAttribute("acdropdown");if(c!=null&&c.length>0){if(document.getElementsByTagName("INPUT")[a].id==null||document.getElementsByTagName("INPUT")[a].id.length==0){document.getElementsByTagName("INPUT")[a].id=cAutocomplete.CS_OBJ_NAME+cAutocomplete.nCount}b=new cAutocomplete(document.getElementsByTagName("INPUT")[a].id)}}}var d=document.getElementsByTagName("TEXTAREA").length;for(a=0;a<d;a++){c=document.getElementsByTagName("TEXTAREA")[a].getAttribute("acdropdown");if(c!=null&&c.length>0){if(document.getElementsByTagName("TEXTAREA")[a].id==null||document.getElementsByTagName("TEXTAREA")[a].id.length==0){document.getElementsByTagName("TEXTAREA")[a].id=cAutocomplete.CS_OBJ_NAME+cAutocomplete.nCount}b=new cAutocomplete(document.getElementsByTagName("TEXTAREA")[a].id)}}var e=document.getElementsByTagName("SELECT").length;var f=null;for(a=0;a<e;a++){f=document.getElementsByTagName("SELECT")[a];c=f.getAttribute("acdropdown");if(c!=null&&c.length>0){if(f.id==null||f.id.length==0){f.id=cAutocomplete.CS_OBJ_NAME+cAutocomplete.nCount}b=new cAutocomplete(f.id);e--;a--}}};if(cAutocomplete.CB_AUTOINIT){if(window.attachEvent){window.attachEvent("onload",cAutocomplete.autoInit)}else if(window.addEventListener){window.addEventListener("load",cAutocomplete.autoInit,false)}}cAutocomplete.prototype.init=function(sInputId){this.sInputId=sInputId;this.sListId=cAutocomplete.CS_LIST_PREFIX+sInputId;this.sObjName=cAutocomplete.CS_OBJ_NAME+"_obj_"+cAutocomplete.nCount++;this.hObj=this.sObjName;this.hActiveSelection=null;this.nSelectedItemIdx=-1;this.sLastActiveValue="";this.sActiveValue="";this.bListDisplayed=false;this.nItemsDisplayed=0;this.bAssociative=false;this.sHiddenInputId=null;this.bHasButton=false;this.aData=null;this.aSearchData=new Array;this.bSorted=false;this.nLastMatchLength=0;this.bForceCorrect=cAutocomplete.CB_FORCECORRECT;var sForceCorrect=document.getElementById(this.sInputId).getAttribute("autocomplete_forcecorrect");if(sForceCorrect!=null&&sForceCorrect.length>0){this.bForceCorrect=eval(sForceCorrect)}this.bMatchBegin=cAutocomplete.CB_MATCHSTRINGBEGIN;var sMatchBegin=document.getElementById(this.sInputId).getAttribute("autocomplete_matchbegin");if(sMatchBegin!=null&&sMatchBegin.length>0){this.bMatchBegin=eval(sMatchBegin)}this.bMatchSubstring=cAutocomplete.CB_MATCHSUBSTRING;var sMatchSubstring=document.getElementById(this.sInputId).getAttribute("autocomplete_matchsubstring");if(sMatchSubstring!=null&&sMatchSubstring.length>0){this.bMatchSubstring=true}this.bAutoComplete=cAutocomplete.CB_AUTOCOMPLETE;this.bAutocompleted=false;var sAutoComplete=document.getElementById(this.sInputId).getAttribute("autocomplete_complete");if(sAutoComplete!=null&&sAutoComplete.length>0){this.bAutoComplete=eval(sAutoComplete)}this.formatOptions=null;var sFormatFunction=document.getElementById(this.sInputId).getAttribute("autocomplete_format");if(sFormatFunction!=null&&sFormatFunction.length>0){this.formatOptions=eval(sFormatFunction)}this.onSelect=null;var sOnSelectFunction=document.getElementById(this.sInputId).getAttribute("autocomplete_onselect");if(sOnSelectFunction!=null&&sOnSelectFunction.length>0){this.onSelect=eval(sOnSelectFunction)}this.bAssociative=true;var sAssociative=document.getElementById(this.sInputId).getAttribute("autocomplete_assoc");if(sAssociative!=null&&sAssociative.length>0){if(sAssociative=="false"){this.bAssociative=false}}if(this.getListArrayType()!="url"){this.bRemoteList=false}else{this.bRemoteList=true;this.sListURL=this.getListURL();this.hXMLHttp=XmlHttp.create()}this.initListArray();this.initListContainer();this.initInput();eval(this.hObj+"= this")};cAutocomplete.prototype.initInput=function(){var a=document.getElementById(this.sInputId);a.hAutocomplete=this;var b=document.getElementById(this.sListId);b.hAutocomplete=this;var c=a.offsetWidth;if(!c||c==0){var d=a.cloneNode(true);d.style.position="absolute";d.style.top="-1000px";document.body.appendChild(d);var c=d.offsetWidth;document.body.removeChild(d)}var e=a.name;var f=a.form;var g=false;var h=a.value;var i=a.type.toLowerCase()=="text"?a.value:"";var j=a.getAttribute("autocomplete_button");if(j!=null&&j.length>0){g=true}if(a.type.toLowerCase()=="select-one"){g=true;if(a.selectedIndex>=0){h=a.options[a.selectedIndex].value;i=a.options[a.selectedIndex].text}}if(f&&false){var k=document.createElement("INPUT");k.id=cAutocomplete.CS_HIDDEN_INPUT_PREFIX+this.sInputId;k.type="hidden";f.appendChild(k);if(this.bAssociative){k.name=e;a.name=cAutocomplete.CS_INPUT_PREFIX+e}else{k.name=cAutocomplete.CS_INPUT_PREFIX+e}k.value=h;this.sHiddenInputId=k.id}if(g){this.bHasButton=true;var l=document.createElement("DIV");l.className="acinputContainer";l.style.width=c;var m=document.createElement("INPUT");m.id=cAutocomplete.CS_BUTTON_PREFIX+this.sInputId;m.type="button";m.className="button";m.tabIndex=a.tabIndex+1;m.hAutocomplete=this;var n=document.createElement("INPUT");if(this.bAssociative){n.name=cAutocomplete.CS_INPUT_PREFIX+e}else{n.name=e}n.type="text";n.value=i;n.style.width=c-22;n.className=cAutocomplete.CS_INPUT_CLASSNAME;n.tabIndex=a.tabIndex;n.hAutocomplete=this;l.appendChild(n);l.appendChild(m);a.parentNode.replaceChild(l,a);n.id=this.sInputId;a=n}if(a.attachEvent){a.attachEvent("onkeyup",cAutocomplete.onInputKeyUp);a.attachEvent("onkeyup",cAutocomplete.saveCaretPosition);a.attachEvent("onkeydown",cAutocomplete.onInputKeyDown);a.attachEvent("onblur",cAutocomplete.onInputBlur);a.attachEvent("onfocus",cAutocomplete.onInputFocus);if(m){m.attachEvent("onclick",cAutocomplete.onButtonClick)}}else if(a.addEventListener){a.addEventListener("keyup",cAutocomplete.onInputKeyUp,false);a.addEventListener("keyup",cAutocomplete.saveCaretPosition,false);a.addEventListener("keydown",cAutocomplete.onInputKeyDown,false);a.addEventListener("keypress",cAutocomplete.onInputKeyPress,false);a.addEventListener("blur",cAutocomplete.onInputBlur,false);a.addEventListener("focus",cAutocomplete.onInputFocus,false);if(m){m.addEventListener("click",cAutocomplete.onButtonClick,false)}}a.setAttribute("autocomplete","OFF");if(f){if(f.attachEvent){f.attachEvent("onsubmit",cAutocomplete.onFormSubmit)}else if(f.addEventListener){f.addEventListener("submit",cAutocomplete.onFormSubmit,false)}}};cAutocomplete.prototype.initListContainer=function(){var a=document.getElementById(this.sInputId);var b=document.createElement("DIV");b.className="autocomplete_holder";b.id=this.sListId;b.style.zIndex=1e4+cAutocomplete.nCount;b.hAutocomplete=this;var c=document.createElement("DIV");c.className="autocomplete_firstborder";var d=document.createElement("DIV");d.className="autocomplete_secondborder";var e=document.createElement("UL");e.className="autocomplete";d.appendChild(e);c.appendChild(d);b.appendChild(c);document.body.appendChild(b);if(b.attachEvent){b.attachEvent("onblur",cAutocomplete.onListBlur);b.attachEvent("onfocus",cAutocomplete.onListFocus)}else if(a.addEventListener){b.addEventListener("blur",cAutocomplete.onListBlur,false);b.addEventListener("focus",cAutocomplete.onListFocus,false)}if(b.attachEvent){b.attachEvent("onclick",cAutocomplete.onItemClick)}else if(b.addEventListener){b.addEventListener("click",cAutocomplete.onItemClick,false)}};cAutocomplete.prototype.createList=function(){var a=document.getElementById(this.sInputId);var b=document.getElementById(this.sListId);var c=b.getElementsByTagName("UL")[0];if(c){c=c.parentNode.removeChild(c);while(c.hasChildNodes()){c.removeChild(c.childNodes[0])}}var d=null;var e=null;var f=null;var g=null;var h=this.aData;var i=0;var j;for(f in h){g=h[f];d=document.createElement("LI");e=document.createElement("A");e.setAttribute("itemvalue",f);var k=g.split(cAutocomplete.CS_ARRAY_SEPARATOR);if(k.length>1){this.aData[f]=k[0];e.setAttribute("itemdata",g.substring(g.indexOf(cAutocomplete.CS_ARRAY_SEPARATOR)+1));j=k[0]}else{j=g}e.href="#";e.appendChild(document.createTextNode(j));e.realText=j;if(i==this.nSelectedItemIdx){this.hActiveSelection=e;this.hActiveSelection.className="selected"}d.appendChild(e);c.appendChild(d);this.aSearchData[i++]=j.toLowerCase()}var l=b.firstChild.firstChild;l.appendChild(c);this.bListUpdated=false};cAutocomplete.prototype.initListArray=function(){var hInput=document.getElementById(this.sInputId);var hArr=null;if(hInput.type.toLowerCase()=="select-one"){hArr=new Object;for(var nI=0;nI<hInput.options.length;nI++){hArrKey=hInput.options.item(nI).value;sArrEl=hInput.options.item(nI).text;hArr[hArrKey]=sArrEl;if(hInput.options.item(nI).selected){this.nSelectedItemIdx=nI}}}else{var sAA=hInput.getAttribute("autocomplete_list");var sAAS=hInput.getAttribute("autocomplete_list_sort");var sArrayType=this.getListArrayType();switch(sArrayType){case"array":hArr=eval(sAA.substring(6));break;case"list":hArr=new Array;var hTmpArray=sAA.substring(5).split("|");var aValueArr;for(hKey in hTmpArray){aValueArr=hTmpArray[hKey].split(cAutocomplete.CS_ARRAY_SEPARATOR);if(aValueArr.length==1){hArr[hKey]=hTmpArray[hKey];this.bAssociative=false}else{hArr[aValueArr[0]]=aValueArr[1]}}break}if(sAAS!=null&&eval(sAAS)){this.bSorted=true;this.aData=hArr.sort();hArr=hArr.sort()}}this.setArray(hArr)};cAutocomplete.prototype.setArray=function(sArray){if(typeof sArray=="string"){this.aData=eval(sArray)}else{this.aData=sArray}this.bListUpdated=true};cAutocomplete.prototype.setListArray=function(a){this.setArray(a);this.updateAndShowList()};cAutocomplete.prototype.getListArrayType=function(){var a=document.getElementById(this.sInputId);var b=a.getAttribute("autocomplete_list");if(b!=null&&b.length>0){if(b.indexOf("array:")>=0){return"array"}else if(b.indexOf("list:")>=0){return"list"}else if(b.indexOf("url:")>=0){return"url"}}};cAutocomplete.prototype.getListURL=function(){var a=document.getElementById(this.sInputId);var b=a.getAttribute("autocomplete_list");if(b!=null&&b.length>0){if(b.indexOf("url:")>=0){return b.substring(4)}}};cAutocomplete.prototype.setListURL=function(a){this.sListURL=a};cAutocomplete.prototype.onXmlHttpLoad=function(){if(this.hXMLHttp.readyState==4){var a=this.hXMLHttp.parseError;if(a&&a.errorCode!=0){alert(a.reason)}else{this.afterRemoteLoad()}}};cAutocomplete.prototype.loadListArray=function(){var a=this.sListURL;var b=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint);b=b.replace(/^\s/,"");b=b.replace(/\s$/,"");if(a.indexOf("[S]")>=0){a=a.replace("[S]",b)}else{a+=this.sActiveValue}this.hXMLHttp.open("GET",a,true);var c=this;this.hXMLHttp.onreadystatechange=function(){c.onXmlHttpLoad()};this.hXMLHttp.send(null)};cAutocomplete.prototype.afterRemoteLoad=function(){var a=document.getElementById(this.sInputId);var b=new Array;var c=this.hXMLHttp.responseText.split("|");var d;for(hKey in c){d=c[hKey].split(cAutocomplete.CS_ARRAY_SEPARATOR);if(d.length==1){b[hKey]=c[hKey]}else{b[d[0]]=c[hKey].substr(c[hKey].indexOf(cAutocomplete.CS_ARRAY_SEPARATOR)+1)}}a.className="";a.readonly=false;a.value=this.sActiveValue;this.setListArray(b)};cAutocomplete.prototype.prepareList=function(a){var b=document.getElementById(this.sInputId);this.sActiveValue=b.value;if(this.bRemoteList){b.readonly=true}var c=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint);var d=this.getStringForAutocompletion(this.sLastActiveValue,this.nInsertPoint);if(d!=c||a||!this.bListDisplayed||this.bMatchSubstring){if(this.bRemoteList){b.className="search";b.value="please wait...";this.loadListArray();return}this.updateAndShowList(a)}};cAutocomplete.prototype.updateAndShowList=function(a){var b=document.getElementById(this.sListId);var c=b.getElementsByTagName("UL")[0];var d=document.getElementById(this.sInputId);if(this.bListUpdated){this.createList()}var e=this.bMatchSubstring?this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint):this.sActiveValue;var f=this.bMatchSubstring?this.getStringForAutocompletion(this.sLastActiveValue,this.nInsertPoint):this.sLastActiveValue;if(e==f){if(!this.bMatchSubstring){a=true}}this.filterOptions(a);if(this.nItemsDisplayed==0){if(this.bForceCorrect){var g=this.getInsertPos(this.sActiveValue,this.nInsertPoint,"");cAutocomplete.markInputRange(d,this.nLastMatchLength,g[0])}}this.sLastActiveValue=this.sActiveValue;if(this.nItemsDisplayed>0){if(!a||this.bMatchSubstring){this.deselectOption()}if(this.bAutoComplete&&this.nItemsDisplayed==1){var h=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint);var i=c.getElementsByTagName("LI")[this.nFirstDisplayed].getElementsByTagName("A")[0].realText;if(h.toLowerCase()==i.toLowerCase()){this.selectOption(c.getElementsByTagName("LI")[this.nFirstDisplayed].getElementsByTagName("A")[0]);this.hideOptions();return}}if(this.bAutoComplete&&!a){this.selectOption(c.getElementsByTagName("LI")[this.nFirstDisplayed].getElementsByTagName("A")[0])}this.showList()}else{this.clearList()}};cAutocomplete.prototype.showList=function(){if(cAutocomplete.hListDisplayed){cAutocomplete.hListDisplayed.clearList()}var a=document.getElementById(this.sInputId);var b=cDomObject.getOffsetParam(a,"offsetTop");var c=cDomObject.getOffsetParam(a,"offsetLeft");var d=document.getElementById(this.sListId);var e=d.getElementsByTagName("UL")[0];if(this.bHasButton){d.style.width=document.getElementById(this.sInputId).parentNode.offsetWidth}else{d.style.width=document.getElementById(this.sInputId).offsetWidth}var f=this.nItemsDisplayed<cAutocomplete.CN_NUMBER_OF_LINES?this.nItemsDisplayed:cAutocomplete.CN_NUMBER_OF_LINES;e.style.height=f*cAutocomplete.CN_LINE_HEIGHT+cAutocomplete.CN_HEIGHT_FIX+"px";d.style.top=b+a.offsetHeight+cAutocomplete.CN_OFFSET_TOP+"px";d.style.left=c+cAutocomplete.CN_OFFSET_LEFT+"px";d.style.display="none";d.style.visibility="visible";d.style.display="block";cAutocomplete.hListDisplayed=this;this.bListDisplayed=true};cAutocomplete.prototype.binarySearch=function(a){var b=0;var c=this.aSearchData.length-1;var d;var e,f;var g;var h=a.length;var i;while(b<=c){d=(b+c)/2;e=d<1?0:parseInt(d);g=this.aSearchData[e].substr(0,h);if(g<a){b=e+1;continue}if(g>a){c=e-1;continue}if(g==a){c=e-1;f=e;continue}return e}if(typeof f!="undefined"){return f}else{return null}};cAutocomplete.prototype.getStringForAutocompletion=function(a,b){if(a==null||a.length==0){return""}if(this.bMatchSubstring){var c=a.lastIndexOf(cAutocomplete.CS_SEPARATOR,b-1);c=c<0?0:c;var d=a.indexOf(cAutocomplete.CS_SEPARATOR,b);d=d<0?a.length:d;var e=a.substr(c,d-c);e=e.replace(/^(\,?)(\s*)(\S*)(\s*)(\,?)$/g,"$3");return e}else{return a}};cAutocomplete.prototype.insertString=function(a,b,c){if(this.bMatchSubstring){var d=a.lastIndexOf(cAutocomplete.CS_SEPARATOR,b-1);d=d<0?0:d;var e=a.indexOf(cAutocomplete.CS_SEPARATOR,b);e=e<0?a.length:e;var f=a.substr(d,e-d);f=f.replace(/^(\,?)(\s*)(\S?[\S\s]*\S?)(\s*)(\,?)$/g,"$1$2"+c+"$4$5");f=a.substr(0,d)+f+a.substr(e);return f}else{return c}};cAutocomplete.prototype.getInsertPos=function(a,b,c){b=b==null?0:b;var d=a.lastIndexOf(cAutocomplete.CS_SEPARATOR,b-1);d=d<0?0:d;var e=a.indexOf(cAutocomplete.CS_SEPARATOR,b);e=e<0?a.length:e;var f=a.substr(d,e-d);f=f.replace(/^(\,?)(\s*)(\S?[\S\s]*\S?)(\s*)(\,?)$/g,"$1$2"+c);return[b,d+f.length]};cAutocomplete.prototype.filterOptions=function(a){if(this.hActiveSelection&&!a){this.hActiveSelection.className=""}if(typeof a=="undefined"){a=false}var b=document.getElementById(this.sInputId);var c=this.getStringForAutocompletion(this.sActiveValue,this.nInsertPoint);if(a){c=""}var d=document.getElementById(this.sListId);var e=d.getElementsByTagName("UL")[0];var f=e.childNodes.length;var g=null;var h=0;var i=e.parentNode;var e=e.parentNode.removeChild(e);var j=e.childNodes;this.nItemsDisplayed=0;if(c.length==0){for(var k=0;k<f;k++){if(this.formatOptions){j[k].childNodes[0].innerHTML=this.formatOptions(j[k].childNodes[0].realText,k)}j[k].style.display="block"}h=f;if(f>0){this.nFirstDisplayed=0;this.nLastDisplayed=f-1}else{this.nFirstDisplayed=this.nLastDisplayed=-1}var l=this.getInsertPos(this.sActiveValue,this.nInsertPoint,c);this.nLastMatchLength=l[0]}else{this.nFirstDisplayed=this.nLastDisplayed=-1;c=c.toLowerCase();var m=false;if(this.bSorted&&this.bMatchBegin){var n=this.binarySearch(c);for(var k=0;k<f;k++){j[k].style.display="none";if(k>=n&&!m){if(!m&&this.aSearchData[k].indexOf(c)!=0){m=true;continue}if(this.formatOptions){j[k].childNodes[0].innerHTML=this.formatOptions(j[k].childNodes[0].realText,k)}j[k].style.display="block";h++;if(this.nFirstDisplayed<0){this.nFirstDisplayed=k}this.nLastDisplayed=k}}}else{for(var k=0;k<f;k++){j[k].style.display="none";if(this.bMatchBegin&&this.aSearchData[k].indexOf(c)==0||!this.bMatchBegin&&this.aSearchData[k].indexOf(c)>=0){if(this.formatOptions){j[k].childNodes[0].innerHTML=this.formatOptions(j[k].childNodes[0].realText,k)}j[k].style.display="block";h++;if(this.nFirstDisplayed<0){this.nFirstDisplayed=k}this.nLastDisplayed=k}}}if(h>0){var l=this.getInsertPos(this.sActiveValue,this.nInsertPoint,c);this.nLastMatchLength=l[0]}}i.appendChild(e);this.nItemsDisplayed=h};cAutocomplete.prototype.hideOptions=function(){var a=document.getElementById(this.sListId);a.style.visibility="hidden";a.style.display="none";cAutocomplete.hListDisplayed=null};cAutocomplete.prototype.markAutocompletedValue=function(){var a=document.getElementById(this.sInputId);var b=this.hActiveSelection.realText;if(this.bMatchSubstring){var c=this.getInsertPos(this.sLastActiveValue,this.nInsertPoint,b);var d=c[0];var e=c[1]}else{var d=this.nInsertPoint;var e=b.length}this.nStartAC=d;this.nEndAC=e;if(this.hMarkRangeTimeout!=null){clearTimeout(this.hMarkRangeTimeout)}this.hMarkRangeTimeout=setTimeout(function(){cAutocomplete.markInputRange2(a.id)},cAutocomplete.CN_MARK_TIMEOUT)};cAutocomplete.prototype.selectOptionByIndex=function(a){if(this.bListUpdated){this.createList()}var b=document.getElementById(this.sListId);var c=b.getElementsByTagName("UL")[0];var d=c.childNodes.length;if(a>=0&&a<d){this.selectOption(c.childNodes[a].getElementsByTagName("A")[0])}};cAutocomplete.prototype.selectOptionByValue=function(a){if(this.bListUpdated){this.createList()}a=a.toLowerCase();var b=document.getElementById(this.sListId);var c=b.getElementsByTagName("UL")[0];var d=c.childNodes.length;var e=-1;for(var f=0;f<d;f++){if(this.aSearchData[f].indexOf(a)==0){e=f}}if(e>=0){this.selectOption(c.childNodes[e].getElementsByTagName("A")[0])}};cAutocomplete.prototype.selectOption=function(a){if(this.hActiveSelection){if(this.hActiveSelection==a){return}else{this.hActiveSelection.className=""}}this.hActiveSelection=a;var b=document.getElementById(this.sInputId);if(this.hActiveSelection!=null){if(this.sHiddenInputId!=null){if(this.bMatchSubstring){document.getElementById(this.sHiddenInputId).value=this.hActiveSelection.getAttribute("itemvalue")}else{document.getElementById(this.sHiddenInputId).value=this.hActiveSelection.getAttribute("itemvalue")}}this.hActiveSelection.className="selected";if(this.bAutoComplete){b.value=this.insertString(this.sLastActiveValue,this.nInsertPoint,this.hActiveSelection.realText);this.bAutocompleted=true;this.markAutocompletedValue()}else{var c=this.getInsertPos(this.sLastActiveValue,this.nInsertPoint,this.hActiveSelection.realText);b.value=this.insertString(this.sActiveValue,this.nInsertPoint,this.hActiveSelection.realText);cAutocomplete.setInputCaretPosition(b,c[1])}this.sActiveValue=b.value;if(this.onSelect){this.onSelect()}}else{b.value=this.sActiveValue;cAutocomplete.setInputCaretPosition(b,this.nInsertPoint)}};cAutocomplete.prototype.deselectOption=function(){if(this.hActiveSelection!=null){this.hActiveSelection.className="";this.hActiveSelection=null}};cAutocomplete.prototype.clearList=function(){this.hideOptions();this.bListDisplayed=false};cAutocomplete.prototype.getPrevDisplayedItem=function(a){if(a==null){var b=document.getElementById(this.sListId);a=b.getElementsByTagName("UL")[0].childNodes.item(b.getElementsByTagName("UL")[0].childNodes.length-1)}else{a=getPrevNodeSibling(a.parentNode)}while(a!=null){if(a.style.display=="block"){return a}a=a.previousSibling}return null};cAutocomplete.prototype.getNextDisplayedItem=function(a){if(a==null){var b=document.getElementById(this.sListId);a=b.getElementsByTagName("UL")[0].childNodes.item(0)}else{a=getNextNodeSibling(a.parentNode)}while(a!=null){if(a.style.display=="block"){return a}a=a.nextSibling}return null};cAutocomplete.onInputKeyDown=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;var c=b.hAutocomplete;var d=document.getElementById(c.sListId);var e=document.getElementById(c.sInputId);var f=d.getElementsByTagName("UL")[0];var g=getParentByTagName(b,"A");if(d!=null&&c.bListDisplayed){var h=null;var i=null;if(a.keyCode==13||a.keyCode==27){var j=a.keyCode==13?true:false;c.clearList()}if(a.keyCode==38){i=c.getPrevDisplayedItem(c.hActiveSelection);if(i!=null){c.selectOption(i.childNodes.item(0));if(c.nItemsDisplayed>cAutocomplete.CN_NUMBER_OF_LINES){if(f.scrollTop<5&&i.offsetTop>f.offsetHeight){f.scrollTop=f.scrollHeight-f.offsetHeight}if(i.offsetTop-f.scrollTop<0){f.scrollTop-=i.offsetHeight}}}else{c.selectOption(null)}}else if(a.keyCode==40){i=c.getNextDisplayedItem(c.hActiveSelection);if(i!=null){c.selectOption(i.childNodes.item(0));if(c.nItemsDisplayed>cAutocomplete.CN_NUMBER_OF_LINES){if(f.scrollTop>0&&f.scrollTop>i.offsetTop){f.scrollTop=0}if(Math.abs(i.offsetTop-f.scrollTop-f.offsetHeight)<5){f.scrollTop+=i.offsetHeight}}}else{c.selectOption(null)}}}if(e.form){e.form.bLocked=true}if(a.keyCode==13||a.keyCode==27||a.keyCode==38||a.keyCode==40){if(a.preventDefault){a.preventDefault()}a.cancelBubble=true;a.returnValue=false;return false}};cAutocomplete.onInputKeyPress=function(a){if(a.keyCode==13||a.keyCode==38||a.keyCode==40){if(a.preventDefault){a.preventDefault()}a.cancelBubble=true;a.returnValue=false;return false}};cAutocomplete.onInputKeyUp=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;var c=b.hAutocomplete;var d=document.getElementById(c.sInputId);switch(a.keyCode){case 8:if(c.bAutoComplete&&c.bAutocompleted){c.bAutocompleted=false;return false}break;case 38:case 40:if(c.bListDisplayed){if(a.preventDefault){a.preventDefault()}a.cancelBubble=true;a.returnValue=false;return false}break;case 13:case 32:case 46:case 35:case 36:break;default:if(a.keyCode<48){if(a.preventDefault){a.preventDefault()}a.cancelBubble=true;a.returnValue=false;return false}break}if(c.hMarkRangeTimeout!=null){clearTimeout(c.hMarkRangeTimeout)}if(c.hShowTimeout){clearTimeout(c.hShowTimeout);c.hShowTimeout=null}var e=c.bRemoteList?cAutocomplete.CN_REMOTE_SHOW_TIMEOUT:cAutocomplete.CN_SHOW_TIMEOUT;c.hShowTimeout=setTimeout(function(){c.prepareList()},e)};cAutocomplete.onInputBlur=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;if(b.form){b.form.bLocked=false}var c=b.hAutocomplete;if(!c.hClearTimeout){c.hClearTimeout=setTimeout(function(){c.clearList()},cAutocomplete.CN_CLEAR_TIMEOUT)}};cAutocomplete.onInputFocus=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;var c=b.hAutocomplete;if(c.hClearTimeout){clearTimeout(c.hClearTimeout);c.hClearTimeout=null}};cAutocomplete.saveCaretPosition=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;var c=b.hAutocomplete;var d=document.getElementById(c.sInputId);if(a.keyCode!=38&&a.keyCode!=40){c.nInsertPoint=cAutocomplete.getInputCaretPosition(d)}};cAutocomplete.getInputCaretPosition=function(a){if(typeof a.selectionStart!="undefined"){if(a.selectionStart==a.selectionEnd){return a.selectionStart}else{return a.selectionStart}}else if(a.createTextRange){var b=document.selection.createRange();if(a.tagName.toLowerCase()=="textarea"){var c=b.duplicate();var d=b.duplicate();b.moveToElementText(a);c.setEndPoint("StartToStart",b);return c.text.length}else{b.moveStart("character",-1*a.value.length);var e=b.text.length;return e}}return null};cAutocomplete.setInputCaretPosition=function(a,b){if(a.setSelectionRange){a.setSelectionRange(b,b)}else if(a.createTextRange){var c=a.createTextRange();c.moveStart("character",b);c.moveEnd("character",b);c.collapse(true);c.select()}};cAutocomplete.markInputRange=function(a,b,c){if(a.setSelectionRange){a.focus();a.setSelectionRange(b,c)}else if(a.createTextRange){var d=a.createTextRange();d.collapse(true);d.moveStart("character",b);d.moveEnd("character",c-b);d.select()}};cAutocomplete.markInputRange2=function(a){var b=document.getElementById(a);var c=b.hAutocomplete.nStartAC;var d=b.hAutocomplete.nEndAC;cAutocomplete.markInputRange(b,c,d)};cAutocomplete.onListBlur=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;b=getParentByProperty(b,"className","autocomplete_holder");var c=b.hAutocomplete;if(!c.hClearTimeout){c.hClearTimeout=setTimeout(function(){c.clearList()},cAutocomplete.CN_CLEAR_TIMEOUT)}};cAutocomplete.onListFocus=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;b=getParentByProperty(b,"className","autocomplete_holder");var c=b.hAutocomplete;if(c.hClearTimeout){clearTimeout(c.hClearTimeout);c.hClearTimeout=null}};cAutocomplete.onItemClick=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;var c=getParentByProperty(b,"className","autocomplete_holder");var d=getParentByTagName(b,"A");if(c!=null){var e=c.hAutocomplete;e.selectOption(d);document.getElementById(e.sInputId).focus();e.clearList()}if(a.preventDefault){a.preventDefault()}a.cancelBubble=true;a.returnValue=false;return false};cAutocomplete.onButtonClick=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;var c=b.hAutocomplete;var d=document.getElementById(c.sInputId);if(d.disabled){return}c.prepareList(true);var d=document.getElementById(c.sInputId);d.focus()};cAutocomplete.onFormSubmit=function(a){if(a==null){a=window.event}var b=a.srcElement?a.srcElement:a.originalTarget;if(b.bLocked){b.bLocked=false;a.returnValue=false;if(a.preventDefault){a.preventDefault()}return false}}
