var ajaxBox_offsetX=0;var ajaxBox_offsetY=0;var ajax_list_externalFile="backend/ajax-autocomplete.php";var minimumLettersBeforeLookup=1;var ajax_list_objects=new Array();var ajax_list_cachedLists=new Array();var ajax_list_activeInput=false;var ajax_list_activeItem;var ajax_list_optionDivFirstItem=false;var ajax_list_currentLetters=new Array();var ajax_optionDiv=false;var ajax_optionDiv_iframe=false;var ajax_list_MSIE=false;if(navigator.userAgent.indexOf("MSIE")>=0&&navigator.userAgent.indexOf("Opera")<0){ajax_list_MSIE=true}var currentListIndex=0;function ajax_getTopPos(a){var b=a.offsetTop;while((a=a.offsetParent)!=null){b+=a.offsetTop}return b}function ajax_list_cancelEvent(){return false}function ajax_getLeftPos(a){var b=a.offsetLeft;while((a=a.offsetParent)!=null){b+=a.offsetLeft}return b}function ajax_option_setValue(c,b){if(!b){b=this}var a=b.innerHTML;if(ajax_list_MSIE){a=b.innerText}else{a=b.textContent}if(!a){a=b.innerHTML}ajax_list_activeInput.value=a;if(document.getElementById(ajax_list_activeInput.name+"_hidden")){document.getElementById(ajax_list_activeInput.name+"_hidden").value=b.id}ajax_options_hide()}function ajax_options_hide(){if(ajax_optionDiv){ajax_optionDiv.style.display="none"}if(ajax_optionDiv_iframe){ajax_optionDiv_iframe.style.display="none"}}function ajax_options_rollOverActiveItem(a,b){if(ajax_list_activeItem){ajax_list_activeItem.className="optionDiv"}a.className="optionDivSelected";ajax_list_activeItem=a;if(b){if(ajax_list_activeItem.offsetTop>ajax_optionDiv.offsetHeight){ajax_optionDiv.scrollTop=ajax_list_activeItem.offsetTop-ajax_optionDiv.offsetHeight+ajax_list_activeItem.offsetHeight+2}if(ajax_list_activeItem.offsetTop<ajax_optionDiv.scrollTop){ajax_optionDiv.scrollTop=0}}}function ajax_option_list_buildList(f,b){ajax_optionDiv.innerHTML="";ajax_list_activeItem=false;if(ajax_list_cachedLists[b][f.toLowerCase()].length<=1){ajax_options_hide();return}ajax_list_optionDivFirstItem=false;var d=false;for(var c=0;c<ajax_list_cachedLists[b][f.toLowerCase()].length;c++){if(ajax_list_cachedLists[b][f.toLowerCase()][c].length==0){continue}d=true;var e=document.createElement("DIV");var a=ajax_list_cachedLists[b][f.toLowerCase()][c].split(/###/gi);if(ajax_list_cachedLists[b][f.toLowerCase()].length==1&&ajax_list_activeInput.value==a[0]){ajax_options_hide();return}e.innerHTML=a[a.length-1];e.id=a[0];e.className="optionDiv";e.onmouseover=function(){ajax_options_rollOverActiveItem(this,false)};e.onclick=ajax_option_setValue;if(!ajax_list_optionDivFirstItem){ajax_list_optionDivFirstItem=e}ajax_optionDiv.appendChild(e)}if(d){ajax_optionDiv.style.display="block";if(ajax_optionDiv_iframe){ajax_optionDiv_iframe.style.display=""}ajax_options_rollOverActiveItem(ajax_list_optionDivFirstItem,true)}}function ajax_option_list_showContent(c,a,b,f){if(f!=currentListIndex){return}var g=a.value;var d=ajax_list_objects[c].response;var e=d.split("|");ajax_list_cachedLists[b][g.toLowerCase()]=e;ajax_option_list_buildList(g,b)}function ajax_option_resize(a){ajax_optionDiv.style.top=(ajax_getTopPos(a)+a.offsetHeight+ajaxBox_offsetY)+"px";ajax_optionDiv.style.left=(ajax_getLeftPos(a)+ajaxBox_offsetX)+"px";if(ajax_optionDiv_iframe){ajax_optionDiv_iframe.style.left=ajax_optionDiv.style.left;ajax_optionDiv_iframe.style.top=ajax_optionDiv.style.top}}function ajax_showOptions(b,c,d){if(d.keyCode==13||d.keyCode==9){return}if(ajax_list_currentLetters[b.name]==b.value){return}if(!ajax_list_cachedLists[c]){ajax_list_cachedLists[c]=new Array()}ajax_list_currentLetters[b.name]=b.value;if(!ajax_optionDiv){ajax_optionDiv=document.createElement("DIV");ajax_optionDiv.id="ajax_listOfOptions";document.body.appendChild(ajax_optionDiv);if(ajax_list_MSIE){ajax_optionDiv_iframe=document.createElement("IFRAME");ajax_optionDiv_iframe.border="0";ajax_optionDiv_iframe.style.width=ajax_optionDiv.clientWidth+"px";ajax_optionDiv_iframe.style.height=ajax_optionDiv.clientHeight+"px";ajax_optionDiv_iframe.id="ajax_listOfOptions_iframe";document.body.appendChild(ajax_optionDiv_iframe)}var j=document.getElementsByTagName("INPUT");for(var l=0;l<j.length;l++){if(!j[l].onkeyup){j[l].onfocus=ajax_options_hide}}var g=document.getElementsByTagName("SELECT");for(var l=0;l<g.length;l++){g[l].onfocus=ajax_options_hide}var h=document.body.onkeydown;if(typeof h!="function"){document.body.onkeydown=ajax_option_keyNavigation}else{document.body.onkeydown=function(){h();ajax_option_keyNavigation()}}var f=document.body.onresize;if(typeof f!="function"){document.body.onresize=function(){ajax_option_resize(b)}}else{document.body.onresize=function(){f();ajax_option_resize(b)}}}if(b.value.length<minimumLettersBeforeLookup){ajax_options_hide();return}ajax_optionDiv.style.top=(ajax_getTopPos(b)+b.offsetHeight+ajaxBox_offsetY)+"px";ajax_optionDiv.style.left=(ajax_getLeftPos(b)+ajaxBox_offsetX)+"px";if(ajax_optionDiv_iframe){ajax_optionDiv_iframe.style.left=ajax_optionDiv.style.left;ajax_optionDiv_iframe.style.top=ajax_optionDiv.style.top}ajax_list_activeInput=b;ajax_optionDiv.onselectstart=ajax_list_cancelEvent;currentListIndex++;if(ajax_list_cachedLists[c][b.value.toLowerCase()]){ajax_option_list_buildList(b.value,c,currentListIndex)}else{var m=currentListIndex/1;ajax_optionDiv.innerHTML="";var k=ajax_list_objects.length;ajax_list_objects[k]=new sack();var a=ajax_list_externalFile+"?"+c+"&distinct=1&letters="+b.value.replace(" ","+");ajax_list_objects[k].requestFile=a;ajax_list_objects[k].onCompletion=function(){ajax_option_list_showContent(k,b,c,m)};ajax_list_objects[k].runAJAX()}}function ajax_option_keyNavigation(a){if(document.all){a=event}if(!ajax_optionDiv){return}if(ajax_optionDiv.style.display=="none"){return}if(a.keyCode==38){if(!ajax_list_activeItem){return}if(ajax_list_activeItem&&!ajax_list_activeItem.previousSibling){return}ajax_options_rollOverActiveItem(ajax_list_activeItem.previousSibling,true)}if(a.keyCode==40){if(!ajax_list_activeItem){ajax_options_rollOverActiveItem(ajax_list_optionDivFirstItem,true)}else{if(!ajax_list_activeItem.nextSibling){return}ajax_options_rollOverActiveItem(ajax_list_activeItem.nextSibling,true)}}if(a.keyCode==13||a.keyCode==9){if(ajax_list_activeItem&&ajax_list_activeItem.className=="optionDivSelected"){ajax_option_setValue(false,ajax_list_activeItem)}if(a.keyCode==13){return false}else{return true}}if(a.keyCode==27){ajax_options_hide()}}document.documentElement.onclick=autoHideList;function autoHideList(a){if(document.all){a=event}if(a.target){source=a.target}else{if(a.srcElement){source=a.srcElement}}if(source.nodeType==3){source=source.parentNode}if(source.tagName.toLowerCase()!="input"&&source.tagName.toLowerCase()!="textarea"){ajax_options_hide()}}function sack(file){this.xmlhttp=null;this.resetData=function(){this.method="POST";this.queryStringSeparator="?";this.argumentSeparator="&";this.URLString="";this.encodeURIString=true;this.execute=false;this.element=null;this.elementObj=null;this.requestFile=file;this.vars=new Object();this.responseStatus=new Array(2)};this.resetFunctions=function(){this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onError=function(){};this.onFail=function(){}};this.reset=function(){this.resetFunctions();this.resetData()};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e1){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e2){this.xmlhttp=null}}if(!this.xmlhttp){if(typeof XMLHttpRequest!="undefined"){this.xmlhttp=new XMLHttpRequest()}else{this.failed=true}}};this.setVar=function(name,value){this.vars[name]=Array(value,false)};this.encVar=function(name,value,returnvars){if(true==returnvars){return Array(encodeURIComponent(name),encodeURIComponent(value))}else{this.vars[encodeURIComponent(name)]=Array(encodeURIComponent(value),true)}};this.processURLString=function(string,encode){encoded=encodeURIComponent(this.argumentSeparator);regexp=new RegExp(this.argumentSeparator+"|"+encoded);varArray=string.split(regexp);for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(true==encode){this.encVar(urlVars[0],urlVars[1])}else{this.setVar(urlVars[0],urlVars[1])}}};this.createURLString=function(urlstring){if(this.encodeURIString&&this.URLString.length){this.processURLString(this.URLString,true)}if(urlstring){if(this.URLString.length){this.URLString+=this.argumentSeparator+urlstring}else{this.URLString=urlstring}}this.setVar("rndval",new Date().getTime());urlstringtemp=new Array();for(key in this.vars){if(false==this.vars[key][1]&&true==this.encodeURIString){encoded=this.encVar(key,this.vars[key][0],true);delete this.vars[key];this.vars[encoded[0]]=Array(encoded[1],true);key=encoded[0]}urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0]}if(urlstring){this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator)}else{this.URLString+=urlstringtemp.join(this.argumentSeparator)}};this.runResponse=function(){eval(this.response)};this.runAJAX=function(urlstring){if(this.failed){this.onFail()}else{this.createURLString(urlstring);if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var self=this;if(this.method=="GET"){totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;this.xmlhttp.open(this.method,totalurlstring,true)}else{this.xmlhttp.open(this.method,this.requestFile,true);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(e){}}this.xmlhttp.onreadystatechange=function(){switch(self.xmlhttp.readyState){case 1:self.onLoading();break;case 2:self.onLoaded();break;case 3:self.onInteractive();break;case 4:self.response=self.xmlhttp.responseText;self.responseXML=self.xmlhttp.responseXML;self.responseStatus[0]=self.xmlhttp.status;self.responseStatus[1]=self.xmlhttp.statusText;if(self.execute){self.runResponse()}if(self.elementObj){elemNodeName=self.elementObj.nodeName;elemNodeName.toLowerCase();if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){self.elementObj.value=self.response}else{self.elementObj.innerHTML=self.response}}if(self.responseStatus[0]=="200"){self.onCompletion()}else{self.onError()}self.URLString="";break}};this.xmlhttp.send(this.URLString)}}};this.reset();this.createAJAX()};
