function ChangeSearchBaseCategory(n,t){var i=t.attr("action").split("/")[2];t.attr("action",t.attr("action").replace(i,window.baseCatDictionary[n]));$("input[class*=listingsearchbasecategoryid]",t).val(n)}function DetailedSearchFormEventTypeChanged(n,t){var i=$("input[name=EventTypeID]:checked",t),r;i.length==0&&(i=$("[name=EventTypeID]",t),i.length==0&&(i=$('[name="LocationSearch.EventTypeID"]',t)));selectedETID=i.val();SetAdditionalEventTypeFields(i,t);r=currentBaseCategoryID==27;$("input[class*=hidEventTypeID]",t).val(selectedETID);$("input[class*=hidSubEventTypeID]",t).val(selectedSubETID);n||(RepopulateDetailedSearchFormCatMakeModel(r,t),GetSortOrdersAjax(currentBaseCategoryID,t));ShowHideDetailedSearchFormParentCategory(t);ShowHideDetailedSearchFormFieldsByEventTypeID(t)}function SetAdditionalEventTypeFields(n,t){selectedSubETID=$(n).attr("subeventtypeid");(typeof selectedSubETID==typeof undefined||selectedSubETID==!1)&&(selectedSubETID=0);$("input[class=hidlistingsearchsubeventtypeid]",t).val(selectedSubETID);searchOnlineAuctionListingsOnly=$(n).attr("showonlineauctiononly");(typeof searchOnlineAuctionListingsOnly==typeof undefined||searchOnlineAuctionListingsOnly==!1)&&(searchOnlineAuctionListingsOnly="false");searchOnlineAuctionListingsOnly=ConvertToBoolean(searchOnlineAuctionListingsOnly);$("input[class=hidlistingsearchshowonlineauctiononly]",t).val(searchOnlineAuctionListingsOnly);searchUpcomingAuctionListings=$(n).attr("showupcomingautionlistings");(typeof searchUpcomingAuctionListings==typeof undefined||searchUpcomingAuctionListings==!1)&&(searchUpcomingAuctionListings="false");searchUpcomingAuctionListings=ConvertToBoolean(searchUpcomingAuctionListings);$("input[class=hidlistingsearchshowupcomingauctionlistings]",t).val(searchUpcomingAuctionListings)}function ShowHideDetailedSearchFormParentCategory(n){var t=$("div[class*=parentcategorydivselector]");currentBaseCategoryID==27?(t.show(),$("label[class*=subcategorylabelselector]",n).show(),$("label[class*=catlabelselector]",n).hide()):(t.hide(),$("label[class*=subcategorylabelselector]",n).hide(),$("label[class*=catlabelselector]",n).show())}function RepopulateDetailedSearchFormCatMakeModel(n,t){IndustrySelected(currentBaseCategoryID,n,!1,!0,"",0,currentParentCategoryID,undefined,undefined,undefined,t)}function ShowHideDetailedSearchFormTruckSpecsByParentCategorySelected(n){var r=$("select[class*=industry-dropdown]",n).val(),i=$("div[class*=listingsearchtrucksleeperspecs]",n),t=$("div[class*=listingsearchtrucksaxlespecs]",n);switch(r){case"208":i.show();t.hide();t.children("input").each(function(){ClearTextBox(this)});t.children("select").each(function(){ClearDropDown(this)});break;case"209":t.hide();i.hide();t.children("input").each(function(){ClearTextBox(this)});t.children("select").each(function(){ClearDropDown(this)});i.children("input").each(function(){ClearTextBox(this)});i.children("select").each(function(){ClearDropDown(this)});break;default:t.show();i.show()}}function ShowHideDetailedSearchFormFarmSpecsByCategorySelected(n){var f=$("select[class*=category-dropdown]",n).val(),l=$("input[class*=catidswithwidthspecinfeethid]",n).val(),r=$("div[class*=listingsearchtractorbladespacingdivselector]",n),t=$("div[class*=listingsearchtractorframewidthdivselector]",n),i=$("div[class*=listingsearchtractorrowspacingdivselector]",n),u=$("div[class*=listingsearchtractornumberofrowsdivselector]",n),e=$("div[class*=listingsearchtractornumberofbottomsdivselector]",n),o=$("input[class*=metersorfeetspecmeasurement]",n).val(),s=$("input[class*=cmorinchesspecmeasurement]",n).val(),h=$("input[class*=minwidthtranslation]",n).val(),c=$("input[class*=maxwidthtranslation]",n).val();r.hide();t.hide();i.hide();u.hide();e.hide();switch(f){case"1113":i.show();break;case"1115":u.show();i.show();t.show();break;case"1121":case"1122":case"1125":i.show();t.show();break;case"1123":case"1130":u.show();i.show();break;case"1126":t.show();break;case"1127":t.show();r.show();break;case"1198":case"1199":t.show();e.show();break;case"1129":t.show()}i.is(":visible")||i.find("input:text").val("");r.is(":visible")||r.find("input:text").val("");t.is(":visible")||t.find("input:text").val("");t.is(":visible")&&l.indexOf("||"+f+"||")>-1?($("label[class*=listingsearchtractorminframewidthlabelselector]",n).text(h+" ("+o+"):"),$("label[class*=listingsearchtractormaxframewidthlabelselector]",n).text(c+" ("+o+"):")):($("label[class*=listingsearchtractorminframewidthlabelselector]",n).text(h+" ("+s+"):"),$("label[class*=listingsearchtractormaxframewidthlabelselector]",n).text(c+" ("+s+"):"))}function ShowHideDetailedSearchFormConstructionSpecsByCategorySelected(n){var u=$("select[class*=category-dropdown]",n).val(),f=$("input[class*=catidswithcapacityspec]",n).val(),e=$("div[class*=listingsearchmachinerycapacitymindivselector]",n),o=$("div[class*=listingsearchmachinerycapacitymaxdivselector]",n),s=$("input[class*=catidswithcapacityvalues]",n),r="",h,c,i,t;if(s.length>0&&(r=s.val().split("||")),h=$("label[class*=capacityminmeasurement]",n),c=$("label[class*=capacitymaxmeasurement]",n),o.hide(),e.hide(),f&&f.indexOf("||"+u+"||")>-1)for(o.show(),e.show(),i=0;i<r.length;i++)t=r[i].split(":"),t[0].indexOf(u)>-1&&t[1]!=""&&(h.text("("+t[1]+")"),c.text("("+t[1]+")"))}function ShowHideDetailedSearchFormFieldsByEventTypeID(n){$("div[class*=listingsearchforsaledivselector]",n).hide();$("div[class*=listingsearchforrentdivselector]",n).hide();$("div[class*=listingsearchforleasedivselector]",n).hide();$("div[class*=listingsearchauctionresultdivselector]",n).hide();$("div[class*=listingsearchonlineauctiondivselector]",n).hide();selectedETID!=5&&selectedETID!=6||searchUpcomingAuctionListings?($("span.not-auction-results").show(),$("span.auction-results").hide()):($("span.not-auction-results").hide(),$("span.auction-results").show());selectedETID==1?searchOnlineAuctionListingsOnly?$("div[class*=listingsearchonlineauctiondivselector]",n).show():$("div[class*=listingsearchforsaledivselector]",n).show():selectedETID==2?$("div[class*=listingsearchforrentdivselector]",n).show():selectedETID==20?$("div[class*=listingsearchforleasedivselector]",n).show():(selectedETID==5||selectedETID==6)&&(searchUpcomingAuctionListings?$("div[class*=listingsearchupcomingauctionsdivselector]",n).show():$("div[class*=listingsearchauctionresultdivselector]",n).show())}function ClearDropDown(n){n.selectedIndex=0}function ClearTextBox(n){n.val("")}function ConvertToBoolean(n){if(n!=undefined)switch(n.toUpperCase()){case"TRUE":case"YES":case"1":return!0;case"FALSE":case"NO":case"0":case null:return!1;default:return Boolean(n)}return!1}function DropDownLoadAuctions(n){var t=window.location.pathname+window.location.search;t=t.replace("/search","/list");window.location=n.toString().length>0?insertParam(insertParam(insertParam(t,EVENT_BD,n),EVENT_ED,n),ARD,1):removeURLParameter(removeURLParameter(t,EVENT_BD),EVENT_ED)}var selectedETID,selectedSubETID,searchOnlineAuctionListingsOnly,searchUpcomingAuctionListings,currentBaseCategoryID,currentParentCategoryID,auctionResultsETID=5,auctionResultsTrkETID=6,truckSubCats=[207,208,209,5e4,50001,50002,50003,50004];(function(n){var t=n("#main-search-form"),i=n("input[name=EventTypeID]:checked",t),r;if(i.length==0&&(i=n("[name=EventTypeID]",t),i.length==0)){i=n('[name="LocationSearch.EventTypeID"]',t);i.on("change",function(){selectedETID=n(this).val();ShowHideDetailedSearchFormFieldsByEventTypeID(t)})}selectedETID=i.val();currentBaseCategoryID=n("input[class*=listingsearchbasecategoryid]",t).val();currentParentCategoryID=n("input[class*=listingsearchparentcategoryid]",t).val();n("select[class*=industry-dropdown]",t).change(function(){n("input[class*=listingsearchparentcategoryid]",t).val(n(this).val())});SetAdditionalEventTypeFields(i);currentBaseCategoryID==27?(ShowHideDetailedSearchFormTruckSpecsByParentCategorySelected(),n("select[class*=parentcategorydivselector]",t).bind("change",function(){ShowHideDetailedSearchFormTruckSpecsByParentCategorySelected(t)})):currentBaseCategoryID==464?(ShowHideDetailedSearchFormFarmSpecsByCategorySelected(),n("select[class*=category-dropdown]",t).bind("change",function(){ShowHideDetailedSearchFormFarmSpecsByCategorySelected(t)})):currentBaseCategoryID==4&&(ShowHideDetailedSearchFormConstructionSpecsByCategorySelected(),n("select[class*=category-dropdown]",t).bind("change",function(){ShowHideDetailedSearchFormConstructionSpecsByCategorySelected(t)}));DetailedSearchFormEventTypeChanged(!0,t);n("input[name=EventTypeID]").on("change",function(){DetailedSearchFormEventTypeChanged(!1,t)});n("select[name=EventTypeID]",t).on("change",function(){selectedETID=n(this).val();ShowHideDetailedSearchFormFieldsByEventTypeID(t)});n("input[class*=numeric-only-input]").on("blur",function(){n(this).val(n(this).val().replace(/\D/g,""))});n(document).ready(function(){SetHoldValues("#ParentCategoryID",t);SetHoldValues("#CategoryID",t);SetHoldValues("#SearchManufacturerList",t);SetHoldValues("input[class*=listingsearchbasecategoryid]",t);SetHoldValues("input[name=EventTypeID]:checked",t);SetHoldValues("#EventTypeID",t);n('input[type="radio"][name="BaseCategoryID"]',t).length>0&&(currentBaseCategoryID==35e3&&selectedETID==auctionResultsETID?(selectedETID=auctionResultsTrkETID,n("#EventTypeID",t).val(selectedETID),HoldValuesFunction.HoldValue("#EventTypeID",!0,t)):currentBaseCategoryID!=35e3&&selectedETID==auctionResultsTrkETID&&(selectedETID=auctionResultsETID,n("#EventTypeID",t).val(selectedETID),HoldValuesFunction.HoldValue("#EventTypeID",!0,t)),RepopulateDetailedSearchFormCatMakeModel(currentBaseCategoryID==27,t),GetSortOrdersAjax(currentBaseCategoryID,t))});n("#SearchManufacturerList, #TruckSearchCriteria_AxleType").change(function(){var n=this.selectedOptions?this.selectedOptions:this.querySelectorAll("option:checked"),t;if(n.length||(this.selectedIndex=0),n.length>1)for(t=0;t<n.length;t++)(n[t].value==" "||n[t].value=="")&&(n[t].selected=!1)});n('input[type="radio"][name="BaseCategoryID"]',t).change(function(){var u=n(this),i=u.filter(":checked").val(),r=n(".category-dropdown",t);currentBaseCategoryID==35e3&&i!=35e3&&selectedETID==auctionResultsTrkETID?(selectedETID=auctionResultsETID,n("input[name=EventTypeID]:checked",t).val(selectedETID),n("#EventTypeID",t).val(selectedETID),HoldValuesFunction.HoldValue("input[name=EventTypeID]:checked",!0,t),HoldValuesFunction.HoldValue("#EventTypeID",!0,t)):(currentBaseCategoryID==81||currentBaseCategoryID==22e3)&&i==35e3&&selectedETID==auctionResultsETID&&(selectedETID=auctionResultsTrkETID,n("input[name=EventTypeID]:checked",t).val(selectedETID),n("#EventTypeID",t).val(selectedETID),HoldValuesFunction.HoldValue("input[name=EventTypeID]:checked",!0,t),HoldValuesFunction.HoldValue("#EventTypeID",!0,t));currentBaseCategoryID=i;ChangeSearchBaseCategory(currentBaseCategoryID,t);r.attr("onchange","CategoryDropDownChanged("+currentBaseCategoryID+", true,'',0,'','','','', $(this).closest('form'))");n("option:first",r).val(i);HoldValuesFunction.HoldValue(r.attr("id"),!0,t);r.attr("defaultvalue",i);RepopulateDetailedSearchFormCatMakeModel(currentBaseCategoryID==27,t);GetSortOrdersAjax(currentBaseCategoryID,t)});n(".industry-dropdown.location-input",t).change(function(){var r=n(this),i=r.val();~truckSubCats.indexOf(parseInt(i))&&(i=27);ChangeSearchBaseCategory(i,t)});r=n(".category-dropdown.location-input",t);r.val()<=0&&r.addClass("importantRule");r.change(function(){var t=n(this);t.valid()?t.removeClass("importantRule"):t.addClass("importantRule")});n("#LocationSearch_Location_ClientIsValid",t).val()!="1"&&n(".autocomplete-location",t).addClass("importantRule");t.submit(function(){var i=!0;n(".important",t).removeClass("importantRule");n(".input-validation-error",t).each(function(){var u=n(this),f,r;u.attr("id")=="LocationSearch_Location_ClientIsValid"?n(".autocomplete-location",t).addClass("importantRule"):u.addClass("importantRule");i&&(f=n("html, body"),r=u,r.is(":visible")||(r=t),f.scrollTop(r.offset().top),i=!1)})})})(jQuery);var EVENT_BD="eventbd",EVENT_ED="evented",ARD="ard"