var GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.Destinations=function(){"use strict";var n=Object.create(HTMLElement.prototype),r=3,u="",t="Destinations",i=!1;return n.createdCallback=function(){GolfNow.Web.Page.Pub("widget_loading",{widgetName:t});var n=this;this.readAttributes();this.headerElement=u=this.querySelector("#fdHeader");GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:t});GolfNow.Web.Page.Sub("window_resize",function(){})},n.readAttributes=function(){this.items=r=Number(this.getAttribute("items"));isNaN(this.items)&&(this.items=3)},n.attributeChangedCallback=function(){},n.init=function(){i||(i=!0,document.registerElement("gn-destinations",{prototype:n}))},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.HotDealsZone=function(){"use strict";function c(){for(var n,i,r=[],t=0;t<s.length;t++)n=s[t],i=n.isPath?n.tmplPath:"/Tmpls/_"+n.tmplPath+".tmpl.html",r.push(GolfNow.Web.Client.LoadTemplate(i,n.accessorName,n.helpers));return r}function f(){var f=r,n=$(f),e={FacilityId:t,PageSize:100,PageNumber:1,Date:i,SortBy:GolfNow.Web.Utils.GetDefaultSearchSort(),SortByRollup:GolfNow.Web.Utils.GetDefaultSearchSort(),SortDirection:0,SearchType:1,View:"List",HotDealsOnly:!0};l.Post("hot-deals-zone","/api/tee-times/hot-deals-zone",JSON.stringify(e)).done(function(t){if(t&&t.length>0){var i=$.render.hotDealsZoneTemplate({hotDealTimes:t});n.html(i).show()}else n.hide()}).fail(function(){GolfNow.Web.Utils.ConsoleError("Failed to get hot deals zone tee times.");n.hide()}).always(function(){u=!1})}var n=Object.create(HTMLElement.prototype),t="",i=GolfNow.Web.Cache.GetActiveDate(),e=3,r="",o="HotDealsZone",s=[{tmplPath:"HotDealsZone",accessorName:"hotDealsZoneTemplate",isPath:!1}],l=GolfNow.Web.Request,u=!1,h=!1;return n.createdCallback=function(){var n=this;n.readAttributes().done(n.loadItems);GolfNow.Web.Page.Pub("widget_loading",{widgetName:o,ctx:this})},n.readAttributes=function(){var n=this;return this.facilityId=t=this.getAttribute("facility-id"),this.date=i=this.getAttribute("date"),GolfNow.Web.Utils.ConsoleLog("Hot Deals Zone Facility Id: "+t),GolfNow.Web.Utils.ConsoleLog("Hot Deals Zone Date: "+i),this.items=e=Number(this.getAttribute("items")),(isNaN(this.items)||this.items===0)&&(this.items=e=this.itemsToShow()),$.Deferred().resolveWith(n)},n.loadItems=function(){var n=this;$.when.apply(this,c()).then(f).done(function(){GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:o});GolfNow.Web.Page.Sub("window_resize",function(){n.setAttribute("items",n.itemsToShow())});GolfNow.Web.Page.Sub("search_date_changed",function(t){$(n).hide();n.setAttribute("date",GolfNow.Web.Utils.GetDateString(t))})})},n.attributeChangedCallback=function(n,t,i){var r=this;GolfNow.Web.Utils.ConsoleLog("Attribute "+n+" changed!");/^(items|facility-id|date)$/.test(n)&&t!=i&&(u||(u=!0,setTimeout(function(){r.readAttributes();f()},500)))},n.itemsToShow=function(){var n=3;return Foundation.utils.is_small_only()?n=3:Foundation.utils.is_medium_only()?n=5:Foundation.utils.is_large_up()&&(n=8),n},n.init=function(){h||(h=!0,this.hotDealZoneElement=r=document.querySelector("gn-hot-deals-zone"),r.setAttribute("date",GolfNow.Web.Utils.GetDateString(GolfNow.Web.Cache.GetActiveDate())),document.registerElement("gn-hot-deals-zone",{prototype:n}))},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.FeaturedCourses=function(){"use strict";function d(n,t,i,r,u,f){return l?GolfNow.Web.Request.Post("get_ff_details","/api/tee-times/featured-facility-result",JSON.stringify({facilityId:n.facilityId,predicateDate:t})).then(function(t){return n.minPrice=t.ffResult.minPrice,n.maxPrice=t.ffResult.maxPrice,n.teeTimeCount=t.ffResult.teeTimeCount,n.isPriceRangeZero=t.ffResult.isPriceRangeZero,n.isTimeRangeZero=t.ffResult.isTimeRangeZero,n.insLocation=i,n.sliceStart=u,n.sliceEnd=f,n.day=t.ffResult.day,n.minTimeFormatted=t.ffResult.minDateFormatted,n.minMeridian=t.ffResult.formattedMinTimeMeridian,n.maxTimeFormatted=t.ffResult.maxDateFormatted,n.maxMeridian=t.ffResult.formattedMaxTimeMeridian,n.searchType=r,GolfNow.Web.Domains.BookingCenterPhone().done(function(t){n.phoneNumber=t}),n}):$.Deferred().resolve()}function v(){var nt=Math.floor(o/t),h=Math.floor(s/t),tt=h*t,b=c/s+1,l,r;b%2!=0&&(h+=1);o<t&&(h=1);for(var w=0,a=k?"teetimes":"facilities",g=e.length,v=[],p=0;w<h&&g>0;)l=e.shift(),l&&(r=u+t,r>i.length&&(p=r-i.length,r-=p),v.push(d(l,n.date,f,n.searchType,u,r)),u+=t-p,f++),w++;v.length>0?$.when.apply(this,v).done(function(){var t=Array.prototype.slice.call(arguments);t.length>1&&t.sort(function(n,t){return n.insLocation<t.insLocation?-1:n.insLocation>t.insLocation?1:0});_.each(t,function(t){TrackGoogleEvent("featuredImpression","Featured Course","impression",t.name+"|"+t.facilityId,1);var r=t[a]=i.slice(t.sliceStart,t.sliceEnd);$.observable(n.featured).insert(t.insLocation,t)});y(a)}):y(a)}function y(t){var o,r;e.length===0&&(e.length===0&&f===0&&(n.featured.push({facilityId:"",insLocation:f,searchType:n.searchType}),f+=i.length),n&&n.featured&&n.featured.length>0&&(o=i.length-u,o>0&&(r=n.featured[n.featured.length-1],r[t]instanceof Array||(r[t]=[]),$.observable(r[t]).insert(i.splice(u,o)))),e.length===0&&window.setTimeout(p,25))}function p(){$("section.search-results").length>0?h||(GolfNow.Web.Page.Pub("content_rendered",null),h=!0):window.setTimeout(p,25)}function g(n,t){var i=t.items.length+" item(s) added at index: "+t.index;GolfNow.Web.Utils.ConsoleLog(i)}var r=Object.create(HTMLElement.prototype),w="FeaturedCourses",o=0,s=0,c=0,b=!1,l=!0,t=20,u=0,f=0,a={ttResults:null},e=[],i=[],n={featured:[]},k=!1,h=!1;return r.createdCallback=function(){GolfNow.Web.Page.Pub("widget_loading",{widgetName:w});var r=this;this.readAttributes();GolfNow.Web.Page.Sub("search_results_data_loaded",function(r){o=r.totalRecords;s=r.pageSize;c=r.startIndex;a=r.serverData;n=r.coursesByFeatured;i=r.teetimes;k=r.isTeeTimes;r.featuredFacilities!==undefined&&l&&(e=r.featuredFacilities);r.featuredFacilityInsertLocation!==undefined&&(u=r.featuredFacilityInsertLocation);r.featuredFacilityInsertLocation2!==undefined&&(f=r.featuredFacilityInsertLocation2);a.ttResults.total=o;a.ttResults.featuredFacilityFrequency=t;h=!1;$.observe(n.featured,g);n.isVipMember=b;v()});GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:w});GolfNow.Web.Page.Sub("window_resize",function(){});GolfNow.Web.Page.Sub("content_rendered",function(){h=!0})},r.readAttributes=function(){this.totalRecords=o=Number(this.getAttribute("total-records"));this.pageSize=s=Number(this.getAttribute("page-size"));this.startIndex=c=Number(this.getAttribute("start-index"));this.featuredFacilityFrequency=t=Number(this.getAttribute("featured-per-items"));isNaN(this.featuredFacilityFrequency)&&(this.featuredFacilityFrequency=20);this.vipMember=b=this.getAttribute("vip-member").toLowerCase()==="true"?!0:!1;this.showFeatured=l=this.getAttribute("show-featured").toLowerCase()==="true"?!0:!1},r.attributeChangedCallback=function(n){/^(facilities-total|page-size|start-index|featured-per-items|show-featured)$/.test(n)&&(this.readAttributes(),v())},r.init=function(){document.registerElement("gn-featured-courses",{prototype:r})},{initWidget:r.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.SearchInputBig=function(){function rt(){if(r===null&&(r=$(v)),i===null&&(i=$(".federatedSearchResults li a.selected")),nt===null&&(nt=r.length),i.length==0)i=r.first().addClass("selected");else{var n=i.index(v)+1;$(kt).removeClass("selected");n==nt?r.first().addClass("selected"):r.eq(n).addClass("selected")}}function ni(n){var t=/\-/g,i=n;return n.length>0&&!federatedSearchValidation.test(n)?!1:n.length>0&&n.match(t)!=null&&n.match(t).length>1?!1:!0}function ut(s){s.keyCode!==13&&s.keyCode!==9&&_.delay(function(){var h,s,l,a,v,y,p;if(c=n.val(),c!=at)if(at=c,c&&c.length>=minimumchar){if(ni(c))n.tooltipster("hide");else{n.tooltipster("show");return}t.find(".facility, .location").remove();f.empty();e.empty();u.show();t.find(".federatedSearchResults").hide();t.find(".message").hide();t.find(".throbber").show();n.data().searchData=null;v=2;y=Math.floor(previewTop/2);GolfNow.Web.GeoPlaces.TypeAheadWrapper(c,function(i,r,u,e){i!==undefined&&i.length&&(e&&e.type==="course"&&(g="course"),i=i.slice(0,y),$.each(i,function(i,r){v+=i;h=$("<li />").addClass("facility");s=$("<a />");l=$("<i />").addClass("ion-ios-flag color-green-primary");a=$("<span />").html(r.displayName);s.append(l).append(a);var u={$textbox:n,$resultsList:t,id:r.contextInformation.courseId,eid:r.id,name:r.displayName,lat:r.geo.lat,lon:r.geo.lon},e=GolfNow.Web.GeoPlaces.Course_Click;s.on("click",u,e).on("keypress",u,e);h.append(s);f.append(h)}))},function(i,r,u,o){o&&o.type!=="course"&&(g="city");i=i.slice(0,y);$.each(i,function(i,r){v+=i;h=$("<li />").addClass("location");s=$("<a />");l=$("<i />").addClass("ion-ios-location color-blue-primary");a=$("<span />").html(r.displayName);s.append(l).append(a);var u={$textbox:n,$resultsList:t,id:r.mongoId,eid:r.id,name:r.displayName,lat:r.geo.lat,lon:r.geo.lon},f=GolfNow.Web.GeoPlaces.Location_Click;s.on("click",u,f).on("keypress",u,f);h.append(s);e.append(h)});t.find(".google-logo").empty();t.find(".throbber").hide();e.show();f.show();e.find("li").length==0&&f.find("li").length==0&&t.find(".message").show()},ii(),ci,function(){var t=0,n=$("#autocomplete-wrapper ul.tabs li.tab-title"),u;n.removeClass("one-tab").removeClass("two-tab").removeClass("three-tab");f.find("li").length==0?($("#federatedResultsCoursesTab").hide(),t++):($("#federatedResultsCoursesTab a").html('<i class="ion-ios-flag color-green-primary"><\/i> Courses ('+Number(f.find("li").length)+")"),$("#federatedResultsCoursesTab").show());e.find("li").length==0?($("#federatedResultsLocationsTab").hide(),t++):($("#federatedResultsLocationsTab a").html('<i class="ion-ios-location color-blue-primary"><\/i> Locations ('+Number(e.find("li").length)+")"),$("#federatedResultsLocationsTab").show());switch(t){case 0:n.filter(":visible").addClass("three-tab");break;case 1:n.filter(":visible").addClass("two-tab");break;default:n.filter(":visible").addClass("one-tab")}i=null;r=null;f.find("li").length>0&&w()==="course"?$("#federatedResultsCoursesTab a").click():e.find("li").length>0&&w()==="city"?$("#federatedResultsLocationsTab a").click():$("#federatedResultsPreviousTab a").click();u=_.debounce(rt,o,!1);dt!=w()&&u()})}else tt(),p=$("#autocomplete-wrapper ul.tabs li.tab-title"),p.removeClass("one-tab").removeClass("two-tab").removeClass("three-tab"),$("#federatedResultsCoursesTab").hide(),$("#federatedResultsLocationsTab").hide(),$("#federatedResultsPreviousTab").is(":visible")&&$("#federatedResultsPreviousTab").addClass("one-tab").show().find("a").click(),f.empty(),e.empty(),dt=g="previous",ot()&&t.append(wt.clone())},o)}function ti(i){var l=$(".search-input-container"),a=i.find("form").parents(".search-input-row"),o,r,s,h,c;n=i.find("input[type=text].autocomplete");t=$("<ul />").addClass("mega").addClass("autocomplete-results").addClass("federatedSearchResults");t.append($("<li />").addClass("throbber padding-10 text-center").html('<img src="https://r3c8b5x6.ssl.hwcdn.net/Content/images/wait_sm.gif?v=201709220946" height="32" width="32">'));t.append($("<li />").addClass("message").html(yt));u=$("<div />").attr("id","autocomplete-wrapper").addClass("f-dropdown mega  federatedWrap").css("left","auto").css("display","none");u.append($("<div />").addClass("nearme").html(d));u.append(t);o=$("<ul />").addClass("tabs").attr("data-tab","");o.append($("<li />").addClass("tab-title active").attr("id","federatedResultsPreviousTab").addClass("one-tab").append($("<a />").attr("href","#federatedResultsPrevious").html('<i class="ion-ios-loop-strong"><\/i> Previous <span>Searches<\/span> ()')));o.append($("<li />").addClass("tab-title").css("display","none").attr("id","federatedResultsCoursesTab").append($("<a />").attr("href","#federatedResultsCourses").html('<i class="ion-ios-flag color-green-primary"><\/i> Courses ()')));o.append($("<li />").addClass("tab-title").css("display","none").attr("id","federatedResultsLocationsTab").append($("<a />").attr("href","#federatedResultsLocations").html('<i class="ion-ios-location color-blue-primary"><\/i> Locations ()')));u.append(o);r=$("<div />").addClass("tabs-content");vt=$("<div />").addClass("federatedSearchResults").append($("<ul />"));s=$("<div />").attr("id","federatedResultsPrevious").addClass("content active").append(vt);f=$("<div />").addClass("federatedSearchResults");h=$("<div />").attr("id","federatedResultsCourses").addClass("content active").append(f);e=$("<div />").addClass("federatedSearchResults");c=$("<div />").attr("id","federatedResultsLocations").addClass("content").append(e);r.append(s);r.append(h);r.append(c);r.append(r);u.append(r);n.after(u);$(document).foundation("tab","reflow");searchController&&GolfNow.Web.Client.SearchController.PopulatePreviousSearch(searchController)}function ft(t,i){if(t.type=="click"||t.type=="keypress"||t.keyCode==13){var f=i!==undefined&&i!==null?new Date(i.playDate):Date.today(),r=Number(i!==undefined&&i!==null?i.players:$("#fed-search-big-golfers").val())||0,e=n.val(),u=function(t){var i=t.Latitude,u=t.Longitude,f={SearchType:k,Latitude:i,Longitude:u,Players:r,Q:t.Address,QC:"GeoLocation"},e;searchController.SearchParameters.Set(f,!0);searchController.SaveFederatedSearchParameters({SearchType:k,Latitude:i,Longitude:u,Address:t.Address,Players:r});searchController.AddRecentSearch(-1,t.Address,"GEOLOCATION",i,u,null);d.find(".federatedNearMe a.nearMeLink span").text(t.Status.message);n.val(t.Address);e={searchType:"location",searchTerm:t.Address,lat:i,lng:u};n.data().searchData=e;TrackGoogleEvent("searchNearMe","Search","Search Near You",t.Address,1);_.delay(function(){searchController.RedirectToCustomSearchPage(f)},o)};GolfNow.Web.LocationServices.HasGPS&&GolfNow.Web.LocationServices.LocateMe(!0,u,u,!0)}}function et(t){var h,r,f,u,c,e,l,s;if(t.keyCode===13||t.type==="click")if(h=n.val(),r=n.data().searchData||{},r.players=Number($("#fed-search-big-golfers").val())||0,r.playDate=$("#fed-search-big-date").val()||Date.today().toString(GolfNow.Web.Utils.GetDefaultDateFormatString()),r.daysOut=st(Date.today(),new Date(r.playDate))||0,h==="")t.type==="click"?TrackGoogleEvent("searchButton","Search","Search Button","Click - No Search Term",1):TrackGoogleEvent("searchButton","Search","Search Button","Enter Keypress - No Search Term",1),_.delay(function(){$(".federatedWrap a.nearMeLink").trigger("click",r)},o);else{if(n.val()!==""&&!n.data().searchData){f="";u=searchController.SearchParameters.Get();switch(u.SearchType){case lt:f=u.FacilityName?u.FacilityName.replace(/\+/g," "):"";r.searchType="course";r.id=u.FacilityId||null;r.name=f;break;case k:case searchType_GoPlay:f=u.Address?u.Address.replace(/\+/g," "):"";r.searchType="location";r.lat=u.Latitude;r.lon=u.Longitude}f===n.val()?r.searchTerm=n.val():(c=$("ul.tabs > li.tab-title.active > a").attr("href"),e=$(c).find(".federatedSearchResults > li:first > a"),e.length&&(i=e),i?(n.trigger("blur"),i.trigger("click"),r=n.data().searchData,r.daysOut||(r.daysOut=st(Date.today(),new Date(r.playDate))),r.players||(r.players=Number($("#fed-search-big-golfers").val())||0),r.playDate||(r.playDate=$("#fed-search-big-date").val())):r.searchTerm=n.val())}l=r.searchTerm||n.val();s=l+" | "+r.daysOut+" | "+r.players;t.type==="click"?TrackGoogleEvent("searchButton","Search","Search Button","Click - "+s,1):TrackGoogleEvent("searchButton","Search","Search Button","Enter Keypress - "+s,1);_.delay(function(){GolfNow.Web.GeoPlaces.SearchBtn_Event(r)},o)}}function tt(){GolfNow.Web.LocationServices.Status(!1).done(function(n){d.find(".federatedNearMe a.nearMeLink span").text(n.message)})}function ot(){return bt}function ii(){return previewTop}function w(){return g}function st(n,t){var i=Math.abs(t.getTime()-n.getTime());return Math.ceil(i/864e5)}function ri(){return b}function ui(n){var t,i;it&&(n.preventDefault(),t=$(n.target),t.prop("id")!=="btn-search-tee-time"&&s.length&&(i=s.find("a.vip-cta").prop("href")||s.data("vipurl")||"/vip",y!==""&&p!==""&&TrackGoogleClickEvent("hp_hero_click",null,null,"hp_hero_"+y+"_"+p,null,i)))}function ht(){it&&s.length&&(y=s.data("vipbenefit")||"",p=s.data("vipcta")||"",y!==""&&p!==""&&TrackGoogleEvent("hp_hero_impression",null,null,"hp_hero_"+y+"_"+p,null))}var l=Object.create(HTMLElement.prototype),ct="SearchInputBig",h=!1,fi=document.querySelector("gn-search-input-big"),li=$(fi),b,ei,oi,si="",hi=null,lt="",k="",c=null,ci=0,at="",o=150,u=null,t=null,f=null,e=null,vt=null,n=null,d=null,yt="",a=null,pt=!1,wt=$('<li class="google-logo"/>').append($("<span />").addClass("pull-right").append($("<img />").addClass("google-logo"))),bt=usegoogleplaces,g="previous",v=".federatedSearchResults li a:visible",kt=".federatedSearchResults li a",r=null,i=null,nt=null,dt=w(),y,p,s,it,gt;return l.createdCallback=function(){GolfNow.Web.Page.Sub("show-refine-search-clicked",function(){h=!0});GolfNow.Web.Page.Sub("show-search-filters-clicked",function(){h=!0});GolfNow.Web.Page.Pub("widget_loading",{widgetName:ct});GolfNow.Web.Page.Sub("searchController_Initialized",function(n){return searchController=n,GolfNow.Web.Client.SearchController.InitializeFederatedSearch(),a.handlePreviousDateLink(),a.handleSortState(),Foundation.utils.is_medium_up()&&a.removeUnSupportedViewOptions($("#view-options > li > a")),Foundation.utils.is_medium_up()&&a.removeUnSupportedSortOptions($("#sort-options > li > a"),GolfNow.Web.Page.GetCurrentClientProfile()),GolfNow.Web.FederatedSearch.handlePageRefinements(),!1});GolfNow.Web.Page.Sub("set-filter-display-values",function(t){var r,u,i;ri()||(r=t.location==="Near You"?"":t.location,n.val(r),u=new Date(t.refinedObj.Date).toDateDisplayString(),$("#fed-search-big-date").val(u),i=t.refinedObj.Players||"0",i==="0"&&(i="any"),$("#fed-search-big-golfers").val(i))});GolfNow.Web.Page.Sub("window_resize",function(){});d=$('<div class="columns federatedNearMe">,<a class="button btn-blue expand nearMeLink hide"><i class="ion-android-locate"><\/i> <span>Search Near You<\/span><\/a>,<\/div>'.replace(/,/g,""));tt();ti($(this));this.readAttributes();a=GolfNow.Web.Search;gt();GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:ct});s=$(".universal-search");s.length?ht():_.delay(ht,300)},l.readAttributes=function(){},l.attributeChangedCallback=function(n,t,i){var r=this;/^(usegoogle)$/.test(n)&&t!=i&&(bt=i.toLowerCase()==="true"?!0:!1)},l.init=function(n){pt||(pt=!0,si=n.redirectToFacilityLink,hi=n.placeDetailService,lt=n.searchType_Facility,k=n.searchType_GeoLocation,searchType_GoPlay=n.searchType_GoPlay,yt=n.noResultsMessage,b=n.isHomePageSearch,ei=n.isSpecialRatesPage,oi=n.isFacilitySearch,it=n.isVIPEnabled,document.registerElement("gn-search-input-big",{prototype:l}))},gt=function(){n.on("keyup",ut);n.on("focusin",ut);n.on("focusin",function(){var i=!0,r=$(this),n=r.val().length;n>0&&(i=!1,r[0].setSelectionRange(0,n));n>0&&t.find(".location, .facility").length>1?u.show():i&&(tt(),t.find(".message").hide(),t.find(".throbber").hide(),t.find(".google-logo").remove(),ot()&&t.append(wt.clone()),u.show())}).on("focusout",function(){});$("div.inner-wrap").on("click",function(t){$(t.target).prop("id")!=n.prop("id")&&($(t.target).parents(".tabs").length>0||u.hide())});if($("#fed-search-big-date").length>0){var e=$("#fed-search-big-date").pickadate({min:!0,max:GolfNow.Web.Utils.GetMaximumCalendarDays(),clear:"",format:GolfNow.Web.Utils.GetDefaultDateFormatString().toLowerCase(),onSet:function(n){var t,i;n.select&&(t=null,_.isObject(n.select)?n.select.obj&&_.isDate(n.select.obj)&&(t=new Date(n.select.obj)):t=new Date(n.select),searchController.SavePickerSelectedDate(t),searchController.SetDate(t,!0),i=$("#fed-search-big-golfers"),i.length&&_.delay(function(){i.focus()},o))}}),s=e.pickadate("picker"),f=new Date(GolfNow.Web.Cache.GetActiveDate());s.set("select",[f.getFullYear(),f.getMonth(),f.getDate()],{muted:!0})}n.tooltipster({content:$('<p class="help-block"><strong class="required-text">Search Requirements<\/strong><br />Multiple Hyphens, Symbols, and Special Characters are not Allowed<br />'),trigger:"custom",position:"bottom-right"});$(".gn-button").find("li").on("click",function(n){n.preventDefault();$(this).addClass("active").siblings().removeClass("active");$(this).find("input[type=radio]").prop("checked",!0);$(this).siblings().find("input[type=radio]").prop("checked",!1)});$(document).on("open.fndtn.reveal","#searchModal",function(n){if(n.namespace==="fndtn.reveal"){var t=$(this);$("#pre-fedsearch").hasClass("homepage-search")&&(b=!0);t.prop("id")==="searchModal"&&h&&Foundation.utils.is_small_only()?($(".current-search").removeClass("show-for-medium-up"),$(".serach-bar").hide()):t.prop("id")==="searchModal"&&!h&&Foundation.utils.is_small_only()&&($(".current-search").addClass("show-for-medium-up"),$(".serach-bar").show());window.readyForAutoScroll=!1}});$(document).on("opened.fndtn.reveal","#searchModal",function(n){if(n.namespace==="fndtn.reveal"){var t=$(this);t.prop("id")==="searchModal"&&h?h=!1:t.prop("id")!=="searchModal"||h||(b?GolfNow.Web.Page.Pub("homepage-edit-search-clicked",null):GolfNow.Web.Page.Pub("edit-search-clicked",null));window.readyForAutoScroll=!1;GolfNow.Web.Client.ForceFullPageHeight()}});$(document).on("closed.fndtn.reveal","#searchModal",function(n){n.namespace==="fndtn.reveal"&&(GolfNow.Web.Client.ForceDefaultPageHeight(),window.readyForAutoScroll=!0)});$(".search-field").on("click",".federatedWrap a.nearMeLink",ft).on("keypress",".federatedWrap a.nearMeLink",ft);$("#fed-search-big").keydown(function(t){var f,u;if(t.keyCode==13||t.keyCode==38||t.keyCode==40||t.keyCode==9){if(f=$(t.target),r=$(v),i=$(".federatedSearchResults li a.selected"),nt=r.length,(t.keyCode===13||t.keyCode===9)&&(t.preventDefault(),t.keyCode===13?TrackGoogleEvent("enterKeyPress","Search","Enter Key Press","Type Ahead - "+n.val(),1):TrackGoogleEvent("tabKeyPress","Search","Tab Key Press","Type Ahead - "+n.val(),1),_.delay(function(){if($(".federatedSearchResults").is(":visible")){var n=i.attr("href");n!=null?window.location.href=n:(i.length||(i=r.first()),i.trigger("click"));$(".federatedWrap").hide()}else $(".federatedWrap").show()},o)),t.keyCode==38){if(i.length==0)return;u=i.index(v)-1;$(kt).removeClass("selected");u==-1?$(v).last().addClass("selected"):r.eq(u).addClass("selected")}t.keyCode==40&&rt()}});$(".autocomplete-results").on("mouseover","li",function(){$(".autocomplete-results li a").removeClass("selected");$("a",this).addClass("selected")});$(".autocomplete-results").on("mouseout","li",function(){$(".autocomplete-results li a").removeClass("selected")});$("gn-search-input-big").on("click","#description",ui).on("click","#btn-search-tee-time",et).on("keydown","#btn-search-tee-time",et);$("#fed-search-big-golfers").keydown(function(n){if(n.keyCode===13){var t=$(n.target);TrackGoogleEvent("enterKeyPress","Search","Enter Key Press","Golfers - "+t.val(),1);_.delay(function(){$("#btn-search-tee-time").focus()},o)}})},{initWidget:l.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.SearchInput=function(){function a(){var i=$(document.querySelector("gn-search-input"));$(".gn-button").find("li").on("click",function(n){n.preventDefault();$(this).addClass("active").siblings().removeClass("active");$(this).find("input[type=radio]").prop("checked",!0);$(this).siblings().find("input[type=radio]").prop("checked",!1)});$("#pre-fedsearch").on("focusin",function(){var n=$("#searchModal");try{n.foundation("reveal","open")}catch(t){GolfNow.Web.Utils.ConsoleWarn("OpenFederatedSearch:"+t)}return!1});i.on("click",".description-wrapper",v).on("click",".search-btn-small",GolfNow.Web.FederatedSearch.nearmeHandler);$(document).on("open.fndtn.reveal","#searchModal",function(n){if(n.namespace==="fndtn.reveal"){var i=$(this);$("#pre-fedsearch").hasClass("homepage-search")&&(c=!0);i.prop("id")==="searchModal"&&t&&(Foundation.utils.is_small_only()||e)?($(".current-search").removeClass("show-for-medium-up"),$(".serach-bar").hide()):i.prop("id")==="searchModal"&&!t&&(Foundation.utils.is_small_only()||e)&&($(".current-search").addClass("show-for-medium-up"),$(".serach-bar").show());GolfNow.Web.LocationServices.Status(!1).done(function(n){$(".federatedNearMe a.nearMeLink span").text(n.message)});window.readyForAutoScroll=!1;$.scrollTo("#main-header")}});$(document).on("opened.fndtn.reveal","#searchModal",function(n){var r,u;if(n.namespace==="fndtn.reveal"){var i=$(this),f=searchController.GetRestoreFedSearchKey(),e=typeof f.Location=="undefined"?"":f.Location;i.find("#fedsearch").val(GolfNow.Web.Utils.UrlDecodeString(e));i.prop("id")==="searchModal"&&t?(GolfNow.Web.Client.SearchController.StepThree(),t=!1):i.prop("id")!=="searchModal"||t||(c?GolfNow.Web.Page.Pub("homepage-edit-search-clicked",null):GolfNow.Web.Page.Pub("edit-search-clicked",null),GolfNow.Web.Client.SearchController.StepOne(),r=i.find("#fedsearch"),u=!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform),u||r.focus(),r.select());$("html, body").animate({scrollTop:$("#modalTitle").offset().top},800,function(){GolfNow.Web.Client.ForceFullPageHeight()});i.css({top:0})}});$(document).on("closed.fndtn.reveal","#searchModal",function(n){if(n.namespace==="fndtn.reveal"){var t=$(this);GolfNow.Web.Client.ForceDefaultPageHeight();window.readyForAutoScroll=!0}});$("#pre-fedsearch").on("click",function(){$(this).blur()});if($("#fed-search-big-date").length>0){var r=$("#fed-search-big-date").pickadate({min:!0,max:GolfNow.Web.Utils.GetMaximumCalendarDays(),clear:"",format:GolfNow.Web.Utils.GetDefaultDateFormatString().toLowerCase(),onSet:function(n){if(n.select){var t=new Date(n.select);searchController.SetDate(t,!0)}}}),u=r.pickadate("picker"),n=new Date(GolfNow.Web.Cache.GetActiveDate());u.set("select",[n.getFullYear(),n.getMonth(),n.getDate()],{muted:!0})}}function v(t){var r,i;o&&(t.preventDefault(),r=$(t.target),n.length&&(i=n.find("a.vip-cta").prop("href")||n.data("vipurl")||"/vip",u!==""&&f!==""&&TrackGoogleClickEvent("hp_hero_click",null,null,"hp_hero_"+u+"_"+f,null,i)))}function s(){o&&n.length&&(u=n.data("vipbenefit")||"",f=n.data("vipcta")||"",u!==""&&f!==""&&TrackGoogleEvent("hp_hero_impression",null,null,"hp_hero_"+u+"_"+f,null))}var i=Object.create(HTMLElement.prototype),h="SearchInput",t=!1,e=!1,c=!1,r=null,l=!1,u,f,n,o;return i.createdCallback=function(){var u,i;GolfNow.Web.Page.Sub("show-refine-search-clicked",function(){t=!0});GolfNow.Web.Page.Sub("show-search-filters-clicked",function(n){e=n.mediumOverride||!1;t=!0});GolfNow.Web.Page.Sub("window_resize",function(){});GolfNow.Web.Page.Sub("searchController_Initialized",function(n){return searchController=n,GolfNow.Web.Client.SearchController.InitializeFederatedSearch(),r.handlePreviousDateLink(),r.handleSortState(),Foundation.utils.is_medium_up()&&r.removeUnSupportedViewOptions($("#view-options > li > a")),Foundation.utils.is_medium_up()&&r.removeUnSupportedSortOptions($("#sort-options > li > a"),GolfNow.Web.Page.GetCurrentClientProfile()),GolfNow.Web.FederatedSearch.handlePageRefinements(),!1});GolfNow.Web.Page.Pub("widget_loading",{widgetName:h});u=this;this.readAttributes();r=GolfNow.Web.Search;a();GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:h});n=$(".universal-search");n.length?s():_.delay(s,300);i=$(u).parents("section");i.hasClass("search-results")||i.insertBefore("header > section.heading.deepNav");i.find("gn-search-input").removeClass("hide")},i.readAttributes=function(){},i.attributeChangedCallback=function(){},i.init=function(n){l||(l=!0,o=n.isVIPEnabled,document.registerElement("gn-search-input",{prototype:i}))},{initWidget:i.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.SearchRefine=function(){var n=Object.create(HTMLElement.prototype),i="SearchRefine",t=null;return n.createdCallback=function(){GolfNow.Web.Page.Sub("searchController_Initialized",function(n){return searchController=n,GolfNow.Web.Client.SearchController.InitializeFederatedSearch(),t.handlePreviousDateLink(),t.handleSortState(),Foundation.utils.is_medium_up()&&t.removeUnSupportedViewOptions($("#view-options > li > a")),Foundation.utils.is_medium_up()&&t.removeUnSupportedSortOptions($("#sort-options > li > a"),GolfNow.Web.Page.GetCurrentClientProfile()),GolfNow.Web.FederatedSearch.handlePageRefinements(),!1});GolfNow.Web.Page.Pub("widget_loading",{widgetName:i});var n=this;this.readAttributes();t=GolfNow.Web.Search;$("#fedresults").text()===""&&searchController&&searchController.GetRestoreFedSearchKey();GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:i});GolfNow.Web.Page.Sub("window_resize",function(){})},n.readAttributes=function(){},n.attributeChangedCallback=function(){},n.init=function(){document.registerElement("gn-search-refine",{prototype:n})},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.SearchResultActions=function(){function a(){for(var n,i,r=[],t=0;t<c.length;t++)n=c[t],i=n.isPath?n.tmplPath:"/Tmpls/_"+n.tmplPath+".tmpl.html",r.push(GolfNow.Web.Client.LoadTemplate(i,n.accessorName,n.helpers));return r}function v(){var t=$(document),o=document.querySelector("gn-search-result-actions"),s=$(o);u();$("#selSortOptions").on("change",r);$("gn-search-result-actions, gn-search-results, #sortModal").on("click","a.sort-criteria-option",r);$("gn-search-result-actions, #viewModal").on("click","a.view-criteria-option",e);t.on("click",".filtersToggle",function(){GolfNow.Web.FederatedSearch.ShowAdvancedSearch(searchController);$(".off-canvas-wrap").foundation("offcanvas","show","offcanvas-overlap-right");Foundation.utils.is_medium_only()&&$("gn-search-filters aside.left-off-canvas-menu > .filters.search-options-wrap").height($(".inner-wrap").height()+500)});t.on("open.fndtn.reveal","#sortModal",function(t){t.namespace==="fndtn.reveal"&&(n.removeUnSupportedSortOptions($("li a.sort-criteria-option"),i),$.scrollTo("#main-header"))});t.on("opened.fndtn.reveal","#sortModal",function(n){if(n.namespace==="fndtn.reveal"){var t=$(this);t.css({top:0});GolfNow.Web.Client.ForceFullPageHeight()}});t.on("closed.fndtn.reveal","#sortModal",function(n){n.namespace==="fndtn.reveal"&&GolfNow.Web.Client.ForceDefaultPageHeight()});t.on("open.fndtn.reveal","#viewModal",function(t){t.namespace==="fndtn.reveal"&&(n.removeUnSupportedViewOptions($(this).find("li a.view-criteria-option")),$.scrollTo("#main-header"))});t.on("opened.fndtn.reveal","#viewModal",function(n){if(n.namespace==="fndtn.reveal"){var t=$(this);t.css({top:0});GolfNow.Web.Client.ForceFullPageHeight()}});t.on("closed.fndtn.reveal","#viewModal",function(n){n.namespace==="fndtn.reveal"&&GolfNow.Web.Client.ForceDefaultPageHeight()});t.on("opened.fndtn.dropdown","#view-options",function(t){t.namespace==="dropdown.fndtn"&&n.removeUnSupportedViewOptions($(this).find("li a"))});t.on("opened.fndtn.dropdown","#sort-options",function(t){t.namespace==="dropdown.fndtn"&&n.removeUnSupportedSortOptions($(this).find("li a"),i)});if(GolfNow.Web.Page.Sub("close-result-action-menus",function(){$(".f-dropdown.open").click()}),!f)s.on("click",".search-results-heading a#lnkfedresults",function(n){n.preventDefault();var t=$(".filters.search-options-wrap a#location");t.length&&t.click()})}function r(){var r=$(this),t=r.data("sort-criteria"),i,u,f;if(t!==""){if(i=searchController.SearchParameters.Get(),u=i.SortBy,r.parent().hasClass("list-group-item")||t.indexOf("|")===-1&&(t+=u===t?i.SortDirection==0?"|1":"|0":"|0"),!n.isSortAllowed(t)){$("#sortModal").foundation("reveal","close");return}f=i.SortBy+"|"+i.SortDirection;f!==t?searchController.ChangeSort(t):$("#sortModal").foundation("reveal","close")}}function e(){var r=$(this),t=r.data("view-criteria"),i;t!==""&&(i=searchController.SearchParameters.Get(),i.View!==t?(searchController.ChangeView(t),n.handleSortState()):$("#viewModal").foundation("reveal","close"))}function u(){if(i=="small")$(".view-dropdown-menu a.dd-link").removeAttr("data-dropdown").removeAttr("data-options").attr("data-reveal-id","viewModal"),$(".sort-dropdown-menu a.dd-link").removeAttr("data-dropdown").removeAttr("data-options").attr("data-reveal-id","sortModal"),$(".view-dropdown-menu").attr("data-reveal-id","viewModal"),$(".sort-dropdown-menu").attr("data-reveal-id","sortModal");else{$(".view-by-btns").on("click","li > a",e);$(".sort-dropdown-menu").on("click","ul > li > a",r).find("a.dd-link").removeAttr("data-reveal-id").attr("data-dropdown","sort-options").attr("data-options","is_hover:false")}}var t=Object.create(HTMLElement.prototype),o="SearchResultActions",y="",n=null,s="",h=!1,p=!1,w=!1,i="",b=!1,c=[{tmplPath:"SearchResultActions",accessorName:"searchResultActionsTemplate",isPath:!1},{tmplPath:"SearchResultActionsSmall",accessorName:"searchResultActionsSmallTemplate",isPath:!1}],l,f=!1;return t.createdCallback=function(){var t=this;GolfNow.Web.Page.Sub("searchController_Initialized",function(t){return searchController=t,GolfNow.Web.Client.SearchController.InitializeFederatedSearch(),n.handlePreviousDateLink(),n.handleSortState(),Foundation.utils.is_medium_up()&&n.removeUnSupportedViewOptions($("#view-options > li > a")),Foundation.utils.is_medium_up()&&n.removeUnSupportedSortOptions($("#sort-options > li > a"),GolfNow.Web.Page.GetCurrentClientProfile()),GolfNow.Web.FederatedSearch.handlePageRefinements(),!1});GolfNow.Web.Page.Pub("widget_loading",{widgetName:o});this.readAttributes();n=GolfNow.Web.Search;v();GolfNow.Web.Page.Sub("window_resize",function(){u()});GolfNow.Web.Page.Sub("set-filter-display-values",_.debounce(function(n){var t=$("#fedresults");t.length&&t.text()===""&&t.text(n.location)}),300)},t.readAttributes=function(){this.fedResultsElement=y=this.querySelector("#fedresults")},t.attributeChangedCallback=function(){},t.init=function(n){n.disableChangeLocation!==null&&(f=n.disableChangeLocation);document.registerElement("gn-search-result-actions",{prototype:t});b=Foundation.utils.is_small_only()?!1:!0;s=n.locationHeadingLabel;h=n.disableAdvanceSearch;p=n.disableCourseView;w=n.disableMapView;i=n.serverDisplayMode;l=n.isSpecialRatesPage;$.when.apply(this,a()).then(function(){i.toLowerCase()=="small"?$("gn-search-result-actions").html($.render.searchResultActionsSmallTemplate({disableAdvancedSearch:h})):$("gn-search-result-actions").html($.render.searchResultActionsTemplate({locationHeadingLabel:s,isSpecialRatesPage:l,disableChangeLocation:f}));u()}).done(function(){GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:o})})},{initWidget:t.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.SearchResults=function(){function a(){$("gn-search-results").on("click",".view-tt-button > span.button",function(){var n=$(this).data("href");n!==""&&(document.location.href=n)});$("gn-search-results").on("click",".search-refine-btn",function(t){t.preventDefault();Foundation.utils.is_medium_only()&&GolfNow.Web.Utils.GetServerDisplayMode()=="medium"?$(".off-canvas-wrap").foundation("offcanvas","show","offcanvas-overlap-right"):(GolfNow.Web.FederatedSearch.ShowAdvancedSearch(n),GolfNow.Web.Client.SearchController.ShowRefineSearch())});GolfNow.Web.Page.Sub("window_resize",function(){})}function v(){if(i)switch(GolfNow.Web.Utils.GetSearchTypeName(i.SearchType)){case"Facility":$("ul li#expandRadius, ul li#changeLocation").hide();break;case"GoPlay":$("ul li#expandRadius, ul li#updateSettings, ul li#changeLocation").hide()}}function y(){if(i.Address&&i.Address!=="")return i.Address;GolfNow.Web.LocationServices.Status(!1).done(function(n){return n.City&&n.State?n.City+", "+n.State:null})}function p(){var t={HotDealsOnly:f==="null"?null:f,Radius:r==="null"?null:r,Players:e==="null"?null:e,Date:u==="null"?null:u,Holes:o==="null"?null:o,PriceMin:s==="null"?null:s,PriceMax:h==="null"?null:h},i,v,a,l;if(n.redirectOnSearch=!0,i=n.SearchParameters.Get(),t.View=i.View,t.SortBy=i.SortBy,v=GolfNow.Web.Utils.GetSearchTypeName(i.SearchType),v==searchType_Facility){var y=i.FacilityId,w=i.FacilityName,p=redirectToFacilityLink.toLowerCase().replace("[facilityid]",y);n.SearchParameters.Set(t);n.SaveSearchParameters(t);window.location.pathname.startsWith(p)?(n.DoSearch(),GolfNow.Web.Client.SearchController.CloseFederatedSearch()):(redirectToFacilityLink=redirectToFacilityLink.toLowerCase().replace("[facilityid]",facilityid),window.location=redirectToFacilityLink)}else n.SaveCurrentFederatedSearchParameters(),n.ShouldRedirectOnSearch()?n.RedirectToCustomSearchPage(t):(n.SearchParameters.Set(t),n.SaveSearchParameters(t),a=n.GetRestoreFedSearchKey(),$("#fedresults").html(a.location),l=a.radius,l!=""&&(l+=" miles from"),$("#fedresults-distance").html(l),$("#fedsearch").val(""));t.Date&&n.SetDisplayDates(Date.parse(t.Date));c=!1}var t=Object.create(HTMLElement.prototype),w=GolfNow.Web.Search,l="SearchResults",b=20,k=!1,d=!0,g=20,nt="",tt=1,r=GolfNow.Web.Utils.GetDefaultSearchRadius(),it="",u=Date.today(),rt=GolfNow.Web.Utils.GetDefaultSearchView(),ut=GolfNow.Web.Utils.GetDefaultSearchSort(),f=!1,e="",o=18,s="",h="",ft=GolfNow.Web.Utils.GetDefaultRateType(),n=null,i=null,c=!1;return t.createdCallback=function(){GolfNow.Web.Page.Pub("widget_loading",{widgetName:l});this.readAttributes();this.loadItems()},t.readAttributes=function(){this.authenticated=k=this.getAttribute("authenticated").toLowerCase()==="true"?!0:!1;this.userName=nt=this.getAttribute("username");this.showFeatured=d=this.getAttribute("show-featured").toLowerCase()==="true"?!0:!1;this.pageSize=g=Number(this.getAttribute("items"));isNaN(this.pageSize)&&(this.pageSize=20);this.featuredFacilityFrequency=b=Number(this.getAttribute("featured-per-items"));isNaN(this.featuredFacilityFrequency)&&(this.featuredFacilityFrequency=20);this.currentPage=tt=Number(this.getAttribute("current-page"));this.timePeriod=u=this.getAttribute("time-period");this.view=rt=this.getAttribute("view");this.sort=ut=this.getAttribute("sort");this.location=it=y()||this.getAttribute("location");this.radius=r=this.getAttribute("radius");this.hotDealsOnly=f=this.getAttribute("hot-deals-only");this.players=e=this.getAttribute("players");this.holes=o=this.getAttribute("holes");this.priceMin=s=this.getAttribute("price-min");this.priceMax=h=this.getAttribute("price-max");this.rateType=ft=this.getAttribute("rate-type")},t.loadItems=function(){a();v();n=w.initializeSearch();$.when.apply(this,n.LoadTemplates()).done(function(){n.Initialize(i,!0);GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:l})})},t.attributeChangedCallback=function(t,i,r){var e=this;if(/^(current-page)$/.test(t)){var u=Number(i),f=Number(r),o=++u===f;isNaN(f)||isNaN(u)||f!==u||!o||(this.readAttributes(),n.NextResult(nextWaitingHandler))}else/^(time-period|view|sort|radius|location|hot-deals-only|players|holes|price-min|price-max|rate-type)$/.test(t)&&(c||(c=!0,setTimeout(function(){e.readAttributes();p()},500)))},t.init=function(n){i=n;document.registerElement("gn-search-results",{prototype:t})},{initWidget:t.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.VisitedCourses=function(){"use strict";function u(){var i=this,t=[];$.when(y(t)).then(p(t)).done(function(t){var l,a,u,c,i,v,r,y;if(t.length){for(l=$(h),a=$(s),t.sort(function(n,t){return n.type<t.type?-1:n.type>t.type?1:0}),u=0,c=0;c<t.length;c++)switch(t[c].type){case"bookings":i=t[c].data;i.length>n&&(i=i.slice(0,n));u=i.length;i=$.map(i,function(n){return n.label=f(n.label),n});v=$.render.bookingsTmpl(i);a.html(v).show();e($.map(i,function(n){return n.id}));break;case"facilities":r=t[c].data;r.length>n&&(r=r.slice(0,n-u));r.length>0&&u<=n&&(u>0&&(r=r.slice(0,n-u)),y=$.render.bookingsTmpl(r),l.html(y).show(),e($.map(r,function(n){return n.id})),u++)}u>0&&$("#previouslyvisitedcourses").show();l.is(":visible")&&a.is(":visible");a.find("a,span.button").on("click",o);l.find("a,span.button").on("click",o)}}).fail(function(n){GolfNow.Web.Utils.ConsoleLog("DecisionTree Fail: "+n)}).always(function(){r=!1})}function y(t){var u=$.Deferred(),f=this,r=GolfNow.Web.Tracking.Customer.GetReservations();return i||i==="true"?$.isEmptyObject(r)||r.length===0?w().done(function(i){var e,f;if(i.length){for(e=i.length,i.length>n&&(e=n),f=0;f<e;f++)GolfNow.Web.Tracking.Customer.AddReservation(i[f].facilityId,i[f].facility.name,i[f].facility.address,i[f].facility.imagePathURL,{averageRating:i[f].facility.averageRating||0,reviewCount:i[f].facility.reviewCount||0},i[f].facility.seoFriendlyName);r=GolfNow.Web.Tracking.Customer.GetReservations();t.push({type:"bookings",data:r});u.resolve(t)}else u.resolve(t)}).fail(function(n){GolfNow.Web.Utils.ConsoleLog("Ajax Fail: "+n);u.reject(n)}):(t.push({type:"bookings",data:r}),u.resolve(t)):(!$.isEmptyObject(r)&&r.length>0&&t.push({type:"bookings",data:r}),u.resolve(t)),u.promise()}function p(t){var e=$.Deferred(),v=this,l=$.grep(t,function(n){return n.type==="bookings"}).length,u,i,h,o,r,c,a,s;if(l>0&&t[0].data.length===n)e.resolve(t);else if(u=GolfNow.Web.Tracking.Customer.GetFacilities(),!$.isEmptyObject(u)&&$.isArray(u)&&u.length){i={};h=[];$.each(u,function(n,t){o=t.id;i.hasOwnProperty(o)?i[o].count+=1:i[o]={count:n,facility:t}});for(r in i)i[r].facility.label=f(i[r].facility.label),c=!1,l>0&&(a=t[0].data.filter(function(n){return Number(n.id)===Number(r)}),c=a.length>0),c||h.push({count:i[r].count,facility:i[r].facility}),GolfNow.Web.Utils.ConsoleLog(r+"::"+$("<div/>").html(decodeURIComponent(i[r].facility.label)).text()+" - ("+i[r].count+")");s=$.map(h.sort(function(n,t){return n.count-t.count}),function(n){return n.facility});s=s.slice(0,n);t.push({type:"facilities",data:s});e.resolve(t)}else e.resolve(t);return e.promise()}function w(){var n=$.Deferred();return $.ajax({url:"/api/account/bookedcourses",type:"GET",contentType:"application/json; charset=utf-8",dataType:"json"}).done(function(t){n.resolve(t)}).fail(function(t,i,r){GolfNow.Web.Utils.ConsoleLog("getBookings Fail: "+r);n.resolve([])}),n.promise()}function f(n){return $("<div/>").html(decodeURIComponent(n).replace(/\+/g," ")).text()}function e(n,t){if(t=t===undefined?0:t,n=_.reject(n,function(n){return!n}),n.length){var i=Date.today().addDays(t).toString("yyyy-MM-ddThh:mm:ss"),r={facilityIds:n,predicateDate:i};GolfNow.Web.Request.Post("other-courses-pricing","/api/tee-times/facilities-result",JSON.stringify(r)).done(function(n){n&&n.batchResults&&_.each(n.batchResults,function(n){var i=$("#previouslyvisitedcourses #"+n.facilityId),s=$.render.bookingsFromPriceTmpl(n),t,r;i.append(s);t=i.parents("a[data-facilityid='"+n.facilityId+"']");t.data("daysout",GolfNow.Web.Date.DaysFromToday(n.minDate));n.minPrice||(r="/courses/"+n.courseDetailSeoFriendlyName,t.attr("href",r));var u="",f="",e="",o="";n.address!==null&&(u=n.address.city,f=n.address.stateProvinceCode,e=n.address.country);n.minPrice!==null&&(o=n.minPrice.formattedValue);GolfNow.Web.Analytics.Google.Ecommerce.ProductImpression(n.facilityName,n.facilityId,o,"","",u,f,e)})}).fail(function(n,t,i){var r=n.responseJSON;GolfNow.Web.Utils.ConsoleWarn("Pricing data request failed for one or more Facilities.\nError: "+i)})}}function o(n){var f;n.preventDefault();n.stopPropagation();var t=$(this),i=!1,r=t.prop("href"),e=t.data("facilityid"),u=t.data("facilityname"),o=Number(t.data("daysout"));t.is("a")?i=t.find(".view-tt-button > span").hasClass("check-next-day"):(r=t.data("href"),i=t.hasClass("check-next-day"));u===null&&(u=t.parents("a").data("facilityname"));TrackGoogleClickEvent("previouslyVisited","Search","Previously Visited Courses",u+"|"+e,1,r);f=new GolfNow.Web.Client.SearchController("");i?document.location.href=r:f.SetDate(Date.today().add(o).days(),!0)}function b(){for(var n,i,r=[],t=0;t<v.length;t++)n=v[t],i=n.isPath?n.tmplPath:"/Tmpls/_"+n.tmplPath+".tmpl.html",r.push(GolfNow.Web.Client.LoadTemplate(i,n.accessorName,n.helpers));return r}function k(n){return typeof n=="object"}function d(){return a}var t=Object.create(HTMLElement.prototype),i=!1,s="",h="",n=3,g="",c="VisitedCourses",l=!1,r=!1,a="",v=[{tmplPath:"VisitedCoursesSingle",accessorName:"bookingsTmpl",isPath:!1,helpers:{urldecode:GolfNow.Web.Utils.UrlDecodeString,isobject:k,units:GolfNow.Web.Utils.AppendRadiusUnits,phoneNumber:d}},{tmplPath:"VisitedCoursesSinglePricing",accessorName:"bookingsFromPriceTmpl",isPath:!1,helpers:{istoday:GolfNow.Web.Date.IsToday,daysout:GolfNow.Web.Date.DaysFromToday}},{tmplPath:"StarRatings",accessorName:"starRatingsTemplate",isPath:!1}];return t.createdCallback=function(){GolfNow.Web.Page.Pub("widget_loading",{widgetName:c});var n=this;GolfNow.Web.Domains.BookingCenterPhone().done(function(n){a=n});this.readAttributes();this.innerHTML='<div class="row">,<div class="columns medium-9 small-12">,<h2 class="color-gray-darker featured-courses-header">,Your Recently Viewed Courses,<\/h2>,<\/div>,<div class="columns medium-3 small-12 hot-deals-container hide-for-small-only">,<a class="button btn-orange right geo-hotdeals">,Hot Deals Near You,<\/a>,<\/div>,<div class="columns small-12">,<hr />,<\/div>,<\/div>,<div id="mycourses" class="results-wrap"><\/div>,<div id="myviews" class="results-wrap"><\/div>'.replace(/,/g,"");this.coursesElement=s=this.querySelector("#mycourses");this.viewsElement=h=this.querySelector("#myviews");this.loadItems()},t.readAttributes=function(){this.authenticated=i=this.getAttribute("authenticated").toLowerCase()==="true"?!0:!1;this.userName=g=this.getAttribute("username");this.items=n=Number(this.getAttribute("items"));isNaN(this.items)&&(this.items=3)},t.loadItems=function(){var n=this;$.when.apply(this,b()).then(u).done(function(){GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:c});GolfNow.Web.Page.Sub("window_resize",function(){})})},t.attributeChangedCallback=function(n){var t=this;/^(items)$/.test(n)&&(r||(r=!0,setTimeout(function(){t.readAttributes();u()},500)))},t.init=function(){l||(l=!0,document.registerElement("gn-visited-courses",{prototype:t}))},{initWidget:t.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.UpdateAccount=function(){function a(){var n=document.getElementById("selCountryCode"),t=n.options[n.selectedIndex];GolfNow.Web.Client.FormUtilities.SetZipCodeValidations($("#PostalZip"),t.value);l=$("#frmUpdateAccount").validate({errorElement:"small",rules:{UserName:{gnUserNameValidate:"Special characters not allowed: /#!@@$%^&*].)(+=_-"},PostalCode:{gnPostalCodeRequired:"#selCountryCode",gnPostalCodeFormat:"#selCountryCode"}},onfocusout:function(n){var t=$(n);t.valid()?t.parent("label").removeClass("error").addClass("valid"):t.parent("label").removeClass("valid").addClass("error")},highlight:function(n,t,i){var r=$(n);r.addClass(t).removeClass(i);r.parent("label").addClass(t).removeClass(i)},unhighlight:function(n,t,i){var r=$(n);r.addClass(i).removeClass(t);r.parent("label").addClass(i).removeClass(t)},submitHandler:function(n){var t=$(n);return w(t,c),!1}});validateForm()}function o(){$("#frmUpdateAccount").valid()?$("#btnSubmit").addClass("btn-green").removeAttr("disabled"):$("#btnSubmit").addClass("btn-green").prop("disabled",!0)}function v(){$("gn-update-account").on("keyup","input",o).on("change","select",o);$("#btnCancel").on("click",function(){window.location.href=r});$("#selCountryCode").change(function(){var t=document.getElementById("selCountryCode"),i=t.options[t.selectedIndex],n=$("#PostalZip");GolfNow.Web.Client.FormUtilities.SetZipCodeValidations(n,i.value);$.inArray(i.value.toLowerCase(),["ie","bm"])===-1?n.prop("placeholder","Postal Code *"):n.prop("placeholder","Postal Code");s()});$("#PostalZip").on("change",function(){var n=document.getElementById("selCountryCode"),t=n.options[n.selectedIndex]})}function s(){var n=document.getElementById("selCountryCode"),t=n.options[n.selectedIndex];$.ajax({url:"/Account/GetStates/",dataType:"html",contentType:"text/html; charset=UTF-8",data:{countryCode:t.value,name:"StateCode",selectedValue:u},success:function(n){var i=$("#StateDrop"),t=$("#state-dropdown"),r=$(n);i.find("select").remove();r.prop("disabled")?(i.find("sup").remove(),t.prepend(n)):(i.find("sup").length?t.empty().prepend(n):(t.before("<sup>*<\/sup>"),t.empty().prepend(n)),f&&t.find("#StateCode").attr("disabled",f))}})}function y(n){n.find("button:submit").prepend('<i class="ion-load-d"><\/i>&nbsp;')}function p(n){n.find("button:submit").find(".ion-load-d").remove()}function w(n,t){if(n.valid()){y(n);$("button:submit, button:reset").prop("disabled",!0);var i={};n.serializeArray().map(function(n){i[n.name]=n.value});$("input[disabled], select[disabled]").each(function(){i[$(this).attr("name")]=$(this).val()});i.StateCode===""&&$("#StateCode").prop("disabled")&&(i.StateCode=u);GolfNow.Web.Request.Post("User_AccountInfoUpdate",t,JSON.stringify(i),{dataType:"json",contentType:"application/json; charset=UTF-8"}).done(function(n){n.success&&n.error===""&&showMessage("Update Account Success","Your Account has been updated.",function(){window.location.href=r})}).fail(function(n){var t=n.responseJSON.modelState,u,i,r,f,e;if(t)if(t.unhandledExceptions)u=t.unhandledExceptions[0],showMessage("Submission Error",u);else{i={};for(r in t)t.hasOwnProperty(r)&&(f=r.split(".")[1],e=t[r][0],i[f]=e);$.isEmptyObject(i)||l.showErrors(i)}else n.error!==""?showMessage("Submission Error",n.error):showMessage("Submission Error","There was an error submitting the form, please try again.")}).always(function(){$("button:submit, button:reset").removeAttr("disabled");p(n)})}}var n=Object.create(HTMLElement.prototype),h="UpdateAccount",c,r,u,f=!1,l,e=null,t=Foundation.utils.is_medium_up(),i=!1;return n.createdCallback=function(){GolfNow.Web.Page.Sub("searchController_Initialized",function(n){return searchController=n,GolfNow.Web.Client.SearchController.InitializeFederatedSearch(),e.handlePreviousDateLink(),e.handleSortState(),!1});GolfNow.Web.Page.Pub("widget_loading",{widgetName:h});var n=this;this.readAttributes();e=GolfNow.Web.Search;s();v();a();GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:h});GolfNow.Web.Page.Sub("window_resize",function(){!t&&Foundation.utils.is_medium_up()?i=!0:t&&!Foundation.utils.is_medium_up()&&(i=!0);i&&(i=!1,Foundation.utils.is_medium_up()?(t=!0,$(".accordion-navigation > div").addClass("active")):(t=!1,$(".accordion-navigation > div").removeClass("active")))})},n.readAttributes=function(){},n.attributeChangedCallback=function(){},n.init=function(t,i,e,o){c=t;r=i;u=e;f=o;document.registerElement("gn-update-account",{prototype:n})},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.OtherCourses=function(){"use strict";function ut(){for(var n,i,r=[],t=0;t<nt.length;t++)n=nt[t],i=n.isPath?n.tmplPath:"/Tmpls/_"+n.tmplPath+".tmpl.html",r.push(GolfNow.Web.Client.LoadTemplate(i,n.accessorName,n.helpers));return r}function w(){var o=document.querySelector("gn-other-courses"),n=$(o),f=$(b),e={PageSize:t,PageNumber:1,Date:Date.today().toDateDisplayString(),SortBy:GolfNow.Web.Utils.GetDefaultSearchSort(),SortByRollup:GolfNow.Web.Utils.GetDefaultSearchSort(),SortDirection:0,Latitude:i,Longitude:r,Radius:u,View:"Courses-Near-Me"};tt.Post("other-courses","/api/tee-times/tee-time-results",JSON.stringify(e)).done(function(t){var i,r,u;if(t&&t.ttResults&&t.ttResults.facilities&&t.ttResults.facilities.length>0)if(i=_.map(t.ttResults.facilities,function(n){return n.facilityId}),i=_.reject(i,function(n){return!n}),i.length){ft(i,e.Date);$("#othercourses").slideDown();y&&(r=$.render.otherCoursesRecordCountTmpl({total:t.total,pageSize:t.ttResults.predicate.pageSize,viewAllUrl:rt}),$(d).empty().append(r).show());n.find(".container.throbber").hide();u=$.render.cubeRollupTemplate(t.ttResults.facilities);f.html(u).slideDown();f.find("a,span.button").on("click",et)}else n.hide();else n.hide()}).fail(function(){GolfNow.Web.Utils.ConsoleError("Failed to get other courses.");n.hide()}).always(function(){v=!1})}function ft(n,t){var i={facilityIds:n,predicateDate:t};tt.Post("other-courses-pricing","/api/tee-times/facilities-result",JSON.stringify(i)).done(function(n){var t=_.uniq(n.batchResults,!1,function(n){return n.facilityId});_.each(t,function(n){var i=$("#othercourses .result #"+n.facilityId+" .row"),u=$.render.cubeRollupPricingTmpl(n),t,r;i.append(u);t=i.parents("a#"+n.facilityId);t.data("daysout",GolfNow.Web.Date.DaysFromToday(n.minDate));n.minPrice||(r="/courses/"+n.courseDetailSeoFriendlyName,t.attr("href",r))})}).fail(function(){GolfNow.Web.Utils.ConsoleError("Failed to get other courses pricing")})}function et(){var n=$(this),t=!1,i=Number(n.data("daysout"));t=n.is("a")?n.find("span").hasClass("check-next-day"):n.hasClass("check-next-day");t?document.location.href=href:searchController.SearchParameters.Set({Date:Date.today().add(i).days()},!0)}var n=Object.create(HTMLElement.prototype),ot=!1,st="",t=3,s=0,ht="",ct="",i=0,r=0,h=0,c=0,u=25,b="",k="",l="",a="",d="",g="OtherCourses",nt=[{tmplPath:"OtherCoursesCubeRollup",accessorName:"cubeRollupTemplate",isPath:!1,helpers:{units:GolfNow.Web.Utils.AppendRadiusUnits}},{tmplPath:"CubeRollupSinglePricing",accessorName:"cubeRollupPricingTmpl",isPath:!1,helpers:{istoday:GolfNow.Web.Date.IsToday,daysout:GolfNow.Web.Date.DaysFromToday}},{tmplPath:"StarRatings",accessorName:"starRatingsTemplate",isPath:!1},{tmplPath:"OtherCoursesRecordCount",accessorName:"otherCoursesRecordCountTmpl",isPath:!1},{tmplPath:"CubeRollupSingleCheckTomorrow",accessorName:"cubeRollupCheckTomorrowTmpl",isPath:!1}],f=GolfNow.Web.LocationServices,tt=GolfNow.Web.Request,v=!1,it=!1,e="",o=!0,y=!1,rt="",p="";return n.createdCallback=function(){var n=this,t;$("#othercourses").show();GolfNow.Web.Page.Pub("widget_loading",{widgetName:g,ctx:this});GolfNow.Web.Page.Sub("user-location-changed",function(t){n.setAttribute("address",t.Address)});t=function(){n.coursesElement=b=n.querySelector("#other-courses");n.couresHeaderElement=k=n.querySelector("#other-courses-header");n.hotdealsContainerElement=a=n.querySelector(".hot-deals-container");n.recordCountContainerElement=d=n.querySelectorAll(".record-count-container");n.coursesCityElement=l=n.querySelector("#other-courses-city");_.delay(function(){n.readAttributes().done(n.loadItems)},300)};f.LocateMe(!1,t,t)},n.readAttributes=function(){var n=this,v;return this.authenticated=ot=this.getAttribute("authenticated").toLowerCase()==="true"?!0:!1,this.userName=st=this.getAttribute("username"),this.seoName=p=this.getAttribute("seoname")||"",e&&e!=""&&$(k).find("h2").html(e),o||$(a).hide().html("&nbsp;"),GolfNow.Web.Utils.ConsoleLog("Show hot deals: "+o),y&&(o=!1,$(a).hide().html("&nbsp;")),s==0?(this.items=t=Number(this.getAttribute("items")),(isNaN(this.items)||this.items===0)&&(this.items=t=this.itemsToShow())):this.items=t=s,this.radius=u=Number(this.getAttribute("radius")),(isNaN(this.radius)||this.radius===0)&&(this.radius=u=this.searchRadius(Number(this.getAttribute("searchradius")))),f.Address().done(function(t){n.address=ht=t}),l!=null&&f.Address_City().done(function(t){n.address_city=ct=t;$(l).text(t)}),h==0&&c==0?(v=f.GeoCoordinates(),v.done(function(t){$.isEmptyObject(t)?(n.latitude=i,n.longitude=r):(n.latitude=i=t.Lat,n.longitude=r=t.Long)})):(n.latitude=i=h,n.longitude=r=c),$.Deferred().resolveWith(n)},n.loadItems=function(){var n=this;$.when.apply(this,ut()).then(w).done(function(){GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:g});GolfNow.Web.Page.Sub("window_resize",function(){n.setAttribute("items",n.itemsToShow())})})},n.attributeChangedCallback=function(n,t,i){var r=this,u;if(/^(items|radius|address)$/.test(n)&&t!=i)v||(v=!0,setTimeout(function(){r.readAttributes();w()},500));else if(/^(showhotdeals|lat-long|customtitle|recordcount|ovritems|searchradius|seoname)$/.test(n)&&t!=i)switch(n){case"showhotdeals":r.hotdeals(i==="true");break;case"lat-long":u=i.split(";");r.overrideLocation(Number(u[0]),Number(u[1]));break;case"customtitle":r.customTitle(i);break;case"recordcount":r.recordCount(i==="true");break;case"ovritems":r.overrideItemsToShow(Number(i));break;case"searchradius":r.searchRadius(Number(i));break;case"seoname":r.seoName(i)}},n.customTitle=function(n){e=n},n.hotdeals=function(n){o=n},n.recordCount=function(n){y=n},n.seoName=function(n){p=n;rt=n!==""?"/tee-times/destination/"+p+"/search":"#"},n.itemsToShow=function(){var n=3;return Foundation.utils.is_small_only()?n=3:Foundation.utils.is_medium_only()?n=5:Foundation.utils.is_large_up()&&(n=8),n},n.overrideItemsToShow=function(n){s=n},n.overrideLocation=function(n,t){h=n;c=t},n.searchRadius=function(n){return u=typeof n=="undefined"||n==0?25:n},n.init=function(){it||(it=!0,document.registerElement("gn-other-courses",{prototype:n}))},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.FeaturedCourses_HPW=function(){"use strict";function vt(){for(var n,i,r=[],t=0;t<st.length;t++)n=st[t],i=n.isPath?n.tmplPath:"/Tmpls/_"+n.tmplPath+".tmpl.html",r.push(GolfNow.Web.Client.LoadTemplate(i,n.accessorName,n.helpers));return r}function k(){var h=document.querySelector("gn-featured-courses-hpw"),n,s;t?b=100:(b=r,u=[]);ct=0;n=$(h);s={PageSize:b,PageNumber:1,Date:at,SortBy:t?null:GolfNow.Web.Utils.GetDefaultSearchSort(),SortByRollup:t?null:GolfNow.Web.Utils.GetDefaultSearchSort(),SortDirection:t?null:0,Latitude:f,Longitude:e,Radius:o,View:"Featured-Near-Me"};GolfNow.Web.Utils.ConsoleLog("loading data::"+f+"::"+e);et.Post("featured-courses-hpw","/api/tee-times/tee-time-results",JSON.stringify(s)).done(function(f){if(f&&f.ttResults&&f.ttResults.facilities&&f.ttResults.facilities.length>0)if(lt=f.total,l=f.ttResults.facilities,i=_.map(f.ttResults.facilities,function(n){return n.facilityId}),i=_.reject(i,function(n){return!n}),i.length){var e=[],o=[];t?(e=g(i,r),o=_.map(e,function(n){return _.findWhere(l,{facilityId:n})})):(e=i,o=l);d(e,s.Date);n.find(".container.throbber").hide();n.find(".header-container").show();$.observable(u).insert(o);$.templates.featuredcoursesTmpl.link("#featured-courses",u);n.show().find("a,span.button").not(".geo-changelocation,.show-more,.geo-hotdeals").on("click",yt)}else n.hide();else n.hide()}).fail(function(){GolfNow.Web.Utils.ConsoleError("Failed to get featured courses.");n.hide()}).always(function(){w=!1})}function d(n,t){var i={facilityIds:n,predicateDate:t};et.Post("other-courses-pricing","/api/tee-times/facilities-result",JSON.stringify(i)).done(function(n){ct++;_.each(n.batchResults,function(n){var i=$("#featuredcourses-hpw #"+n.facilityId),u=$.render.featuredFromPriceTmpl(n),t,r;i.append(u);t=i.parents("a[data-facilityid='"+n.facilityId+"']");t.data("daysout",GolfNow.Web.Date.DaysFromToday(n.minDate));n.minPrice||(r="/courses/"+n.courseDetailSeoFriendlyName,t.attr("href",r))});u.length>=lt&&$(s).hide()})}function yt(n){n.preventDefault();n.stopPropagation();var t=$(this),i=t.prop("href"),r=!1,f=t.data("facilityid"),u=t.data("facilityname")||null,o=t.data("city"),s=t.data("state"),h=t.data("country"),e=Number(t.data("daysout"));t.is("a")?r=t.find(".view-tt-button > span").hasClass("check-next-day"):(i=t.data("href"),r=t.hasClass("check-next-day"));u===null&&(u=t.parents("a").data("facilityname"));TrackGoogleClickEvent("featuredClick","Featured Course","click",u+"|"+f,1,i);r?document.location.href=i:searchController.SearchParameters.Set({Date:Date.today().add(e).days()},!0)}function pt(n){return typeof n=="object"}function wt(){return it}function bt(){$("gn-featured-courses-hpw").on("click",".record-paging-container a.show-more",function(){var n=g(i,r),t=_.map(n,function(n){return _.findWhere(l,{facilityId:n})});d(n,at);$.observable(u).insert(t)})}function g(n,t){var r=[],i;for(t>n.length&&(t=n.length),i=0;i<t;i++)r.push(n.shift());return r}function kt(){$(ut).hide().html("&nbsp;")}var n=Object.create(HTMLElement.prototype),dt=!1,gt="",r=3,a=0,ni="",ti="",f=0,e=0,v=0,y=0,o=25,nt="mi",ii="",tt="",it="",p="",rt="",ut="",s="",ft="FeaturedCourses-HPW",h=GolfNow.Web.LocationServices,et=GolfNow.Web.Request,w=!1,ot=!1,st=[{tmplPath:"CubeRollupSingle",accessorName:"featuredcoursesTmpl",isPath:!1,helpers:{urldecode:GolfNow.Web.Utils.UrlDecodeString,isobject:pt,units:GolfNow.Web.Utils.AppendRadiusUnits,phoneNumber:wt}},{tmplPath:"CubeRollupSinglePricing",accessorName:"featuredFromPriceTmpl",isPath:!1,helpers:{istoday:GolfNow.Web.Date.IsToday,daysout:GolfNow.Web.Date.DaysFromToday}},{tmplPath:"StarRatings",accessorName:"starRatingsTemplate",isPath:!1},{tmplPath:"CubeRollupSingleCheckTomorrow",accessorName:"cubeRollupCheckTomorrowTmpl",isPath:!1}],c="",ht=!0,t=!1,l=[],u=[],i=[],ct=0,b=10,lt=0,at=Date.today().toDateDisplayString();return n.createdCallback=function(){var n=this,i=$("#featuredcourses-hpw"),t;i.find(".header-container").hide();i.show();GolfNow.Web.Page.Pub("widget_loading",{widgetName:ft,ctx:n});GolfNow.Web.Page.Sub("user-location-changed",function(t){n.setAttribute("address",t.Address)});t=_.once(function(){n.coursesElement=ii=n.querySelector("#featured-courses");n.couresHeaderElement=tt=n.querySelector("#featured-courses-header");n.hotdealsContainerElement=ut=n.querySelector(".hot-deals-container");n.pagingContainerElement=s=n.querySelector(".record-paging-container");n.coursesCityElement=p=n.querySelector("#featured-courses-city");n.coursesRadiusElement=rt=n.querySelector("#featured-courses-radius");_.delay(function(){n.readAttributes().done(n.loadItems)},300)});GolfNow.Web.Domains.BookingCenterPhone().done(function(n){it=n});bt();h.LocateMe(!0,t,t)},n.readAttributes=function(){var n,u,i;GolfNow.Web.Utils.ConsoleLog("reading attrs");n=this;this.authenticated=dt=this.getAttribute("authenticated").toLowerCase()==="true"?!0:!1;this.userName=gt=this.getAttribute("username");this.units=nt=this.getAttribute("units");c&&c!=""&&$(tt).find("h2").html(c);ht||kt();t?$(s).show():$(s).empty();a==0?(this.items=r=Number(this.getAttribute("items")),(isNaN(this.items)||this.items===0)&&(this.items=r=this.itemsToShow())):this.items=r=a;this.radius=o=Number(this.getAttribute("radius"));(isNaN(this.radius)||this.radius===0)&&(this.radius=o=this.searchRadius(Number(this.getAttribute("searchradius"))));h.Address().done(function(t){n.address=ni=t});p!=null&&h.Address_City().done(function(t){n.address_city=ti=t;$(p).text(t)});v==0&&y==0?(u=h.GeoCoordinates(),u.done(function(t){$.isEmptyObject(t)?(n.latitude=f,n.longitude=e):(n.latitude=f=t.Lat,n.longitude=e=t.Long)})):(n.latitude=f=v,n.longitude=e=y);i=o;switch(nt){case"km":i+=" Kilometers";break;default:i+=" Miles"}return $(rt).text(i),$.Deferred().resolveWith(n)},n.loadItems=function(){var n=this;$.when.apply(this,vt()).then(k).done(function(){GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:ft});GolfNow.Web.Page.Sub("window_resize",function(){n.setAttribute("items",n.itemsToShow())})})},n.attributeChangedCallback=function(n,t,i){var r=this,f;if(/^(items|radius|address)$/.test(n)&&t!=i)w||(w=!0,setTimeout(function(){r.readAttributes();u=[];k()},500));else if(/^(showhotdeals|lat-long|customtitle|paging|ovritems|searchradius)$/.test(n)&&t!=i){GolfNow.Web.Utils.ConsoleLog("setting attrs");switch(n){case"showhotdeals":r.hotdeals(i==="true");break;case"lat-long":f=i.split(";");r.overrideLocation(Number(f[0]),Number(f[1]));break;case"customtitle":r.customTitle(i);break;case"paging":r.enablePaging(i==="true");break;case"ovritems":r.overrideItemsToShow(Number(i));break;case"searchradius":r.searchRadius(Number(i))}}},n.customTitle=function(n){c=n},n.hotdeals=function(n){ht=n},n.itemsToShow=function(){var n=3;return Foundation.utils.is_small_only()?n=3:Foundation.utils.is_medium_only()?n=5:Foundation.utils.is_large_up()&&(n=8),n},n.overrideItemsToShow=function(n){a=n},n.overrideLocation=function(n,t){v=n;y=t},n.searchRadius=function(n){return o=typeof n=="undefined"||n===0?25:n},n.enablePaging=function(n){t=n},n.init=function(){ot||(ot=!0,document.registerElement("gn-featured-courses-hpw",{prototype:n}))},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.DfpAd=function(){"use strict";function s(n){var f=this,r=$.Deferred(),i,u;return t.length>0?(i=[],_.each(t,function(n){if(n!=null){var u=n.lastIndexOf("_"),t=n.substr(u+1),r=!_.isNull(_.findWhere(o,{display:t})||null);r&&t==="large"?t+="-up":r||(t="");i.push('<div id="'+n+'" class="ad-container'+(t!==""?" show-for-"+t:"")+'"><\/div>')}}),i=i.join().replace(/,/g,""),u="gn-dfpad#"+n.id+" aside#ad div.columns",$(u).html(i),r.resolve()):r.resolve(),r.promise()}function r(){(this._adUnitNames===null||this._adUnitNames===undefined)&&(this._adUnitNames=t);_.each(this._adUnitNames,function(n){var i=n.lastIndexOf("_"),r=n.substr(i+1),t=_.findWhere(o,{display:r})||null;n!==null&&t!==null&&t.isMatch()?GolfNow.Web.Ads.Dfp.DisplayAd(n):n!==null&&t===null&&GolfNow.Web.Ads.Dfp.DisplayAd(n)})}var n=Object.create(HTMLElement.prototype),i=!1,u,h="",t=[],f="DfpAd",e=!1,c=_.bind(function(){return Foundation.utils.is_small_only()}),l=_.bind(function(){return Foundation.utils.is_medium_only()}),a=_.bind(function(){return Foundation.utils.is_large_up()}),o=[{display:"small",isMatch:c},{display:"medium",isMatch:l},{display:"large",isMatch:a}];return n.createdCallback=function(){var n=this;GolfNow.Web.Page.Pub("widget_loading",{widgetName:f,ctx:this});n.readAttributes()},n.readAttributes=function(){var n=this;this.adNames=h=this.getAttribute("adunitnames")},n.loadItems=function(){var n=this;GolfNow.Web.Page.Pub("request_page_adnames",u);s(this).done(function(){if(GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:f}),GolfNow.Web.Ads.Dfp.IsInitialized()){var t=_.bind(r,n);t()}GolfNow.Web.Page.Sub("window_resize",function(){var t=_.debounce(_.bind(r,n),300);t()})})},n.attributeChangedCallback=function(n,t,r){var u=this;/^(adunitnames)$/.test(n)&&t!=r&&(i||(i=!0,setTimeout(function(){u.readAttributes();i=!1},500)))},n.attachedCallback=function(){var n=this,r="",i=n.parentNode.attributes.getNamedItem("id").nodeValue;u={adContainerName:i,adUnitNames:[]};GolfNow.Web.Page.Sub("response_page_adnames",function(n){n.adContainerName===i&&(t=$.grep(n.adUnitNames,function(n){return n!=null}),r=t.join())});n.setAttribute("adunitnames",r);n.loadItems(i)},n.init=function(){var t=this;e||(e=!0,document.registerElement("gn-dfpad",{prototype:n}))},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.Destination_Link_List=function(){"use strict";function o(){GolfNow.Web.Page.Sub("xhr_get_always_destination-link-list-data",function(n){GolfNow.Web.Utils.ConsoleLog(n.requestStatus)});GolfNow.Web.Request.Get("destination-link-list-data",t,!0).done(function(n){var u,t,f,e;n.result==="success"&&n.data!==null?(u=null,t=[],_.each(n.data.countries,function(n){var i=_.reject(n.countriesGroup,function(n){return n.name==="United States"});i.length>0?t.push(n):u=n.countriesGroup}),u!==null&&u!=="undefined"&&u!=="null"&&(f=$.render.linkListUsTmpl(u),$(i).append(f)),t!==null&&t!=="undefined"&&t!=="null"&&t.length>0&&(e=$.render.linkListNonUsTmpl({countries:t}),$(r).append(e))):GolfNow.Web.Utils.ConsoleWarn("Unable to retrieve other golf destinations data.")}).fail(function(n){GolfNow.Web.Utils.ConsoleError(n.responseJSON.exceptionMessage)})}function s(){for(var n,i,r=[],t=0;t<e.length;t++)n=e[t],i=n.isPath?n.tmplPath:"/Tmpls/_"+n.tmplPath+".tmpl.html",r.push(GolfNow.Web.Client.LoadTemplate(i,n.accessorName,n.helpers));return r}function h(){$("gn-destination-link-list").on("click","ul li > a.parent-link",function(){$(document).foundation("dropdown","reflow")}).on("click",".f-dropdown li > a.other-golf-destination",c).on("click",".f-dropdown li > a.other-golf-destination-cities",l)}function c(n){n.preventDefault();var t=$(n.target),i=t.data("cityname"),r=t.data("cityid"),u=t.data("href");TrackGoogleClickEvent("otherDestinations","Search","Other Golf Destinations",i+"|"+r,1,u)}function l(n){n.preventDefault();var t=$(n.target),i=t.data("cityname"),r=t.data("href");TrackGoogleClickEvent("otherDestinationCities","Search","Other Golf Destination Cities",i,1,r)}var n=Object.create(HTMLElement.prototype),t="",i="",r="",u="Destination-Link-List",f=!1,e=[{tmplPath:"DestinationLinkList-Us",accessorName:"linkListUsTmpl",isPath:!1,helpers:{utilities:{defaultItemsPerCol:10,defaultNumOfCols:5,calcItemsPerCol:function(n,t){return((t===undefined||t===0||t==="")&&(t=this.defaultNumOfCols),n>t)?Math.ceil(n/t):this.defaultItemsPerCol}}}},{tmplPath:"DestinationLinkList-NonUs",accessorName:"linkListNonUsTmpl",isPath:!1}];return n.createdCallback=function(){GolfNow.Web.Page.Pub("widget_loading",{widgetName:u});var n=this;this.readAttributes();this.innerHTML='<span class="anchor" id="fdHeader"><\/span> ,<div class="row">,<div class="large-12 columns section-heading">,<h2 class="large-header margin-top hide-for-small-only color-gray-darker">All Golf Destinations<\/h2>,<\/div>,<\/div>,<div id="usDestinations"><\/div>,<div id="nonUsDestinations"><\/div>'.replace(/,/g,"");this.usDestinationsElement=i=this.querySelector("#usDestinations");this.nonUsDestinationsElement=r=this.querySelector("#nonUsDestinations");this.loadDestinations()},n.readAttributes=function(){},n.loadDestinations=function(){var n=this;$.when.apply(this,s()).then(o).done(function(){GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:u});GolfNow.Web.Page.Sub("window_resize",function(){});h()})},n.attributeChangedCallback=function(){var n=this},n.init=function(i){t=i;f||(f=!0,document.registerElement("gn-destination-link-list",{prototype:n}))},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.SearchFilters=function(){function ci(){var n=document.querySelector("gn-search-filters"),r=$(n);if(!h){if(e.bindDatePicker(),e.bindEventHandlers(),Foundation.utils.is_large_up())or(r);else r.on("click",".filtersToggle",function(){GolfNow.Web.FederatedSearch.ShowAdvancedSearch(searchController);GolfNow.Web.Client.SearchController.ShowSearchFilters(a);var n=new Date(t.get());return $(document).find("#search-header-date, #currentDateRefineText").html(n.toDateDisplayString()),!1});if(!s&&i)r.on("click",".locationToggle",function(){$("#change-location-modal").foundation("reveal","open")});if(Foundation.utils.is_medium_only()){r.on("click",".off-canvas-list .menuCloseBtn > a",function(){$(".off-canvas-wrap").foundation("offcanvas","hide","offcanvas-overlap-right")});if(!s&&!a)$(document).on("open.fndtn.offcanvas","[data-offcanvas]",function(n){n.namespace==="fndtn.offcanvas"&&$("html").css("overflow","hidden")}).on("close.fndtn.offcanvas","[data-offcanvas]",function(n){n.namespace==="fndtn.offcanvas"&&$("html").css("overflow","auto")})}$(document.querySelector(".reset-filters")).on("click",function(){searchController.ResetAdvancedSearchParams();GolfNow.Web.FederatedSearch.ShowAdvancedSearch(searchController)})}$(document.querySelector('input[type="checkbox"].view-criteria-option')).on("change",pi);$(document.querySelectorAll("ul.gn-button.golfers li")).on("click",function(){var t=$(this).find("input").val()||"0";n.setAttribute("players",t)});$(document.querySelectorAll("ul.gn-button.holes li")).on("click",function(){var t=$(this).find("input").val()||"0";n.setAttribute("holes",t)});if(t=$("#inputCurrentDate").pickadate("picker"),t){t.on("set",function(t){if(t.select){var i=new Date(t.select);$(document).find("#search-header-date, #currentDateRefineText").html(i.toDateDisplayString());n.setAttribute("date",i)}});n.setAttribute("date",t.get())}$(document.querySelector("select#ddbRateTypes")).on("change",wi);li(n)}function li(t){ot=t.querySelector("#slider-snap-value-lower-time");st=t.querySelector("#slider-snap-value-upper-time");ui=[ot,st];n.noUiSlider.on("update",pt);n.noUiSlider.on("change",function(n,i){pt(n,i);t.setAttribute(i===0?"timemin":"timemax",Number(n[i]))});ht=t.querySelector("#slider-snap-value-lower-price");ct=t.querySelector("#slider-snap-value-upper-price");gr=t.querySelector("#pre-price-min");lt=t.querySelector("#post-price-max");at=[ht,ct];u.noUiSlider.on("update",yt);u.noUiSlider.on("change",function(n,i){yt(n,i);t.setAttribute(i===0?"pricemin":"pricemax",Number(n[i]))});g=t.querySelector("#slider-step-distance-value");l.noUiSlider.on("update",wt);l.noUiSlider.on("change",function(n,i){wt(n,i);t.setAttribute("radius",Number(n[i]))})}function ai(n){return ft(GolfNow.Web.Utils.GetTimePeriodString(n))}function vi(){var r=document.querySelector("gn-search-filters"),t;n=r.querySelector("#slider-snap-time");u=r.querySelector("#slider-snap-price");l=r.querySelector("#slider-step-distance");t=ut(null,null,tt,i);hi?noUiSlider.create(n,{start:[t.startPeriod,t.endPeriod],connect:!0,behaviour:"drag-fixed",step:1,margin:4,limit:4,range:{min:GolfNow.Web.Utils.GetMinTimePeriodValue(),max:GolfNow.Web.Utils.GetMaxTimePeriodValue()},format:wNumb({decimals:0})}):noUiSlider.create(n,{start:[t.startPeriod,t.endPeriod],connect:!0,step:6,margin:6,range:{min:GolfNow.Web.Utils.GetMinTimePeriodValue(),max:GolfNow.Web.Utils.GetMaxTimePeriodValue()},format:wNumb({decimals:0})});noUiSlider.create(u,{start:[0,130],connect:!0,step:5,margin:10,range:{min:0,max:130},format:wNumb({decimals:0})});noUiSlider.create(l,{start:[GolfNow.Web.Utils.GetDefaultSearchRadius()],step:1,connect:"lower",range:{min:[5],max:[75]},format:wNumb({decimals:0})})}function yi(){var n=$("#ddbRateTypes"),t=GolfNow.Web.Utils.GetAllowedRateTypes();$(t).each(function(){n.append($("<option>").attr("value",this.value).text(this.text))})}function pi(){var n=document.querySelector("gn-search-filters"),t=document.querySelector("#hotdeals").checked;n.setAttribute("hotdealsonly",t)}function wi(){var n=document.querySelector("gn-search-filters"),t=document.querySelector("#ddbRateTypes").value;n.setAttribute("ratetype",t)}function bi(n){var a=document.querySelector("gn-search-filters"),k=$(a),f=n.refinedObj,d=n.refinedItems,w=n.searchType,b,rt,s,nt,it,r,v,u,e,o,l,h,p;(c===""||c!==w)&&(c=w);b=n.location;rt=$("meta[name='accept-language']").attr("content");ri=b;k.find("#locationDisplay").html(b);Foundation.utils.is_medium_only()&&k.find(".action-buttons > a.success-button").text("Apply Filters");s=searchController.SearchParameters.Get();for(nt in d){r=d[nt];v="";switch(r){case"Date":if(u=f[r],u!==s[r])continue;it=new Date(u);$(document).find("#search-header-date, #currentDateRefineText").html(it.toDateDisplayString());t&&a.setAttribute("date",t.get());break;case"PriceMin":if(e=f[r],e!==s[r])continue;e===null&&(e=GolfNow.Web.Utils.GetPriceFloor());l=e;ht.innerHTML=accounting.formatMoney(Number(l),y(),0);a.setAttribute(r.toLowerCase(),Number(e));break;case"PriceMax":if(o=f[r],o!==s[r])continue;o===null&&(o=GolfNow.Web.Utils.GetPriceCeiling());h=o;h>=130&&(h=130);ct.innerHTML=accounting.formatMoney(Number(h),y(),0);a.setAttribute(r.toLowerCase(),Number(o));break;case"Players":if(u=f[r],u!==s[r])continue;bt(r,u);break;case"TimeMin":e=f[r];p=ut(f.Date,{timemin:e,timemax:f.timemax},tt,i);e===null&&(e=p.startPeriod);l=e;l<GolfNow.Web.Utils.GetMinTimePeriodValue()&&(l=GolfNow.Web.Utils.GetMinTimePeriodValue());ki(r,Number(l));break;case"TimeMax":o=f[r];p=ut(f.Date,{timemin:e,timemax:f.timemax},tt,i);o===null&&(o=p.endPeriod);h=o;h>GolfNow.Web.Utils.GetMaxTimePeriodValue()&&(h=GolfNow.Web.Utils.GetMaxTimePeriodValue());di(r,Number(h));break;case"Radius":u=f[r];v=u+GolfNow.Web.Utils.GetDefaultUnitOfMeasure();w!=="Facility"&&(u!==s[r]||g.innerHTML!==v)&&(g.innerHTML=v,a.setAttribute(r.toLowerCase(),Number(u)));break;case"Holes":if(u=f[r],u!==s[r])continue;kt(r,u);break;case"HotDealsOnly":if(u=f[r],u!==s[r])continue;dt(r,u);break;case"RateType":if(u=f[r],u!==s[r])continue;gt(r,u)}}}function vt(){p=!1;_.isEmpty(r)||it();Foundation.utils.is_medium_only()&&$(".off-canvas-wrap").foundation("offcanvas","hide","offcanvas-overlap-right")}function it(){var e=document.querySelector("gn-search-filters"),i=searchController.SearchParameters.Get(),u=Object.getOwnPropertyNames(i),f,n,t;_.isEmpty(r)&&_.forEach(e.attributes,function(n){r[n.name]=n.value});for(f in u)n=u[f],_.isString(n)&&(t=n.toLocaleLowerCase(),r.hasOwnProperty(t)&&r[t]&&(i[n]=r[t]));searchController.SearchParameters.Set(i,!0);GolfNow.Web.Page.Pub("filter-option-changed",searchController);GolfNow.Web.Analytics.Google.TrackPageView("/search-filters");o=!1;r={}}function y(){return GolfNow.Web.Currency.getSymbol($("meta[name='currency-code']").attr("content"))}function yt(n,t){var i=n[t];i>=130?(at[t].innerHTML=accounting.formatMoney(130,y(),0),lt.innerHTML="+"):(n[1]<130&&(lt.innerHTML=""),at[t].innerHTML=accounting.formatMoney(Number(i),y(),0))}function pt(n,t){var i=n[t],r=GolfNow.Web.Utils.GetMaxTimePeriodValue();i>r&&(i=r);ui[t].innerHTML=ai(i)}function wt(n,t){var i=n[t];g.innerHTML=i+GolfNow.Web.Utils.GetDefaultUnitOfMeasure()}function rt(){if(searchController){var n=searchController.GetRestoreFedSearchKey();$("#no-location .fedresults, #locationDisplay").html(n.Location)}}function ki(n,t){var i=document.querySelector("gn-search-filters"),r=$(i);ot.innerHTML=ft(GolfNow.Web.Utils.GetTimePeriodString(t));i.setAttribute(n.toLowerCase(),t)}function di(n,t){var i=document.querySelector("gn-search-filters"),r=$(i);st.innerHTML=ft(GolfNow.Web.Utils.GetTimePeriodString(t));i.setAttribute(n.toLowerCase(),t)}function bt(n,t){var i=document.querySelector("gn-search-filters"),u=$(i),r=$(document.querySelectorAll("input[name=radioGolfers]"));if(t===null||t==="null")GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,0),i.setAttribute(n.toLowerCase(),0);else switch(t){case"0":case 0:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,0);i.setAttribute(n.toLowerCase(),0);break;case"1":case 1:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,1);i.setAttribute(n.toLowerCase(),1);break;case"2":case 2:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,2);i.setAttribute(n.toLowerCase(),2);break;case"3":case 3:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,3);i.setAttribute(n.toLowerCase(),3);break;case"4":case 4:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,4);i.setAttribute(n.toLowerCase(),4);break;default:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,0);i.setAttribute(n.toLowerCase(),0)}}function kt(n,t){var i=document.querySelector("gn-search-filters"),u=$(i),r=$(document.querySelectorAll("input[name=radioHoles]"));if(t===null||t==="null")GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,0),i.setAttribute(n.toLowerCase(),3);else switch(t){case"0":case 0:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,0);i.setAttribute(n.toLowerCase(),3);break;case"1":case 1:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,1);i.setAttribute(n.toLowerCase(),1);break;case"2":case 2:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,2);i.setAttribute(n.toLowerCase(),2);break;case"3":default:GolfNow.Web.Client.FormUtilities.SetSelectedValue(r,0);i.setAttribute(n.toLowerCase(),3)}}function dt(n,t){var i=document.querySelector("gn-search-filters"),u=$(i),r=$(document.querySelector("#hotdeals"));t!==null&&typeof t=="number"?t=Boolean(t):t!==null&&typeof t=="string"&&(t=t.toLowerCase()==="true");t?(r.attr("checked",!0),i.setAttribute(n.toLowerCase(),!0)):(r.attr("checked",!1),i.setAttribute(n.toLowerCase(),!1))}function gt(n,t){var u=document.querySelector("gn-search-filters"),f=$(document.querySelector("#ddbRateTypes")),r=GolfNow.Web.Utils.GetAllowedRateTypes(),e=GolfNow.Web.Utils.GetAllowedRateTypes(),i;if(_.isString(c)&&c.toLocaleLowerCase()!="goplay"){for(i=0;i<r.length;i++)if(r[i].hasOwnProperty("value")&&r[i].value.toLowerCase()===t.toLowerCase()){f.val(t.toLowerCase());u.setAttribute(n.toLowerCase(),t.toLowerCase());return}u.setAttribute(n.toLowerCase(),GolfNow.Web.Utils.GetDefaultRateType());GolfNow.Web.Page.Pub("filter-option-changed",searchController)}}function gi(){for(var n,i,r,u=[],f=GolfNow.Web.Page.GetCurrentClientProfile(),t=0;t<oi.length;t++)n=oi[t],i=n.profile.split(","),(n.profile==="all"||_.contains(i,f))&&(r=n.isPath?n.tmplPath:"/Tmpls/_"+n.tmplPath+".tmpl.html",u.push(GolfNow.Web.Client.LoadTemplate(r,n.accessorName,n.helpers)));return u}function nr(){var c=document.querySelector("gn-search-filters"),n=$(c),r=n.find("aside"),u=n.find("#searchModal .serach-bar"),f=n.find("#searchModal .federatedStepOne"),e=n.find("#searchModal .federatedStepTwo"),o=n.find("#searchModal .federatedStepThree > form#advancedSearch"),h=n.find("#filters-locationBtn"),t={isSpecialRatesPage:i,displayMode:ei,mediumOverride:a||s,useGooglePlaces:usegoogleplaces,disableChangeLocation:fi};fr([r,u,f,e,o]);ur(t);Foundation.utils.is_small_only()||a||s?(tr(t),ir(t),rr(t),u.html(b),f.html(k),e.html(d),o.html(v),h.removeClass("hide-for-medium-up"),$(document).find("#searchModal .current-search").removeClass("show-for-medium-up"),Foundation.utils.is_small_only()&&!_.isNull(searchController)&&GolfNow.Web.Client.SearchController.PopulatePreviousSearch(searchController)):Foundation.utils.is_medium_up()&&(h.addClass("hide-for-medium-up"),$(document).find("#searchModal .current-search").addClass("show-for-medium-up"),r.html(v).show());a&&(b="",k="",d="",v="")}function tr(n){b===""&&(b=$.render.fedSearchStepZeroTmpl(n))}function ir(n){k===""&&(k=$.render.fedSearchStepOneTmpl(n))}function rr(n){d===""&&(d=$.render.fedSearchStepTwoTmpl(n))}function ur(n){v===""&&(v=$.render.fedSearchStepThreeTmpl(n))}function fr(n){_.forEach(n,function(n){n.html("")})}function er(){return c}function or(n){var t=null;n.on("mouseover",function(){w=!0;t!==null&&clearTimeout(t);t=setTimeout(function(){w=!1},5e3)}).on("mouseleave",function(){clearTimeout(t);w=!1})}function ut(n,t,i,r){var u,f;return hi?(u=GolfNow.Web.Utils.GetStartTimePeriodValue(n),f=GolfNow.Web.Utils.GetEndTimePeriodValue(n)):(u=GolfNow.Web.Utils.GetMinTimePeriodValue(),f=GolfNow.Web.Utils.GetMaxTimePeriodValue()),(i||r)&&(u=GolfNow.Web.Utils.GetMinTimePeriodValue(),f=GolfNow.Web.Utils.GetMaxTimePeriodValue()),{startPeriod:u,endPeriod:f}}function ft(n){var t,i,u,r;Date.CultureInfo.name=et;t=new Date;t.set({hour:20});var f=n.indexOf(" "),e=n.indexOf("+")>-1,o=t.toLocaleString().indexOf("PM")>-1;return f>-1?(i=n.split(" "),u=i[0]<24&&i[1].indexOf("PM")>-1?Number(i[0])+12:Number(i[0]),t.set({hour:u})):t.set({hour:Number(n)}),r=o&&et==="en-US"?"h tt":"HH",r+=e?"+":"",t.toString(r)}var f=Object.create(HTMLElement.prototype),ni="SearchFilters",e=null,sr=Foundation.utils.is_small_only()?"#advancedSearch":"gn-search-filters",hr=document.querySelector(sr),nu=$(hr),a=$("gn-search-input").find("section#alternate-search-box").length>0,ti=300,p=!0,r={},o=!1,w=!1,b="",k="",d="",v="",ii=GolfNow.Web.Page.GetCurrentClientProfile(),h=!1,ri="",c="",et="en-US",n,u,l,cr,lr,t=null,ar,vr,yr,pr,wr,br,kr,ot,st,ht,ct,g,dr,gr,lt,at,ui,nt,s,i,tt,fi,ei,oi=[{tmplPath:"SearchFilterTypeAhead",accessorName:"fedSearchStepZeroTmpl",isPath:!1,profile:"small,medium"},{tmplPath:"SearchFilterPreviousSearches",accessorName:"fedSearchStepOneTmpl",isPath:!1,profile:"small,medium"},{tmplPath:"SearchFilterTypeAheadRsults",accessorName:"fedSearchStepTwoTmpl",isPath:!1,profile:"small,medium"},{tmplPath:"SearchFilterInputs",accessorName:"fedSearchStepThreeTmpl",isPath:!1,profile:"all"}],si=!1,hi=!1;return f.createdCallback=function(){GolfNow.Web.Page.Sub("searchController_Initialized",function(n){return searchController=n,GolfNow.Web.Client.SearchController.InitializeFederatedSearch(),e.handlePreviousDateLink(),e.handleSortState(),Foundation.utils.is_medium_up()&&e.removeUnSupportedViewOptions($("#view-options > li > a")),Foundation.utils.is_medium_up()&&e.removeUnSupportedSortOptions($("#sort-options > li > a"),GolfNow.Web.Page.GetCurrentClientProfile()),GolfNow.Web.FederatedSearch.handlePageRefinements(),!s&&i&&rt(),!1});GolfNow.Web.Page.Sub("set-filter-display-values",_.debounce(bi,300));GolfNow.Web.Page.Sub("content_rendered",vt);GolfNow.Web.Page.Sub("no_results_rendered",vt);GolfNow.Web.Page.Pub("widget_loading",{widgetName:ni});!s&&i&&(GolfNow.Web.Page.Sub("page_init",rt),GolfNow.Web.Page.Sub("user-location-changed",rt));this.readAttributes();e=GolfNow.Web.Search;this.loadTemplates()},f.readAttributes=function(){var n=this;n.date=lr=n.getAttribute("date");n.hotdealsonly=dr=n.getAttribute("hotdealsonly").toLowerCase()==="true"?!0:!1;n.timemin=ar=Number(n.getAttribute("timemin"));n.timemax=vr=Number(n.getAttribute("timemax"));n.pricemin=yr=Number(n.getAttribute("pricemin"));n.pricemax=pr=Number(n.getAttribute("pricemax"));n.distance=cr=Number(n.getAttribute("radius"));n.holes=wr=Number(n.getAttribute("holes"));n.golfers=br=Number(n.getAttribute("players"));n.ratetype=kr=n.getAttribute("ratetype")},f.attributeChangedCallback=function(f,e,s){var v=this,b=i,c,a,y;if(GolfNow.Web.Utils.ConsoleLog("Filter Attribute "+f+" changed from "+e+" to "+s+"!"),w&&(o=!0),/^(hotdealsonly|date|timemin|timemax|pricemin|pricemax|radius|holes|players|ratetype)$/.test(f)&&e!==s){v.readAttributes();switch(f){case"hotdealsonly":dt(f,s);break;case"date":t&&(y=$(document).find("#search-header-date, #currentDateRefineText"),y.length&&y.html(new Date(t.get()).toDateDisplayString()));b=!0;break;case"timemin":_.isObject(noUiSlider)&&_.isObject(n)&&(nt=n.noUiSlider.options.behaviour,nt==="drag-fixed"?o?(c=Number(s),a=Number(n.noUiSlider.get()[1]),n.noUiSlider.set([c,a]),p=!0,_.delay(it,ti),a!==Number(v.getAttribute("timemax"))&&v.setAttribute("timemax",a)):n.noUiSlider.set([Number(s)]):n.noUiSlider.set([Number(s)]));h&&o&&(si=!0);break;case"timemax":_.isObject(noUiSlider)&&_.isObject(n)&&(nt=n.noUiSlider.options.behaviour,nt==="drag-fixed"?o?(c=Number(n.noUiSlider.get()[0]),a=Number(s),n.noUiSlider.set([c,a]),c!==Number(v.getAttribute("timemin"))&&v.setAttribute("timemin",c)):n.noUiSlider.set([null,Number(s)]):n.noUiSlider.set([null,Number(s)]));h&&o&&(si=!0);break;case"pricemin":_.isObject(noUiSlider)&&_.isObject(u)&&u.noUiSlider.set([Number(s)]);break;case"pricemax":_.isObject(noUiSlider)&&_.isObject(u)&&u.noUiSlider.set([null,Number(s)]);break;case"radius":_.isObject(noUiSlider)&&_.isObject(l)&&l.noUiSlider.set(Number(s));break;case"holes":kt(f,s);break;case"players":bt(f,s);break;case"ratetype":gt(f,s)}Foundation.utils.is_large_up()&&!b&&(p?o&&(r[f]=s):(p=!0,_.delay(it,ti)))}},f.loadTemplates=function(){var n=this;$.when.apply(this,gi()).then(nr).then(vi).then(yi).then(ci).done(function(){if($(document).foundation("offcanvas","reflow"),$(document).foundation("reveal","reflow"),$(document).foundation("tab","reflow"),h?$(n).find("#locationDisplay").html(ri):GolfNow.Web.FederatedSearch.initPage(),$(document).find("#fedresults").text()===""&&searchController&&searchController.GetRestoreFedSearchKey(),!h){GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:ni});var t=function(){var t=GolfNow.Web.Page.GetCurrentClientProfile();ii!==t&&(GolfNow.Web.Client.SearchController.CloseFederatedSearch(),_.delay(function(){n.loadTemplates();ii=t;GolfNow.Web.FederatedSearch.initPage();n.readAttributes();GolfNow.Web.UrlParams.PopulateSearchHeadline(searchController,er(),null)},600))};GolfNow.Web.Page.Sub("mq_small_screen",t);GolfNow.Web.Page.Sub("mq_medium_screen",t);GolfNow.Web.Page.Sub("mq_large_screen",t);h=!0}})},f.init=function(n,t,r,u,e,o){s=n;i=t;ei=u;tt=r;fi=e;!_.isEmpty(o)&&_.isString(o)&&(et=o);document.registerElement("gn-search-filters",{prototype:f})},{initWidget:f.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.VIPInterstitial=function(){"use strict";var n=Object.create(HTMLElement.prototype),e=!1,o=7,c=document.querySelector("gn-vip-interstitial"),u="GolfNow.Web.VIP.InterstitialLastShown",s="",i=1,r,f=!1,t,l=!1,a="",v=!1,h;return n.createdCallback=function(){var t=this,n,i,r,f;if(this.readAttributes(),n=GolfNow.Web.Cache.GetValue(u),i=new Date,n!==null){n=new Date(n);r=Math.abs(i.getTime()-n.getTime());f=Math.floor(r/864e5);e&&f>=o?this.loadTemplates().then(t.buildTemplate).done(t.showVIPInterstitial):this.hideVIPInterstitial();return}e&&this.loadTemplates().then(t.buildTemplate).done(t.showVIPInterstitial)},n.readAttributes=function(){e=this.getAttribute("allow-vip-subs").toLowerCase()==="true"?!0:!1;o=this.getAttribute("no-show-days");v=this.getAttribute("authenticated").toLowerCase()==="true"?!0:!1;a=this.getAttribute("username");v&&(u=u+"_"+a)},n.showVIPInterstitial=function(){var n=$("#vipinterstitial");n.siblings().hide();c.bindEvents();n.height($(document).height());n.show();GolfNow.Web.Cache.SetLocalStorageValue(u,new Date,864e5*o)},n.hideVIPInterstitial=function(){var n=$("#vipinterstitial");n.siblings().show();n.hide()},n.bindEvents=function(){var n=this;n.trackDisplay();$(".btnInterstitialBecomeVIP").on("click",function(){$("#AddVIP").length>0&&($("#AddVIP").attr("checked",!0),$("#rdoCreditCard").prop("checked",!0),$("#rdoCreditCard").trigger("click"),$("#AddVIP").trigger("change",{id:i,name:t,price:r,category:"VIP",quantity:1}));n.hideVIPInterstitial();n.trackBecomeVIPClick()});$("#aInterstitialRemindLater").on("click",function(){n.hideVIPInterstitial();n.trackRemindLaterClick()})},n.trackBecomeVIPClick=function(){GolfNow.Web.Analytics.Google.Ecommerce.VipProductClick(t,i,r,"VIP","VIP Interstitial");f||GolfNow.Web.Analytics.Google.Ecommerce.VipAddToCart(t,i,r,"VIP","VIP Interstitial",null)},n.trackRemindLaterClick=function(){TrackGoogleEvent("interstitial_no_thanks",null,null,null,null)},n.trackDisplay=function(){var n=f?"/vip-sidecart-offer":"/vip-standalone-offer";GolfNow.Web.Analytics.Google.TrackPageView2("virtualPageview",document.location.pathname+n,t);GolfNow.Web.Analytics.Google.Ecommerce.VipProductImpression(t,i,r,"VIP","VIP Interstitial")},n.buildTemplate=function(){c.innerHTML=$.render.interstitialTmpl(h)},n.loadTemplates=function(){var n=$.Deferred(),t={tmplPath:"/Tmpls/_VipInterstitial-v"+h.version+".tmpl.html",accessorName:"interstitialTmpl"};return GolfNow.Web.Client.LoadTemplate(t.tmplPath,t.accessorName,null).done(n.resolve),n.promise()},n.init=function(u){l||(s=u.pageName!==""?u.pageName:document.body.attributes.getNamedItem("class").value.split(" ")[0],f=s.toLowerCase()==="checkout",t="VIP "+(f?"Sidecart":s),i="VIP-"+u.productId,r=u.rawPrice,l=!0,h=u,document.registerElement("gn-vip-interstitial",{prototype:n}))},{initWidget:n.init}}();GolfNow=GolfNow||{};GolfNow.Web=GolfNow.Web||{};GolfNow.Web.Widgets=GolfNow.Web.Widgets||{};GolfNow.Web.Widgets.Destinations=function(){"use strict";var n=Object.create(HTMLElement.prototype),r=!1,u=3,f="",e="",t="Destinations",i=!1;return n.createdCallback=function(){GolfNow.Web.Page.Pub("widget_loading",{widgetName:t});var n=this;this.readAttributes();this.headerElement=e=this.querySelector("#fdHeader");GolfNow.Web.Page.Pub("widget_loadComplete",{widgetName:t});GolfNow.Web.Page.Sub("window_resize",function(){})},n.readAttributes=function(){this.authenticated=r=this.getAttribute("authenticated");this.userName=f=this.getAttribute("username");this.items=u=Number(this.getAttribute("items"));isNaN(this.items)&&(this.items=3)},n.attributeChangedCallback=function(){},n.init=function(){i||(i=!0,document.registerElement("gn-destinations",{prototype:n}))},{initWidget:n.init}}()