var RLIS={token:typeof(RLIS_TOKEN)!='undefined'?RLIS_TOKEN:'sJskhasRzcoxvybCNK4OhwxaNdCPknmFgEiHpULZO_zyvsHp5VrhSVhgjWEzNScKCl6bazHiX7MfEQnnwscrCA..',baseRlisApiUrl:'https://qa-gis.oregonmetro.gov/rlisapi2/',baseAgsServicesUrl:'https://qa-gis.oregonmetro.gov/arcgis/rest/services/',debugging:!0,eft:!1,version:"xx",userToken:"",b:!1,n:9e3,locator:"RLIS_Locator_Pro",poiLocator:"POI_Locator_Pro",taxlotLocator:"Taxlot_Locator_Pro",zipcodeLocator:"Zipcode_Locator_Pro",suggestLocator:"RLIS_Locator_Pro",rNumberLocator:"Taxlot_R_Locator_Pro",_inputData:null,intervalId:null,j:"undefined"!=typeof JSON,patterns:{zipcode:/^\d{5}(?:-\d{4})?$/,intersection:/\b(?:N|S|E|W|NE|NW|SE|SW)?\s*\d{1,3}[a-zA-Z]*\s+(?:and|&)\s+(?:N|S|E|W|NE|NW|SE|SW)?\s*\w+/i,rNumber:/^R\d+(?:,\s*.+)?$/,poi:/^(?!\d{1,6}\s)([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)(?:,\s*([A-Z][a-z]+(?:\s[A-Z][a-z]+)*)(?:,\s*([A-Z]{2}))?)?$/,taxlot:/^\d\d(W|E)|\d(N|S)\d.+$/},selectLocator:function(t,e){return this.patterns.zipcode.test(t)?this.zipcodeLocator:this.patterns.intersection.test(t)?e:this.patterns.rNumber.test(t)?this.rNumberLocator:this.patterns.poi.test(t)?this.poiLocator:this.patterns.taxlot.test(t)?this.taxlotLocator:e},_XssAJAX:function(controller,data,method,callback){var that=this,_x,isIE10=10===document.documentMode;_x="undefined"==typeof XDomainRequest||isIE10?new XMLHttpRequest:new XDomainRequest,void 0!==_x.withCredentials&&(this.b=!0);let url="";controller.includes("Batch",0)?controller.includes("Batch",0)&&(url="GET"==method?this.baseRlisApiUrl+controller+"/?"+data:this.baseRlisApiUrl+controller+"/"):url="GET"==method?this.baseAgsServicesUrl+controller+"/?"+data:this.baseAgsServicesUrl+controller+"/",_x.open(method,url),_x.onload=function(){clearTimeout(_o);var g=_x.responseText;callback(this.j?JSON.parse(g):eval("("+g+")"))},this.b&&_x.setRequestHeader&&_x.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),_x.send(data);var _o=setTimeout(function(){_x.abort(),callback("Server did not respond",!0)},that.n)},Geocode:function(t,e,s){if(this.debugging&&console.log("%c Begin Geocode","background: #bada55; color: #111"),!t||0==t.trim().length)return this.debugging&&console.log("%c No address received","background: #FF0000; color: #111"),e({error:!0,message:"Please enter a valid address"});this.debugging&&console.log("%c type of fields is "+typeof s,"background: #bada55; color: #111"),void 0!==s&&0!=s.trim().length||(s=""),this.debugging&&console.log("%c fields="+s,"background: #bada55; color: #111");const i=this;let r=this.selectLocator(t,this.suggestLocator);r==this.poiLocator&&(i.fields="");this.debugging&&console.log("%c Using this locator: "+r,"background: #bada55; color: #111");const o=async function(s){if(void 0===s.candidates||null===s.candidates)return void e(null,s.error);var o={status:"failure",score:"",locator:"",input:t,fullAddress:"",house:"",side:"",preDir:"",preType:"",streetName:"",sufType:"",sufDir:"",city:"",state:"",zip:"",ORSP_x:"",ORSP_y:"",type:"",unitNumber:"",matches:"",lat:0,lng:0};if(0==s.candidates.length&&"RLIS_Locator_Pro"===r&&1==i.eft){this.debugging&&console.log("%c Falling thru to the Esri Geocoder","background: #bada55; color: #111");let e=await i._esriLocateInput(t);o.locator="ArcGISOnline",void 0!==e&&null!=e&&"success"==e.status&&(o.status="success",o.fullAddress=e.fullAddress,o.score=e.score,o.lat=e.lat,o.lng=e.lng,o.house=e.house,o.side=e.side,o.preDir=e.preDir,o.preType=e.preType,o.streetName=e.streetName,o.sufType=e.sufType,o.sufDir=e.sufDir,o.city=e.city,o.state=e.state,o.zip=e.zip,o.type=e.type,o.unitNumber=e.unitNumber,o.ORSP_x=.1,o.ORSP_y=.1,o.matches=e.matches)}else if(s.candidates.length>0){let e=s.candidates[0];r==i.locator?"RLIS_Locator"==r?(o.status="success",o.score=e.score,o.locator=r,o.input=t,o.fullAddress=e.attributes.Match_addr,o.house=e.attributes.House,o.side=e.attributes.Side,o.preDir=e.attributes.PreDir,o.preType=e.attributes.PreType,o.streetName=e.attributes.StreetName,o.sufType=e.attributes.SufType,o.sufDir=e.attributes.SufDir,o.city=e.attributes.City,o.state=e.attributes.State,o.zip=e.attributes.ZIP,o.ORSP_x=e.attributes?i._safeToFixed(e.attributes.Disp_Lon):null,o.ORSP_y=e.attributes?i._safeToFixed(e.attributes.Disp_Lat):null,o.type=e.attributes.Addr_type,o.unitNumber=e.attributes.UnitNumber,o.matches=s.candidates.length,o.lat=e.location?i._safeToFixed(e.location.y):null,o.lng=e.location?i._safeToFixed(e.location.x):null):"RLIS_Locator_Pro"==r&&(o.status="success",o.score=e.score,o.locator=r,o.input=t,o.fullAddress=e.attributes.Match_addr,o.house=e.attributes.AddNum,o.side=e.attributes.Side,o.preDir=e.attributes.StPreDir,o.preType=e.attributes.StPreType,o.streetName=e.attributes.StName,o.sufType=e.attributes.StType,o.sufDir=e.attributes.StDir,o.city=e.attributes.City,o.state=e.attributes.Region,o.zip=e.attributes.Postal,o.ORSP_x=e.attributes?i._safeToFixed(e.attributes.DisplayX):null,o.ORSP_y=e.attributes?i._safeToFixed(e.attributes.DisplayY):null,o.type=e.attributes.Addr_type,o.unitNumber=e.attributes.UnitName,o.matches=s.candidates.length,o.lat=e.location?i._safeToFixed(e.location.y):null,o.lng=e.location?i._safeToFixed(e.location.x):null):r==i.poiLocator?(o.status="success",o.score=e.score,o.fullAddress=t,o.locator=i.poiLocator,o.input=t,o.ORSP_x=e.attributes?i._safeToFixed(e.attributes.DisplayX):null,o.ORSP_y=e.attributes?i._safeToFixed(e.attributes.DisplayY):null,o.lat=e.location?i._safeToFixed(e.location.y):null,o.lng=e.location?i._safeToFixed(e.location.x):null,o.type=e.attributes.Addr_type,o.matches=s.candidates.length):r==i.zipcodeLocator?(o.status="success",o.score=e.score,o.locator=i.zipcodeLocator,o.input=t,o.fullAddress=t,o.ORSP_x=e.attributes?i._safeToFixed(e.attributes.DisplayX):null,o.ORSP_y=e.attributes?i._safeToFixed(e.attributes.DisplayY):null,o.lat=e.location?i._safeToFixed(e.location.y):null,o.lng=e.location?i._safeToFixed(e.location.x):null,o.type="Zipcode",o.matches=s.candidates.length):r==i.taxlotLocator?(o.status="success",o.score=e.score,o.locator=i.taxlotLocator,o.input=t,o.ORSP_x=e.attributes?i._safeToFixed(e.attributes.DisplayX):null,o.ORSP_y=e.attributes?i._safeToFixed(e.attributes.DisplayY):null,o.lat=e.location?i._safeToFixed(e.location.y):null,o.lng=e.location?i._safeToFixed(e.location.x):null):r==i.rNumberLocator&&(o.status="success",o.score=e.score,o.locator=i.rNumberLocator,o.input=t,o.ORSP_x=e.attributes?i._safeToFixed(e.attributes.DisplayX):null,o.ORSP_y=e.attributes?i._safeToFixed(e.attributes.DisplayY):null,o.lat=e.location?i._safeToFixed(e.location.y):null,o.lng=e.location?i._safeToFixed(e.location.x):null)}const a=performance.now();o.time=parseInt(a-n),i.debugging&&(console.log("%c Completed Forward geocode ","background: #222; color: #bada55",`${a-n} ms`),console.log(o)),e([o],null)},n=performance.now();this._XssAJAX(`locators/${r}/GeocodeServer/findAddressCandidates`,`SingleLine=${encodeURIComponent(t)}&outFields=${s}&f=json&outSR=4326&token=${this.token}`,"GET",o)},ReverseLocate:function(t,e,s,i){void 0===i&&(i="");const r=performance.now(),o=this,n=function(t){if(o.debugging){const t=performance.now();console.log("%c Completed Reverse geocode ","background: #222; color: #bada55",`${t-r} ms`)}if(void 0===t.address||null===t.address)return data=[{}],s(data,null);res=t.address,"RLIS_Locator"==o.locator?o.Geocode(`${res.Street} ${res.City},${res.State}, ${res.ZIP}`,s,i):"RLIS_Locator_Pro"==o.locator&&o.Geocode(`${res.Address} ${res.City},${res.Region}, ${res.Postal}`,s,i)};this._XssAJAX(`locators/${this.locator}/GeocodeServer/ReverseGeocode`,`location=%7B%22x%22%3A${t.x}%2C%22y%22%3A${t.y}%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D&token=${this.token}&f=pjson`,"GET",n)},ReverseQuery:function(t,e,s,i){void 0===i&&(i=""),this._XssAJAX("ReverseQuery","intersection="+e+"&lat="+t.y+"&lng="+t.x+"&fields="+i+"&token="+this.token,"GET",function(t){console.log("%c Completed Reverse Geocode ","background: #222; color: #bada55","more text"),null!==t.data?s(t.data,null):s(null,t.error)})},BatchGeocode:function(t,e,s,i,r,o){this._Batch(t,e,s,"BatchLocate",i,r||1e3,o)},BatchQueryAddress:function(t,e,s,i,r,o){this._Batch(t,e,s,"BatchQueryAddress",i,r||1e3,o)},BatchQueryPoint:function(t,e,s,i,r){this._Batch(t,0,e,"BatchQueryPoint",s,i||1e3,r)},_Batch:function(t,e,s,i,r,o,n){if(!(t.length<1)){void 0===n&&(n="");var a=t,l=this,u=o&&o>499?o:1e3;this.debugging&&console.log("%c Using this token: "+l.token,"background: #bada55; color: #111"),this._XssAJAX(i,"data="+encodeURIComponent(a)+"&token="+l.token+"&fields="+n+"&i_heart_ie="+(new Date).getTime(),"POST",function(t){l.intervalId=setInterval(function(){l._PollBatchProgress(i,t.id,s,r)},u)})}},ToCSV:function(t){if(this.debugging&&console.log("%c Inside ToCSV function ","background: #222; color: #bada55"),!Array.isArray(t)||0===t.length||"object"!=typeof t[0])return"Invalid input";let e="";for(const s of Object.keys(t[0]))e+=s+",";e=e.slice(0,-1),e+="\n";for(const s of t){for(const t of Object.keys(s)){const i=s[t];e+="string"==typeof i?"'"+i+"',":i+","}e=e.slice(0,-1),e+="\n"}return e},_PollBatchProgress:function(t,e,s,i){var r=this;this._XssAJAX(t,"id="+e+"&token="+r.token,"GET",function(t){if(t.progress>=100){if(clearInterval(r.intervalId),null===t.data)return void s(null,t.error);s(t.data,null)}i&&i(t)})},_bindRLISQUERY:function(t){return{basin:t.BASIN,censusBlockGroup:t.CENSUSBLOCKGROUP,censusBlockGroupPopulation:t.CENSUSBLOCKGROUPPOPULATION2010,censusTract:t.CENSUSTRACT.toString(),center:t.CENTER,centerType:t.CENTERTYPE,commercialHauler:t.COMMERCIALHAULER,commercialHaulerPhone:null===t.commhaulerphone?"":t.commhaulerphone,compplan:t.COMPPLAN,congressionalDistrict:t.CongressionalDistrict.toString(),county:t.RCOUNTY,DHSAddress:t.dhsAddress,DHSBranch:t.dhsBranch,DHSID:t.dhsID.toString(),DHSPhone:t.dhsPhone,dropboxProvider:t.DROPBOXPROVIDER,dropboxProviderPhone:null===t.dropboxphone?"":t.dropboxphone,elevation:"1",FEMA:100==t.FEMA?"Inside":0==t.FEMA?"Outside":"",fireDistrict:t.FIREDISTRICT,fireManagementZone:t.FMZ.toString(),houseDistrict:t.HouseDistrict.toString(),metroCouncilDistrict:null===t.METROCOUNCILDISTRICT?"N":t.METROCOUNCILDISTRICT.toLocaleString(),metroCouncilor:null===t.METROCOUNCILOR?"":t.METROCOUNCILOR.toLocaleString(),metroCouncilorEmail:null===t.METROCOUNCILOREMAIL?"":t.METROCOUNCILOREMAIL,ncelem:t.ncelem,NCESdistrictID:t.NCESDISTID.toString(),nchigh:t.nchigh,ncmiddle:t.ncmiddle,neighborhood:t.NEIGHBORHOOD,ORDeptEducationDistrict:t.ORDEPTID.toString(),parkDistrict:t.PARKDISTRICT,quadname:t.usgsquad,reserveCode:t.reservecode,reserveName:t.reservename,reserveType:t.reservetype,residentialHauler:t.RESIDENTIALHAULER,residentialHaulerPhone:null===t.reshaulerphone?"":t.reshaulerphone,schoolDistrict:t.SCHOOLDISTRICT,schoolDistrictNumber:t.SCHOOLDISTRICTNUMBER,section:t.SECTION,senateDistrict:t.SenateDistrict.toString(),sewerDistrict:t.SEWERDISTRICT,subBasin:t.SUBBASIN,subWatershed:t.SUBWATERSHED,transitDistrict:t.TRANSITDISTRICT,UGB:1==t.UGB?"Inside":0==t.UGB?"Outside":"",voterPrecinct:t.VOTERPRECINCT.toString(),waterDistrict:t.WATERDISTRICT,watershed:t.WATERSHED,wetland:null===t.WETLAND?"Not in a wetland":t.wetland,zipcode:t.ZIPCODE,zoning:t.ZONING,zoningClass:t.ZONINGCLASS,zoningGen:t.ZONINGGEN}},_bindTaxlots:function(t){if(!t)return{acres:"",bldgSqFt:"",bldgVal:"",bldgValCur:"",jurisCity:"",JURIS_CITY2:"",landUse:"",landVal:"",landValCur:"",ownerAddress:"",owner:"",ownerCity:"",ownerState:"",ownerZip:"",RNumber:"",alternateAccountNumber:"",propertyCode:"",saleDate:"",salePrice:"",situsAddress:"",situsCity:"",situsZip:"",taxCode:"",yearBuilt:"",TLID:"",totalVal:""};var e=t.BLDGVAL;try{e="$"+parseFloat(t.BLDGVAL).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0})}catch(t){that.debugging&&console.log("Could not parse building value currency.")}var s=t.LANDVAL;try{s="$"+parseFloat(t.LANDVAL).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0})}catch(t){that.debugging&&console.log("Could not parse land value currency.")}var i=t.TOTALVAL;try{i="$"+parseFloat(t.TOTALVAL).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0})}catch(t){that.debugging&&console.log("Could not parse land value currency.")}const r=t&&null!=t.GIS_ACRES?this._safeToFixed(t.GIS_ACRES,2):null;return{acres:null!==r?r+" acres":null,bldgSqFt:t.BLDGSQFT.toString(),bldgVal:t.BLDGVAL.toString(),bldgValCur:e,jurisCity:t.JURIS_CITY,JURIS_CITY2:t.JURIS_CITY2,landUse:t.LANDUSE,landVal:t.LANDVAL.toString(),landValCur:s,owner:"",ownerAddress:"",ownerCity:"",ownerState:"",ownerZip:"",RNumber:t.PRIMACCNUM,alternateAccountNumber:t.ALTACCNUM,propertyCode:t.PROP_CODE,saleDate:"0"==t.SALEDATE?"Unavailable":0==t.SALEDATE.trim().length?"":t.SALEDATE,salePrice:0==t.SALEPRICE?"Unavailable":t.SALEPRICE.toString(),situsAddress:t.SITEADDR,situsCity:t.SITECITY,situsZip:t.SITEZIP,taxCode:t.TAXCODE,yearBuilt:0==t.YEARBUILT?"N/A":t.YEARBUILT.toString(),TLID:t.TLID,totalVal:i}},_bindEsriLocator:function(t){return{status:"success",locator:"ArcGISOnline",score:t.score,lat:t.location?this._safeToFixed(t.location.y):null,lng:t.location?this._safeToFixed(t.location.x):null,matches:"",fullAddress:t.attributes.Match_addr,house:t.attributes.AddNum,side:t.attributes.Side,preDir:t.attributes.StPreDir,preType:t.attributes.StPreType,streetName:t.attributes.StName,sufType:t.attributes.StType,sufDir:t.attributes.StDir,city:t.attributes.City,state:t.attributes.Region,zip:t.attributes.Postal,type:t.attributes.Addr_type,unitNumber:t.attributes.UnitName,ORSP_x:.1,ORSP_y:.1}},QueryPoint:function(t,e,s){this.debugging&&console.log("%c Begin QueryPoint","background: #bada55; color: #111");const i="Incorrect coordinates or out of bounds. RLISQuery only accepts Oregon State Plane (feet) (wkid:2913), Lat/Long (DD.DDDD) (wkid:4326), or Web Mercator (meters) (wkid:102100)";if(!t.hasOwnProperty("x")||!t.hasOwnProperty("y")||!t||0==t.x.length||0==t.y.length)return this.debugging&&console.log("%c Missing coordinate pair","background: #FF0000; color: #111"),e({error:!0,message:i});if(isNaN(parseFloat(t.x))||isNaN(parseFloat(t.y)))return this.debugging&&console.log("%c At least one coordinate is not a number","background: #FF0000; color: #111"),e({error:!0,message:i});if(!this._areCoordinatesValid(t.x,t.y))return this.debugging&&console.log("%c At least one coordinate out of range","background: #FF0000; color: #111"),e({error:!0,message:i});const r=this,o=performance.now();this.ReverseLocate(t,!1,function(t,s){if(null==t&&e(null,s),"failure"==t[0].status)return e(t,null);r._XssAJAX("metromap/RLISQuery/MapServer/0/query",`where=1%3D1&geometry=${t[0].lng},${t[0].lat}&geometryType=esriGeometryPoint&outFields=*&inSR=4326&f=json&returnGeometry=false&token=${r.token}`,"GET",function(s){if(!s.features&&0==s.features.length)return void e(null,s.error);if(r.debugging){const t=performance.now();console.log("%c Completed RLIS Query ","background: #222; color: #bada55",`${t-o} ms`)}s=s.features[0].attributes;const i=r._bindRLISQUERY(s);r._XssAJAX("taxlots/MapServer/0/query",`where=1%3D1&geometry=${t[0].lng},${t[0].lat}&geometryType=esriGeometryPoint&outFields=*&inSR=4326&f=json&returnGeometry=false&token=${r.token}`,"GET",function(s){if(r.debugging){const t=performance.now();console.log("%c Completed Taxlots Query ","background: #222; color: #bada55",`${t-o} ms`)}r.debugging&&console.log(`%c ${s.features.length} taxlot features returned`,"background: #222; color: #bada55"),s=0!=s.features.length?s.features[0].attributes:null;const n=r._bindTaxlots(s);let a=[{...t[0],...i,...n}];r.debugging&&console.log(a),e(a,null)})})})},QueryAddress:function(t,e,s){if(this.debugging&&console.log("%c Begin QueryAddress","background: #bada55; color: #111"),!t||0==t.trim().length)return this.debugging&&console.log("%c No address received","background: #FF0000; color: #111"),e({error:!0,message:"Please enter a valid address"});const i=this,r=performance.now();this.Geocode(t,async function(t,s){if(null==t)return e(null,s);"ArcGISOnline"!=t[0].locator?i._XssAJAX("metromap/RLISQuery/MapServer/0/query",`where=1%3D1&geometry=${t[0].lng},${t[0].lat}&geometryType=esriGeometryPoint&outFields=*&inSR=4326&f=json&returnGeometry=false&token=${i.token}`,"GET",function(s){if(!s.features&&0==s.features.length)return void e(null,s.error);if(i.debugging){const t=performance.now();console.log("%c Completed RLIS Query ","background: #222; color: #bada55",`${t-r} ms`)}s=s.features[0].attributes;const o=i._bindRLISQUERY(s);i._XssAJAX("taxlots/MapServer/0/query","where=1%3D1&geometry="+t[0].lng+","+t[0].lat+"&geometryType=esriGeometryPoint&outFields=*&inSR=4326&f=json&returnGeometry=false&token="+i.token,"GET",function(s){if(i.debugging){const t=performance.now();console.log("%c Completed Taxlots Query ","background: #222; color: #bada55",`${t-r} ms`)}i.debugging&&console.log(`%c ${s.features.length} taxlot features returned`,"background: #222; color: #bada55"),s=0!=s.features.length?s.features[0].attributes:null;const n=i._bindTaxlots(s);let a=[{...t[0],...o,...n}];i.debugging&&console.log(a),e(a,null)})}):e([t[0]],null)})},_autoSuggest:function(t,e,s){const i=performance.now(),r=this;let o=this.suggestLocator,n=/^[a-zA-Z][\w\s]*$/,a=/^\d\d(W|E)|\d(N|S)\d.+$/,l=/^R\d+$/;l.test(t)?o=this.rNumberLocator:n.test(t)?o=this.poiLocator:a.test(t)&&(o=this.taxlotLocator),this._XssAJAX(`locators/${o}/GeocodeServer/suggest`,`text=${t}&maxSuggestions=${e}&token=${this.token}&f=json`,"GET",function(t){if(null===t)return void s(null,t.error);if(r.debugging){const t=performance.now();console.log("%c Completed Suggest ","background: #222; color: #bada55",`${t-i} ms`)}const e={error:!1,values:t.suggestions.map(t=>t.text)};s(e,null)})},_areCoordinatesValid:function(t,e){return-123.6450&&(i=e._bindEsriLocator(o.candidates[0])),i}catch(t){return e.debugging&&console.log("%c Error in EsriLocateInput: "+t,"background: #FF0000; color: #ffffff"),null}},_safeToFixed:function(t,e=6,s=null){const i=parseFloat(t);return isFinite(i)?i.toFixed(e):s}};RLIS.Autosuggest.prototype={construct:function(){function t(t,e,s,i){return function(){t.call(e,s||null,i||null)}}return this.field.autosuggest=this,this.funcClick=this.mouseClick,this.funcCheck=this.checkKey,this.funcPress=this.keyPress,this.funcHighlight=this.highlightTable,this.funcClear=t(this.clearEvents,this),this.funcUp=t(this.scroll,this,!0,1),this.funcDown=t(this.scroll,this,!1,1),this.funcFocus=t(this.focusTable,this),this.funcUnfocus=t(this.unfocusTable,this),this.addEvent(this.field,"focus",t(this.setupEvents,this)),this.addEvent(window,"resize",t(this.reposition,this)),this},setupEvents:function(){this.evsetup||(this.evsetup=!0,this.addEvent(document,"keydown",this.funcCheck),this.addEvent(this.field,"blur",this.funcClear),this.addEvent(document,"keypress",this.funcPress))},clearEvents:function(){function t(t,e,s){t.removeEventListener&&!window.opera?t.removeEventListener(e,s,!0):t.detachEvent?t.detachEvent("on"+e,s):t["on"+e]=null}var e=window.event;if(e&&this.cur_h){var s=e.srcElement||e.target,i=this.mouse_x+(document.documentElement.scrollLeft||document.body.scrollLeft||0),r=this.mouse_y+(document.documentElement.scrollTop||document.body.scrollTop||0);if(s.id==this.field_id&&i>this.cur_x&&ithis.cur_y&&r",i[r++]=t.substring(o,e+o),i[r++]="",i[r++]=t.substring(e+o,t.length),i.join("")},build:function(){function t(t){var e=d.insertRow(-1);e.className=t?"up":"down";var s=e.insertCell(0);return h+=s.offsetHeight+1,s}function e(t,e){var i=s.rows[b]=d.insertRow(-1);i.className=e||s.previous==t?"selected":"";var r=i.insertCell(0);return r.innerHTML=s.parse(s.keywords[t],m,v),r.setAttribute("pos",b++),r.autosuggest=s,s.use_mouse&&(s.addEvent(r,"click",s.funcClick),r.onmouseover=s.funcHighlight),[i.offsetWidth,i.offsetHeight]}if(0!==this.total){this.rows=[],this.current=this.no_default?-1:0;var s=this;this.addEvent(document,"mousemove",function(t){t=t||window.event,s.mouse_x=t.x,s.mouse_y=t.y});var i=document.getElementById("suggest_table_"+this.field_id);if(i){this.displayed=!1,i.parentNode.removeChild(i);var r=document.getElementById("suggest_helper_"+this.field_id);r&&document.getElementById("autosuggest").removeChild(r)}var o=document.createElement("div");o.id="suggest_table_"+this.field_id,o.className="autosuggest-body",this.cur_y=this.curPos(this.field,"Top")+this.field.offsetHeight,o.style.top=this.cur_y+"px",this.cur_x=this.curPos(this.field,"Left"),o.style.left=this.cur_x+"px",this.cur_w=this.field.offsetWidth-(this.msie?2:6),o.style.width=this.cur_w+"px",this.cur_h=1,o.style.height="1px",o.style.zIndex="1000";var n=null,a=this.total>this.entry_limit;n&&(document.body.appendChild(n),n.style.top=this.cur_y+"px",n.style.left=this.cur_x+"px",n.style.width=o.offsetWidth+2),document.body.appendChild(o);var l=!0,u=(a?this.entry_limit:this.total,[]),c=0;u[c++]="",o.innerHTML=u.join("");var d=o.firstChild;this.use_mouse&&(d.onmouseout=this.funcUnfocus,d.onmouseover=this.funcFocus);var h=0,g=0;!this.use_scroll&&a&&(t(!0).parentNode.className="up-disabled");var f,m,_=this.keywords.length,p=0,b=0;if(this.text_delimiter.length>0){var y=this.delim_words[this.current_word];f=this.trim(this.addSlashes(y)),m=this.trim(y).length}else{y=this.field.value;f=this.addSlashes(y),m=y.length}for(var v=new RegExp((this.limit_start?"^":"")+f,"i"),w=0;w<_;w++)if(this.bool[w]){var S=e(w,l&&!this.no_default&&!this.rebuild);if(l=!1,p<=this.entry_limit&&(h+=S[1]+1),go.offsetWidth?g:o.offsetWidth)+(this.msie?-2:2),o.style.width=this.cur_w+"px",n&&(n.style.height=this.cur_h+"px",n.style.width=this.cur_w+"px"),this.range_up=0,this.range_down=b-1,this.displayed=!0,this.use_scroll&&setTimeout(function(){p=0;for(var t=T;t<_;t++){if(!s.displayed)return;if(s.bool[t]&&(e(t),++p==s.entry_limit)){++t;break}}T=t,bthis.entry_limit){var o=this.range_up>0;t(this,!0,o,this.funcUp)}if(this.text_delimiter.length>0){var n=this.delim_words[this.current_word];e=this.trim(this.addSlashes(n)),s=this.trim(n).length}else{n=this.field.value;e=this.addSlashes(n),s=n.length}for(var a=new RegExp((this.limit_start?"^":"")+e,"i"),l=this.keywords.length,u=0,c=0;c=this.range_up&&u<=this.range_down){var d=this.rows[u]=i.rows[r++];d.className="";var h=d.firstChild;h.innerHTML=this.parse(this.keywords[c],s,a),h.setAttribute("pos",u)}if(++u>this.range_down)break}if(l>this.entry_limit){o=u0&&(this.timer=setTimeout(function(){this.mouse_on_list=t,this.hide()},this.time_out))},stopTimer:function(){this.timer&&(clearTimeout(this.timer),this.timer=0)},getRow:function(t){return void 0===t&&(t=this.current),this.rows[t]||null},fixArrows:function(t){if(!(this.total<=this.entry_limit)){var e=t.firstChild,s=0===this.current,i=this.current==this.total-1,r=e.rows[0];r.className=s?"up-disabled":"up",r=e.rows[this.entry_limit+1],r.className=i?"down-disabled":"down"}},scroll:function(t,e){if(this.displayed&&(this.field.focus(),this.current!=(t?0:this.total-1))){if(!t&&this.current<0)this.current=-1;else{var s=this.getRow();s&&s.style&&(s.className="")}this.current+=e*(t?-1:1),t?this.current<0&&(this.current=0):(this.current>=this.total&&(this.current=this.total-1),this.use_scroll&&this.current>=this.rows.length&&(this.current=this.rows.length-1));s=this.getRow();var i=document.getElementById("suggest_table_"+this.field_id);if(this.use_scroll){if(t)s.offsetTopi.scrollTop+i.offsetHeight){var r=this.current-this.entry_limit+1;r>0&&(i.scrollTop=this.getRow(r).offsetTop)}}else t?this.currentthis.range_down?(this.range_down+=e,this.range_down>this.total-1&&(this.range_down=this.total-1),this.range_up=this.range_down-this.entry_limit+1,this.remake()):this.fixArrows(i),s=this.getRow();s&&s.style&&(s.className="selected"),this.stopTimer(),this.startTimer(1),this.field.focus()}},mouseClick:function(t){t=t||window.event;var e=t.srcElement||t.target;e.id||(e=e.parentNode);var s=e.autosuggest;if(!s){var i=e.tagName.toLowerCase();e="tr"==i?e.firstChild:e.parentNode,s=e.autosuggest}s&&s.displayed&&(s.mouse_on_list=0,s.current=parseInt(e.getAttribute("pos"),10),s.choose())},focusTable:function(){this.mouse_on_list=1},unfocusTable:function(){this.mouse_on_list=0,this.stopTimer(),this.startTimer(0)},highlightTable:function(t){t=t||window.event;var e=t.srcElement||t.target,s=e.autosuggest;if(s){s.mouse_on_list=1;var i=s.getRow();i&&i.style&&(i.className=""),s.current=parseInt(e.getAttribute("pos"),10),i=s.getRow(),i&&i.style&&(i.className="selected"),s.stopTimer(),s.startTimer(0)}},choose:function(){if(this.displayed&&!(this.current<0)){this.displayed=!1;for(var t=this.keywords.length,e=0,s=0;e0){for(var s="",i=this.delim_words[this.current_word],r=i.length,o=0,n=0;n=0&&" "==i.charAt(c);--c)l+=" ";s+=a,s+=t,o=s.length,u&&(s+=l)}else s+=this.delim_words[n];n!=this.delim_words.length-1&&(s+=this.delim_char[n])}this.field.value=s,e(this.field,o)}else this.field.value=t;this.mouse_on_list=0,this.hide()},hide:function(){if(0===this.mouse_on_list){this.displayed=!1;var t=document.getElementById("suggest_table_"+this.field_id);if(t){var e=document.getElementById("suggest_helper_"+this.field_id);e&&e.parentNode.removeChild(e),document.body.removeChild(t)}this.stopTimer(),this.cur_x=0,this.cur_y=0,this.cur_w=0,this.cur_h=0,this.rows=[]}},keyPress:function(t){t=t||window.event;var e=window.event?t.keyCode:t.charCode,s=t.srcElement||t.target;if(s=s.autosuggest,s.restrict_typing&&!s.suggest_url.length&&e>=32){var i=s.getCaretEnd(s.field),r=s.field.value.substr(0,i).toLowerCase(),o=!1;if(s.text_delimiter.length>0){for(var n="",a=0;a=0)return s.caret_moved=1,s.stopEvent(t),s.choose(),!1;if(s.field.value.length>0){if(s.displayed&&s.hide(),s.enableTLSearch){var r=new RegExp("\\d\\d(W|E)|\\d(N|S)\\d.+");if(s.field.value.toUpperCase().match(r))return s.TLSearch(s.field.value.toUpperCase()),!1}return"locate"==s.mode?RLIS.Geocode(s.field.value,s.callback,s.fields):RLIS.QueryAddress(s.field.value,s.callback,s.fields),!1}break;case 9:if(s.displayed&&s.current>=0||s.timer)return s.caret_moved=1,s.choose(),setTimeout(function(){s.field.focus()},25),!1;break;case 16:break;default:s.caret_moved=0,s.timer=setTimeout(function(){s.preSuggest(e)},s.response_time<10?10:s.response_time)}return i.length&&setTimeout(function(){s.field.value=i},25),!0},preSuggest:function(t){if(this.timer&&(this.stopTimer(),(!this.displayed||this.lastterm!=this.field.value)&&(this.lastterm=this.field.value,38!=t&&40!=t&&13!=t))){var e,s,i=0;if(this.displayed&&this.current>=0){for(var r=0;r0){var o=this.getCaretEnd(this.field),n="";for(r=0;r=c&&o<=c+this.delim_words[r].length&&(this.current_word=r),c+=this.delim_words[r].length+1;e=this.trim(this.delim_words[this.current_word]),s=this.trim(this.addSlashes(this.delim_words[this.current_word]))}else e=this.field.value,s=this.addSlashes(e);if(0===e.length&&-1!=t)this.mouse_on_list=0,this.hide();else if(1==e.length||this.full_refresh||e.length>1&&!this.keywords.length||e.length>1&&this.keywords[0].charAt(0).toLowerCase()!=e.charAt(0).toLowerCase()){var d=e.length>1&&!this.full_refresh?e.charAt(0):e;if(e.lengtht.value.length?-1:i}return-1},curPos:function(t,e){for(var s=0;t;)s+=t["offset"+e],t=t.offsetParent;return s},addSlashes:function(t){return t.replace(/(['\\\.\|\[\]\^\*\+\?\$\(\)])/g,"\\$1")},trim:function(t){return t.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1")}};