var DignityMemorial=DignityMemorial||{};DignityMemorial.createNamespace=function(n){var t=n.split("."),i=DignityMemorial,r,u;for(t[0]==="DignityMemorial"&&(t=t.slice(1)),r=0;r<t.length;r++)u=t[r],typeof i[u]=="undefined"&&(i[u]={}),i=i[u];return i};DignityMemorial.createNamespace("DignityMemorial.Foundation.CoveoSearch.Base");DignityMemorial.Foundation.CoveoSearch.Base=function(n,t){var i=Coveo.$(t.modelID),o=Coveo.$("#filterResults"),r=parseInt(Coveo.$(i).attr("data-results-per-page")),u=function(n,t){var i={},f=function(n,t){this.queryStateModel.registerNewAttribute(n,t);i[n]=t},u=function(n){return t.coveo("state",n)},e=function(n,i){t.coveo("state",n,i);r(n)},o=function(n,i){t.coveo("state",n,i,{silent:!0});r(n)},s=function(n){t.coveo("state",n,"")},h=function(n){n?this.queryStateModel=n:console.log("QueryState Model is not defined, aborting")},r=function(n){i[n]=u(n)},c=function(n,i){var r=String.format("state:change:{0}",n);t.on(r,i)},l=function(){Coveo.$(".custom-results-message-global").hide();Coveo.$(".custom-no-results-message-global").show();Coveo.$(".CoveoQuerySummary").hide()};return{init:h,register:f,get:u,set:e,setSilent:o,cleanState:s,refreshState:r,custom:i,addListenerToStateChange:c,buildNoResultsMessage:l}}(n,i),s=function(n,t,r){var u="f:",f=function(n,t){var r=String.format("{0}[data-field='{1}']",n,t);return u+i.find(r).attr("id")},e=function(n){return r.get(n)},o=function(n,t){r.set(n,t)},s=function(n){r.set(n,"")};return{fieldQueryString:u,getFacetID:f,getFacetValue:e,setFacetValue:o,CleanFacet:s}}(n,i,u),h=function(n,t,i){var u=0,f=Coveo.$("#see-more-btn"),o=function(){i.custom.isGoogleQueryResult||(i.set("seeMoreResults",0),u=0)},s=function(n,t){t.value===0&&(u=0)},h=function(){i.set("seeMoreResults",0);u=0},c=function(){var n,f=window.sessionStorage.getItem("searchKeyword"),t;u++;t=i.get("seeMoreResults");~t&&u===1?(u++,n=r*2):n=r*u;i.set("seeMoreResults",n);i.custom.isNamedSearch&&!i.custom.isQueryAfterBoundsChange&&i.set("q",f);DignityMemorial.Location?DignityMemorial.Location.Search.StateMachine.transition({type:"SEE_MORE_CLICKED"}):e()};return{$btnElement:f,resetOnStateChange:o,resetOnMapMove:h,resetOnHide:s,clickHandler:c}}(n,i,u),c=function(){function i(n,t,i){var u,r;if(n.length==t.length)for(u=n.length,r=0;r<u;r++)this[n[r]]=i.raw[t[r]];else console.error("Cannot create object because properties and values are not the same length")}var n=[],r=function(n){var r=["name","address","phoneNumber","latitude","longitude","code"],u=[t.PublicName,t.Address,t.PhoneNumber,t.LatFieldName,t.LongFieldName,t.Code];return this.resultItems=n.map(function(n){return new i(r,u,n)}),this.resultItems},u=function(t){return n[t]};return{create:r,getByIndex:u}}(),f=function(){return Coveo.$(".CoveoSearchbox input").val()},l=function(n){Coveo.$(".CoveoSearchbox input").val(n)},a=function(){return!f()},e=function(){i.coveo("executeQuery")},v=function(){return performance.navigation.type==PerformanceNavigation.TYPE_BACK_FORWARD},y=function(){Coveo.$(".CoveoSearchbox input").focus(function(){Coveo.$("#filter-panel").hasClass("in")&&Coveo.$("#filterResults .see-more").trigger("click")})},p=function(n){var t=parseFloat(n);return n.sort(function(n,t){return n-t})};return{model:i,locationFilters:o,resultsPerPage:r,inputIsEmpty:a,getKeyword:f,setKeyword:l,bindNewSearch:y,state:u,facets:s,seeMore:h,results:c,navIsBackForward:v,executeQuery:e}}(jQuery,coveoFields,contextFields)