!function(a,e){if(void 0!==a&&void 0!==a.document&&"function"!=typeof(e=void 0===e?a:e).autocompleteLocation){function t(e,t){t=t||{},this.init(e,t)}t.prototype={elementId:null,options:{},init:function(e,t){this.elementId=e,this.options=t;var o=this;n(t.apiKey,function(e){o.initAutocomplete()})},getElement:function(){var e=this.getElementId(),t=a.document.getElementById(e);return t&&t.tagName?t:null},getElementId:function(){return this.elementId},_placeChange:function(e){e=e||{};var t=this.getElement();t&&e.formatted_address&&(t.value=e.formatted_address),this.options&&this.options.onPlaceChange&&s(this.options.onPlaceChange)&&l(this.options.onPlaceChange,[e])},_error:function(e){e=e||null,this.options&&this.options.onError&&s(this.options.onError)&&l(this.options.onError,[e])},triggerPlaceChange:function(e){e.geometry?this._placeChange(e):this._error(new Error("PLACE_ERROR_NO_GEOMETRY"))},initAutocomplete:function(){var e=this.getElement();if(c()&&e){this.options&&this.options.onLibraryLoaded&&s(this.options.onLibraryLoaded)&&l(this.options.onLibraryLoaded);var t=new a.google.maps.places.Autocomplete(e,{types:["(regions)"]});t.setFields(["address_components","geometry"]),t.setComponentRestrictions({country:["au"]}),e.gAutoComplete=!0;var o=this;t.addListener("place_changed",function(){var e=t.getPlace();o.triggerPlaceChange(e)})}else this._error(new Error("Error initializing"))},setFromPosition:function(e){if(c())if(e&&"object"==typeof e){var t=e.latitude||e.lat,o=e.longitude||e.lng;if(isNaN(t)||isNaN(o))this._error(new Error("Position invalid"));else{var n=new a.google.maps.Geocoder,i=this,r={lat:t,lng:o};n.geocode({location:r},function(e,t){t&&"OK"===t.toUpperCase()&&e&&0<=e.length?(e[0].isGeocoded=!0,i.triggerPlaceChange(e[0])):i.triggerPlaceChange({})})}}else this._error(new Error("Position not valid"));else this._error(new Error("Error initializing"))},lockAutocomplete:function(){var e=this.getElement();e&&(e.setAttribute("readonly","readonly"),e.setAttribute("disabled","disabled"))},unlockAutocomplete:function(){var e=this.getElement();e&&(e.removeAttribute("readonly"),e.removeAttribute("disabled"))},setFromCurrentUserLocation:function(){var o=this;void 0!==a.navigator&&a.navigator.geolocation?a.navigator.geolocation.getCurrentPosition(function(e){var t={lat:e.coords.latitude,lng:e.coords.longitude};o.setFromPosition(t)},function(){o._error(new Error("GEOLOCATION_SERVICE_FAILED"))}):this._error(new Error("GEOLOCATION_SERVICE_FAILED"))}},e.autocompleteLocation=t}function r(){}function s(e){return"function"==typeof e}function l(e,t,o){if(o=o||null,t=t||[],s(e))return e.apply(o,t)}function c(){return void 0!==a.google&&a.google.maps&&a.google.maps.places}function n(e,t){"function"!=typeof t&&(t=function(){});var o=null;if(void 0!==e&&e||(o=new Error("Api key not available")),c()||o)l(t,[o]);else{var n=a.document.createElement("script");n.type="text/javascript",n.src="https://maps.googleapis.com/maps/api/js?key="+e+"&libraries=places";var i=a.document.getElementsByTagName("script")[0];i&&(i.parentNode.insertBefore(n,i),function e(t,o,n){if(void 0!==n&&!isNaN(n)||(n=5),o=s(o)?o:r,(n=parseInt(n))<=0)l(o,[new Error("Sleep exhausted")]);else{var i=l(t);i?l(o,[null,i]):(n--,setTimeout(function(){e(t,o,n)},1e3))}}(c,function(e){l(t,[e])},10))}}}(window); !function(){"use strict";function e(n,t,r){return("string"==typeof t?t:t.toString()).replace(n.define||a,function(e,t,o,a){return 0===t.indexOf("def.")&&(t=t.substring(4)),t in r||(":"===o?(n.defineParams&&a.replace(n.defineParams,function(e,n,o){r[t]={arg:n,text:o}}),t in r||(r[t]=a)):new Function("def","def['"+t+"']="+a)(r)),""}).replace(n.use||a,function(t,o){n.useParams&&(o=o.replace(n.useParams,function(e,n,t,o){if(r[t]&&r[t].arg&&o){var a=(t+":"+o).replace(/'|\\/g,"_");return r.__exp=r.__exp||{},r.__exp[a]=r[t].text.replace(new RegExp("(^|[^\\w$])"+r[t].arg+"([^\\w$])","g"),"$1"+o+"$2"),n+"def.__exp['"+a+"']"}}));var a=new Function("def","return "+o)(r);return a?e(n,a,r):a})}function n(e){return e.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")}var t,r={engine:"doT",version:"1.1.1",templateSettings:{evaluate:/\{\{([\s\S]+?(\}?)+)\}\}/g,interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,useParams:/(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,defineParams:/^\s*([\w$]+):([\s\S]+)/,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:!0,append:!0,selfcontained:!1,doNotSkipEncoded:!1},template:void 0,compile:void 0,log:!0};r.encodeHTMLSource=function(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},t=e?/[&<>"'\/]/g:/&(?!#?\w+;)|<|>|"|'|\//g;return function(e){return e?e.toString().replace(t,function(e){return n[e]||e}):""}},t=function(){return this||(0,eval)("this")}(),"undefined"!=typeof module&&module.exports?module.exports=r:"function"==typeof define&&define.amd?define(function(){return r}):t.doT=r;var o={append:{start:"'+(",end:")+'",startencode:"'+encodeHTML("},split:{start:"';out+=(",end:");out+='",startencode:"';out+=encodeHTML("}},a=/$^/;r.template=function(c,i,u){i=i||r.templateSettings;var d,s,p=i.append?o.append:o.split,l=0,f=i.use||i.define?e(i,c,u||{}):c;f=("var out='"+(i.strip?f.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""):f).replace(/'|\\/g,"\\$&").replace(i.interpolate||a,function(e,t){return p.start+n(t)+p.end}).replace(i.encode||a,function(e,t){return d=!0,p.startencode+n(t)+p.end}).replace(i.conditional||a,function(e,t,r){return t?r?"';}else if("+n(r)+"){out+='":"';}else{out+='":r?"';if("+n(r)+"){out+='":"';}out+='"}).replace(i.iterate||a,function(e,t,r,o){return t?(l+=1,s=o||"i"+l,t=n(t),"';var arr"+l+"="+t+";if(arr"+l+"){var "+r+","+s+"=-1,l"+l+"=arr"+l+".length-1;while("+s+"{{=centre.companyName}}',a='';function c(e,t,n,i){var r=e.getLecContainer();if(e.getElement()&&r&&u(r).find(".lce-selected-container").length&&e.isAllowedCentre(t,n)){e.selectCentre(t,n,i),u(r).addClass("selected"),e.getLceElementId()&&u("#"+e.getLceElementId()).val(""),u(r).find(".lce-list-container").length&&u(r).find(".lce-list-container").empty();var o=u(''+t+""),s=u('Change');u(s).click(function(){e.selectCentre(null),u(r).find(".lce-selected-container").empty(),u(r).removeClass("selected")}),u(r).find(".lce-selected-container").append(e.centreText(o,n,i)),u(r).find(".lce-selected-container").append(s)}}function p(e,t){var n=e.getLecContainer();n&&(u(n).find(".lce-list-container").html(t.message),u(n).addClass("error"),e.onError(t))}function f(i,e){var t=i.getLecContainer();if(t&&u(t).find(".lce-list-container").length){var n=i.itemTemplate||s,r=i.listTemplate||a;if((e=i.onBeforeTemplate(e)).length){var o=function(e,t,n){if(!m.doT)return null;var i=u("
").append(n);return u(i).find(".lce-select-item").attr("data-centre-id","{{=centre.id}}"),u(i).find(".lce-select-item").attr("data-value","{{=centre.companyName}}"),m.doT.template(i[0].innerHTML)({centres:t})}(0,e,r.replace("[itemList]",n));u(t).find(".lce-list-container").html(o),u(t).find(".lce-select-item").click(function(e){var t=u(this).attr("data-centre-id"),n=u(this).attr("data-value");n&&c(i,n,t)})}else p(i,new Error("No Centres found"))}}function t(s){var a=s.getLecContainer();if(!a||!s.options.apiKey)return null;if(s.getAcInstance())return s.getAcInstance();var c=s,l=new m.autocompleteLocation(s.getLceElementId(),{apiKey:s.options.apiKey,onPlaceChange:function(e){!function(e){var t=e.getLecContainer();t&&(u(t).find(".lce-list-container").html(""),u(t).removeClass("error"))}(s);var t="",n=e.geometry.location.lat(),i=e.geometry.location.lng();if(e.formatted_address)t=e.formatted_address;else if(e.address_components){var r=[e.address_components[0]&&e.address_components[0].short_name||"",e.address_components[1]&&e.address_components[1].short_name||"",e.address_components[2]&&e.address_components[2].short_name||"",e.address_components[3]&&e.address_components[3].short_name||"",e.address_components[4]&&e.address_components[4].short_name||""];t=(r=r.filter(function(e){return 0');u(i).append(u('
'));var r=u('
');if(u(r).append(u('')),t.options.allowGps){var o=u('Use Current');u(o).click(function(){var e=t.getAcInstance();e&&e.setFromCurrentUserLocation()}),u(r).append(o)}return u(i).append(r),u(i).append(u('
')),u(n).parent().prepend(i),i}}(this),this._acInstance=t(this),this._rendered=!0;var n=this,e=this.getValue();e?c(n,e):this.options.useSelectedCentre&&!1===this.options.useSelectedCentre||d.subscribeEvent(d.events.SET_AS_FAVOURITE,function(e){d.getFavouriteCentreInfo(function(e,t){!e&&t&&d.utils.isObject(t)&&c(n,t.companyName,t.id,t)})})}},getAcInstance:function(){return this._acInstance},getElement:function(){return u("#"+this.elementId).length?u("#"+this.elementId):null},getValue:function(){var e=this.getElement();return e?e.val():null},getElementId:function(){return this.elementId},getLceElementId:function(){return this.getLceIdentifier()+"LceLocationElement"},getLceIdentifier:function(){return function(e){return e.replace(/[^A-Z0-9]/gi,"")}(this.getElementId())},getLecContainer:function(){return this._container},isSelectElement:function(){var e=this.getElement();return!!e&&(e[0]&&"SELECT"===e[0].nodeName.toUpperCase())},onBeforeTemplate:function(e){var t=e;if("function"==typeof this.options.onBeforeTemplate)t=this.options.onBeforeTemplate.apply(this,[e]);else{var n=this;t=u(e).filter(function(e,t){return n.isAllowedCentre(t.companyName,t.id,t)})}return t},getAllowedCentres:function(){var n=[];if(this.isSelectElement()){var e=this.getElement();u(e).find("option").each(function(e,t){n.push(u(t).attr("value"))})}return n},isAllowedCentre:function(e,t,n){var i=this.filterCentreName(e);if("function"==typeof this.options.isAllowedCentre)return this.options.isAllowedCentre.apply(this,[e,t,n]);if(this.isSelectElement()){var r=this.getAllowedCentres();return-1!==u.inArray(i,r)}return!0},filterCentreName:function(e,t,n){return"function"==typeof this.options.centreNameFilter?this.options.centreNameFilter.apply(this,[e,t,n]):e},selectCentre:function(e,t,n){var i=this.getElement();if(i){var r=null;return e&&(r=this.filterCentreName(e)),i.val(r),"function"==typeof this.options.onSelectCentre?this.options.onSelectCentre.apply(this,[e,t,n]):void 0}},centreText:function(e,t,n){if(this.isSelectElement()){var i=this.getElement();return u(i).find("option:selected").html()}return e},onError:function(e){if("function"==typeof this.options.onError)return this.options.onError.apply(this,[e])}},d.subscribeEvent("onLocationModuleInit",function(e){n()}),d.subscribeEvent("onFavouriteModuleInit",function(e){n()})})}(window);