var ajax_disableCaching=true;
var ajaxBox_offsetX=0;
var ajaxBox_offsetY=0;
var ajax_list_externalFile="/autocomplete/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(_1){
var _2=_1.offsetTop;
while((_1=_1.offsetParent)!=null){
_2+=_1.offsetTop;
}
return _2;
}
function ajax_list_cancelEvent(){
return false;
}
function ajax_getLeftPos(_3){
var _4=_3.offsetLeft;
while((_3=_3.offsetParent)!=null){
_4+=_3.offsetLeft;
}
return _4;
}
function ajax_option_setValue(e,_6){
if(!_6){
_6=this;
}
var _7=_6.innerHTML;
if(ajax_list_MSIE){
_7=_6.innerText;
}else{
_7=_6.textContent;
}
if(!_7){
_7=_6.innerHTML;
}
ajax_list_activeInput.value=_6.id;
if(document.getElementById(ajax_list_activeInput.name+"_hidden")){
document.getElementById(ajax_list_activeInput.name+"_hidden").value=_6.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(_8,_9){
if(ajax_list_activeItem){
ajax_list_activeItem.className="optionDiv";
}
_8.className="optionDivSelected";
ajax_list_activeItem=_8;
if(_9){
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(_a,_b){
ajax_optionDiv.innerHTML="";
ajax_list_activeItem=false;
if(ajax_list_cachedLists[_b][_a.toLowerCase()].length<=1){
ajax_options_hide();
return;
}
ajax_list_optionDivFirstItem=false;
var _c=false;
for(var no=0;no<ajax_list_cachedLists[_b][_a.toLowerCase()].length;no++){
if(ajax_list_cachedLists[_b][_a.toLowerCase()][no].length==0){
continue;
}
_c=true;
var _e=document.createElement("DIV");
var _f=ajax_list_cachedLists[_b][_a.toLowerCase()][no].split(/###/gi);
if(ajax_list_cachedLists[_b][_a.toLowerCase()].length==1&&ajax_list_activeInput.value==_f[0]){
ajax_options_hide();
return;
}
_e.innerHTML=_f[_f.length-1];
_e.id=_f[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(_c){
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(_10,_11,_12,_13){
if(_13!=currentListIndex){
return;
}
var _14=_11.value;
var _15=ajax_list_objects[_10].response;
var _16=_15.split("|");
ajax_list_cachedLists[_12][_14.toLowerCase()]=_16;
ajax_option_list_buildList(_14,_12);
}
function ajax_option_resize(_17){
ajax_optionDiv.style.top=(ajax_getTopPos(_17)+_17.offsetHeight+ajaxBox_offsetY)+"px";
ajax_optionDiv.style.left=(ajax_getLeftPos(_17)+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(_18,_19,e){
if(ajax_disableCaching){
ajax_list_cachedLists=new Array();
}
if(e.keyCode==13||e.keyCode==9){
return;
}
if(ajax_list_currentLetters[_18.name]==_18.value){
return;
}
if(!ajax_list_cachedLists[_19]){
ajax_list_cachedLists[_19]=new Array();
}
ajax_list_currentLetters[_18.name]=_18.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 _1b=document.getElementsByTagName("INPUT");
for(var no=0;no<_1b.length;no++){
if(!_1b[no].onkeyup){
_1b[no].onfocus=ajax_options_hide;
}
}
var _1d=document.getElementsByTagName("SELECT");
for(var no=0;no<_1d.length;no++){
_1d[no].onfocus=ajax_options_hide;
}
var _1f=document.body.onkeydown;
if(typeof _1f!="function"){
document.body.onkeydown=ajax_option_keyNavigation;
}else{
document.body.onkeydown=function(){
_1f();
ajax_option_keyNavigation();
};
}
var _20=document.body.onresize;
if(typeof _20!="function"){
document.body.onresize=function(){
ajax_option_resize(_18);
};
}else{
document.body.onresize=function(){
_20();
ajax_option_resize(_18);
};
}
}
if(_18.value.length<minimumLettersBeforeLookup){
ajax_options_hide();
return;
}
ajax_optionDiv.style.top=(ajax_getTopPos(_18)+_18.offsetHeight+ajaxBox_offsetY)+"px";
ajax_optionDiv.style.left=(ajax_getLeftPos(_18)+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=_18;
ajax_optionDiv.onselectstart=ajax_list_cancelEvent;
currentListIndex++;
if(ajax_list_cachedLists[_19][_18.value.toLowerCase()]){
ajax_option_list_buildList(_18.value,_19,currentListIndex);
}else{
var _21=currentListIndex/1;
ajax_optionDiv.innerHTML="";
var _22=ajax_list_objects.length;
ajax_list_objects[_22]=new sack();
var url=ajax_list_externalFile+"?"+_19+"=1&letters="+_18.value.replace(" ","+");
ajax_list_objects[_22].requestFile=url;
ajax_list_objects[_22].onCompletion=function(){
ajax_option_list_showContent(_22,_18,_19,_21);
};
ajax_list_objects[_22].runAJAX();
}
}
function ajax_option_keyNavigation(e){
if(document.all){
e=event;
}
if(!ajax_optionDiv){
return;
}
if(ajax_optionDiv.style.display=="none"){
return;
}
if(e.keyCode==38){
if(!ajax_list_activeItem){
return;
}
if(ajax_list_activeItem&&!ajax_list_activeItem.previousSibling){
return;
}
ajax_options_rollOverActiveItem(ajax_list_activeItem.previousSibling,true);
return false;
}
if(e.keyCode==40){
if(!ajax_list_activeItem){
ajax_options_rollOverActiveItem(ajax_list_optionDivFirstItem,true);
return false;
}else{
if(!ajax_list_activeItem.nextSibling){
return;
}
ajax_options_rollOverActiveItem(ajax_list_activeItem.nextSibling,true);
return false;
}
}
if(e.keyCode==13||e.keyCode==9){
if(ajax_list_activeItem&&ajax_list_activeItem.className=="optionDivSelected"){
ajax_option_setValue(false,ajax_list_activeItem);
}
if(e.keyCode==13){
return false;
}else{
return true;
}
}
if(e.keyCode==27){
ajax_options_hide();
}
}
document.documentElement.onclick=autoHideList;
function autoHideList(e){
if(document.all){
e=event;
}
if(e.target){
source=e.target;
}else{
if(e.srcElement){
source=e.srcElement;
}
}
if(source.nodeType==3){
source=source.parentNode;
}
if(source.tagName.toLowerCase()!="input"&&source.tagName.toLowerCase()!="textarea"){
ajax_options_hide();
}
}
function sack(_26){
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=_26;
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(_27,_28){
this.vars[_27]=Array(_28,false);
};
this.encVar=function(_29,_2a,_2b){
if(true==_2b){
return Array(encodeURIComponent(_29),encodeURIComponent(_2a));
}else{
this.vars[encodeURIComponent(_29)]=Array(encodeURIComponent(_2a),true);
}
};
this.processURLString=function(_2c,_2d){
encoded=encodeURIComponent(this.argumentSeparator);
regexp=new RegExp(this.argumentSeparator+"|"+encoded);
varArray=_2c.split(regexp);
for(i=0;i<varArray.length;i++){
urlVars=varArray[i].split("=");
if(true==_2d){
this.encVar(urlVars[0],urlVars[1]);
}else{
this.setVar(urlVars[0],urlVars[1]);
}
}
};
this.createURLString=function(_2e){
if(this.encodeURIString&&this.URLString.length){
this.processURLString(this.URLString,true);
}
if(_2e){
if(this.URLString.length){
this.URLString+=this.argumentSeparator+_2e;
}else{
this.URLString=_2e;
}
}
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(_2e){
this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator);
}else{
this.URLString+=urlstringtemp.join(this.argumentSeparator);
}
};
this.runResponse=function(){
eval(this.response);
};
this.runAJAX=function(_2f){
if(this.failed){
this.onFail();
}else{
this.createURLString(_2f);
if(this.element){
this.elementObj=document.getElementById(this.element);
}
if(this.xmlhttp){
var _30=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(_30.xmlhttp.readyState){
case 1:
_30.onLoading();
break;
case 2:
_30.onLoaded();
break;
case 3:
_30.onInteractive();
break;
case 4:
_30.response=_30.xmlhttp.responseText;
_30.responseXML=_30.xmlhttp.responseXML;
_30.responseStatus[0]=_30.xmlhttp.status;
_30.responseStatus[1]=_30.xmlhttp.statusText;
if(_30.execute){
_30.runResponse();
}
if(_30.elementObj){
elemNodeName=_30.elementObj.nodeName;
elemNodeName.toLowerCase();
if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){
_30.elementObj.value=_30.response;
}else{
_30.elementObj.innerHTML=_30.response;
}
}
if(_30.responseStatus[0]=="200"){
_30.onCompletion();
}else{
_30.onError();
}
_30.URLString="";
break;
}
};
this.xmlhttp.send(this.URLString);
}
}
};
this.reset();
this.createAJAX();
}

