TOL.registerModule("Index",function(e){-1!==navigator.userAgent.indexOf("Firefox")&&e(".main-radius select").addClass("FFBtn");const t=function(e){return-1===e.indexOf("?")?"?":"&"};return{priority:"last",init:function(){if("/"===window.location.pathname){if(function(){if(!window.localStorage||!window.localStorage.history||""===localStorage.history)return void e(".recentSearchesCont").addClass("hide");const a=localStorage.history.split(",");a.reverse(),e.ajax({url:"/recent-searches",method:"POST",data:{recentSearches:a},success(a){let r,o="";if(a.length)if(e(".recentSearchesCont").length){for(const e in a)r=a[e].url,-1===r.indexOf("zmc=recentsLink")&&(r+=`${t(r)}zmc=recentsLink${1+parseInt(e,10)}`),o+=`${a[e].text}
`;e("#yourRecentSearches").html(o)}else{o="
";for(const e in a)r=a[e].url,-1===r.indexOf("zmc=recentsLink")&&(r+=`${t(r)}zmc=recentsLink${1+parseInt(e,10)}`),o+=`- ${a[e].text}
`;o+="
",e(".recents").attr("data-content",o).removeClass("hide")}else e(".recentSearchesCont").addClass("hide")}})}(),"mobile"!==deviceDetection&&function(){const t=tolConfig.typeIconPopover().types;for(const a in t)t&&e(`li.${a}`).attr({"data-content":t[a],"data-toggle":"popover","data-trigger":"hover","data-placement":"top"})}(),"desktop"!==deviceDetection&&e("#index-search-form input").blur(),e('[data-toggle="popover"]').popover(),e("#index-search-form").submit((t=>{if("Equipment"===tolConfig.getRealmName()||"Truck"===tolConfig.getRealmName()||"RV"===tolConfig.getRealmName())return null;t.preventDefault(),e("#submit_button span.fa").removeClass("fa-arrow-right").addClass("fa-gear fa-spin");document.getElementById("index-search-form").querySelectorAll("input").forEach((t=>{""===t.value&&(t.setAttribute("disabled","disabled"),"zip_code"===t.id&&e("select[name='radius']").attr("disabled","disabled"))}));const a=document.getElementById("modelText"),r=document.getElementById("zip_code");if(!a.value&&!r.value&&!e("#buyOnlineWithCart").is(":checked")){const e=new URL(t.currentTarget.action);return window.location=e.pathname,null}const o=TOL.Module.Keywordsearch.getKeywordPromise();if(o&&"resolved"!==o.state())return o.then((()=>{e("#index-search-form").submit()})),!1;{const t=TOL.Module.LocationAutocomplete.getKeywordPromise();if(t&&"resolved"!==t.state())return t.then((()=>{e("#index-search-form").submit()})),!1}return t.currentTarget.submit(),null})),"desktop"===deviceDetection){const t=TOL.cookie.get("location");if(t){const a=JSON.parse(t);e("#zip_code").val(a.zipCode)}e.ajax({url:"/gettiledata/listingsFeatured/featuredListings",data:{deviceDetection:"desktop",homepage:"1"},success(t){e("#listingsFeatured").html(t),TOL.Module.Listings.featuredCarousel(),TOL.Module.Mytrader.refreshSavedListings()}})}else e(".useMyLocation").click((()=>{TOL.Module.geoLocate.featuredListings()}));e("#keyword").keydown((t=>13===t.keyCode?(e("#sugs").hide(),!1):null)),"desktop"!==deviceDetection&&e("#index-search-form input").blur(),TOL.Module.Realm.isRecreation()&&e.ajax({url:"/gettiledata/listingsFeatured/recommendedListings",data:{history:localStorage.history},success(t){e("#listingsFeaturedNew").html(t),TOL.Module.Listings.featuredCarousel(!1,e("#listingsFeaturedNew #featured-demo"))}})}}}}(jQuery));