/** Neat Complete v1.4.0 (c) 2017 Abletech Ltd. https://github.com/AbleTech/neat-complete/blob/develop/LICENSE.md */ (function(){var t=[].slice,e=function(t,e){return function(){return t.apply(e,arguments)}},i=function(t,e){function i(){this.constructor=t}for(var n in e)s.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},s={}.hasOwnProperty;!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):t.NeatComplete=e(t)}(this,function(s){var n;return n={},n.addDomEvent=function(t,e,i){var s;return t.addEventListener?t.addEventListener(e,i,!1):(s=function(){return i.apply(t,arguments)},t.attachEvent("on"+e,s))},n.removeDomEvent=function(t,e,i){t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent&&t.detachEvent("on"+e,null)},Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e,i,s,n;if(null==this)throw new TypeError;if(n=Object(this),0===(i=n.length>>>0))return-1;if(s=0,arguments.length>0&&(s=Number(arguments[1]),s!==s?s=0:0!==s&&Infinity!==s&&-Infinity!==s&&(s=(s>0||-1)*Math.floor(Math.abs(s)))),s>=i)return-1;for(e=s>=0?s:Math.max(i-Math.abs(s),0);e=this.results.length&&(e=-1),null!=(s=this.results[e])&&s.highlight(),this.element.value=null!=this.highlighted?this.highlighted.value:this._val},s.prototype._getSuggestionsWithTimeout=function(){return null!=this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(function(t){return function(){return t._getSuggestions()}}(this),this.options.timeout)},s.prototype._getSuggestions=function(){var t,e,i,s,n;if(this.enabled){if(!this._servicesReady())return void(this.searchQueued=!0);if(this._val=this.element.value,this.error_content=null,""!==this._val){for(i=this.services,s=[],t=0,e=i.length;t0)self._completeHandlers.shift()(e)}function success(resp){var type=o.type||resp&&setType(resp.getResponseHeader("Content-Type"));resp=type!=="jsonp"?self.request:resp;var filteredResponse=globalSetupOptions.dataFilter(resp.responseText,type),r=filteredResponse;try{resp.responseText=r}catch(e){}if(r)switch(type){case"json":try{resp=context.JSON?context.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML&&resp.responseXML.parseError&&resp.responseXML.parseError.errorCode&&resp.responseXML.parseError.reason?null:resp.responseXML}self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp),self._successHandler(resp);while(self._fulfillmentHandlers.length>0)resp=self._fulfillmentHandlers.shift()(resp);complete(resp)}function timedOut(){self._timedOut=!0,self.request.abort()}function error(e,t,n){e=self.request,self._responseArgs.resp=e,self._responseArgs.msg=t,self._responseArgs.t=n,self._erred=!0;while(self._errorHandlers.length>0)self._errorHandlers.shift()(e,t,n);complete(e)}this.url=typeof o=="string"?o:o.url,this.timeout=null,this._fulfilled=!1,this._successHandler=function(){},this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){timedOut()},o.timeout)),o.success&&(this._successHandler=function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest.call(this,success,error)}function reqwest(e,t){return new Reqwest(e,t)}function normalize(e){return e?e.replace(/\r?\n/g,"\r\n"):""}function serial(e,t){var n=e.name,r=e.tagName.toLowerCase(),i=function(e){e&&!e.disabled&&t(n,normalize(e.attributes.value&&e.attributes.value.specified?e.value:e.text))},s,o,u,a;if(e.disabled||!n)return;switch(r){case"input":/reset|button|image|file/i.test(e.type)||(s=/checkbox/i.test(e.type),o=/radio/i.test(e.type),u=e.value,(!s&&!o||e.checked)&&t(n,normalize(s&&u===""?"on":u)));break;case"textarea":t(n,normalize(e.value));break;case"select":if(e.type.toLowerCase()==="select-one")i(e.selectedIndex>=0?e.options[e.selectedIndex]:null);else for(a=0;e.length&&aAddress not found. Please verify the spelling.
For brand new addresses, please type it in manually.",location_content:"Addresses near me",location_unavailable:"Location information unavailable. Please type in your address.",location_not_found:"No nearby addresses found. Please type in your address.",location_loading:"Loading your location...",max_results:r.options.maxItems});var d=null,a=r.widget.addService("addy",function(n,s){if(n.length<3)return s(n,new Array),void r.widget._hideResults();try{d=new RegExp("("+(e=n,e.replace(/\\/gi,"/").replace(/[^0-9a-z' /]/gi,"").trim()).split(" ").join("|")+")","gi")}catch(e){d=null}var e;"address"===r.mode?r.makeRequest("search",r.searchSuffix+"&s="+n,function(e){var o=new Array;if(e)for(var t=0;t$1')}});r.setOption=function(e,o){e&&"exclude_postbox"===e?r.options.excludePostBox=o:r.widget.setOption(e,o),t()},r.setExcludeRural=function(e){r.options.exRural=e,t()},r.setExcludePostbox=function(e){r.options.excludePostBox=e,t()},r.setExcludeUndeliverable=function(e){r.options.exUndeliver=e,t()},r.setExcludeSpelling=function(e){r.options.exSpelling=e,t()},r.setExcludeWordRemoval=function(e){r.options.exWord=e,t()},r.setExcludeIpOrder=function(e){r.options.exIp=e,t()},r.setExcludePostcodes=function(e){r.options.exPostcodes=Array.isArray(e)?e.join("-"):e,t()},r.setIncludePostcodes=function(e){r.options.inPostcode=Array.isArray(e)?e.join("-"):e,t()},r.setExcludeRegions=function(e){r.options.exRegion=Array.isArray(e)?e.join("-"):e,t()},r.setIncludeRegions=function(e){r.options.inRegion=Array.isArray(e)?e.join("-"):e,t()},r.setExcludeTerritories=function(e){r.options.exTerritory=Array.isArray(e)?e.join("-"):e,t()},r.setIncludeTerritories=function(e){r.options.inTerritory=Array.isArray(e)?e.join("-"):e,t()},r.setTag=function(e){r.options.tag=e,t()},r.setUniqueId=function(e){r.options.uniqueId=e,t()},r.getOption=function(e){return r.widget.getOption(e)},r.getMaxResults=function(){return r.widget.getOption("max_results")},r.enableLocation=function(){r.options.enableLocation=!0},r.disableLocation=function(){r.options.enableLocation=!1},r.enable=function(){r.widget.enable()},r.disable=function(){r.widget.disable()},r.setPostcodeMode=function(e){r.mode="postcode",r.setOption("empty_content","Postcode not found. Please verify the spelling.")};NeatComplete.addDomEvent(i,"focus",function(e){r.options.enableLocation&&""===i.value&&a._response(a.last_query,[{value:r.getOption("location_content"),data:{id:"location"}}])}),r._onLocationResultsEmpty=function(e){var o=r.widget.getOption("empty_content");r.options.enableLocation=!1,r.setOption("empty_content",e),setTimeout(function(){r.setOption("empty_content",o)},2e3)},r.handleLocationError=function(e){r.makeRequest("errorlog","&message=GeoFailCode:"+e.code+":"+e.message,function(e){}),r._onLocationResultsEmpty(r.getOption("location_unavailable")),a._response(a.last_query,[]),i.placeholder=s},r.reverseGeocode=function(e){r.makeRequest("geocode","&x="+e.coords.longitude+"&y="+e.coords.latitude+"&limit="+r.getMaxResults(),function(e){var o=new Array;if(e)for(var t=0;tDemo Mode: Create a free account at addy.co.nz'),!0)},r.checkDemo(),t()}else console.warn("Input field is missing");function t(){r.searchSuffix="&max="+r.getMaxResults(),r.options.excludePostBox&&(r.searchSuffix+="&expostbox=true"),r.options.exUndeliver&&(r.searchSuffix+="&exundeliver=true"),r.options.exRural&&(r.searchSuffix+="&exrural=true"),r.options.exSpelling&&(r.searchSuffix+="&exspelling=true"),r.options.exWord&&(r.searchSuffix+="&exword=true"),r.options.exIp&&(r.searchSuffix+="&exip=true"),r.options.exPostcodes&&""!==r.options.exPostcodes&&(r.searchSuffix+="&expostcode="+r.options.exPostcodes),r.options.inPostcode&&""!==r.options.inPostcode&&(r.searchSuffix+="&inpostcode="+r.options.inPostcode),r.options.exRegion&&""!==r.options.exRegion&&(r.searchSuffix+="&exregion="+r.options.exRegion),r.options.inRegion&&""!==r.options.inRegion&&(r.searchSuffix+="&inregion="+r.options.inRegion),r.options.exTerritory&&""!==r.options.exTerritory&&(r.searchSuffix+="&exterritory="+r.options.exTerritory),r.options.inTerritory&&""!==r.options.inTerritory&&(r.searchSuffix+="&interritory="+r.options.inTerritory),r.requestSuffix="",r.options.tag&&""!==r.options.tag&&(r.requestSuffix+="&tag="+r.options.tag),r.options.uniqueId&&""!==r.options.uniqueId&&(r.requestSuffix+="&uniqueid="+r.options.uniqueId)}}function initAddyByCss(){var e=["","2-","3-","4-"],t="addy-";function o(e){var o=document.getElementsByClassName(t+e);return 1===o.length?o[0]:null}for(var i=0;i