$(document).ready(function(){$(document).on("change",".budget_check,.policy_check,.rating_check,.country_check,.board_check,.amenities_check,.payment_check,.hotel_amenities_check,.view_check,.bed_check",function(){var checked_number=$(".filters input:checked").length;if(checked_number>0){$(".show-hide-rate").hide();}else{$(".show-hide-rate").show();} $('.roomrate,.rateplan_step2').show();if($('.rate_plan').attr('data-has-loyalty')){$('.rate_plan').css('display','grid');}else{$('.rate_plan').css('display','flex');} var checked=$(".budget_check:checked");var unchecked=$(".budget_check:not(:checked)");if(checked.length>0){$.each(unchecked,function(index,value){removeElementsByPrice($(value).data('minimum'),$(value).data('maximum'));});} var checked_pol=$(".policy_check:checked");var unchecked_pol=$(".policy_check:not(:checked)");if(checked_pol.length>0){$.each(checked_pol,function(index,value){removeElementsByItemArray('policy',$(value).data('policy'));});} var checked_pay=$(".payment_check:checked");var unchecked_pay=$(".payment_check:not(:checked)");if(checked_pay.length>0){$.each(checked_pay,function(index,value){removeElementsByDataArray('payments',$(value).data('payment'));});} var checked_hotel_amenities=$(".hotel_amenities_check:checked");var unchecked_hotel_amenities=$(".hotel_amenities_check:not(:checked)");if(checked_hotel_amenities.length>0){$.each(checked_hotel_amenities,function(index,value){removeElementsByDataArray('hotelamenities',$(value).data('hotelamenity'));});} var checked_rating=$(".rating_check:checked");var unchecked_rating=$(".rating_check:not(:checked)");if(checked_rating.length>0){$.each(unchecked_rating,function(index,value){removeElementsByData('rating',$(value).data('rating'));});} var checked_country=$(".country_check:checked");var unchecked_country=$(".country_check:not(:checked)");if(checked_country.length>0){$.each(unchecked_country,function(index,value){removeElementsByData('country',$(value).data('country'));});} var checked_board=$(".board_check:checked");var unchecked_board=$(".board_check:not(:checked)");if(checked_board.length>0){$.each(checked_board,function(index,value){removeElementsByItemArray('board',$(value).data('board'));});} var checked_amenities=$(".amenities_check:checked");var unchecked_amenities=$(".amenities_check:not(:checked)");if(checked_amenities.length>0){var checked_amenities_ids=[];$.each(checked_amenities,function(index,value){checked_amenities_ids.push($(value).data('amenitie'));});filterAmenities(checked_amenities_ids);} var checked_views=$(".view_check:checked");var unchecked_views=$(".view_check:not(:checked)");if(checked_views.length>0){var checked_views_ids=[];$.each(checked_views,function(index,value){checked_views_ids.push($(value).data('view'));});filterAmenities(checked_views_ids);} var checked_beds=$(".bed_check:checked");var unchecked_beds=$(".bed_check:not(:checked)");if(checked_beds.length>0){var checked_beds_ids=[];$.each(checked_beds,function(index,value){checked_beds_ids.push($(value).data('bed'));});filterAmenities(checked_beds_ids);} RemoveRoomsWithoutRate();if($('.roomrate:visible,.rateplan_step2:visible').length==0){$(".applied_filters").removeClass("d-none");}else{$(".applied_filters").addClass("d-none");}});function filterAmenities(checked_ids){$.each($('.roomrate'),function(index,value){for(var j=0;j=min&&$(this).data("price")<=max;});to_remove.hide();} function removeElementsByData(data_key,value){var to_remove=$(".roomrate,.rateplan_step2").filter(function(){return $(this).data(data_key)==value;});to_remove.hide();} function removeElementsByDataArray(data_key,value){var to_remove=$(".roomrate,.rateplan_step2").filter(function(){if($(this).data(data_key)!=null&&value!=null){if(!$(this).data(data_key).includes(value)){$(this).hide();}}});to_remove.hide();} function removeElementsByItemArray(data_key,value){var to_remove=$(".roomrate , .rateplan_step2").filter(function(){if($(this).data(data_key)!=null&&value!=null){if(!value.includes($(this).data(data_key))){$(this).hide();}}});to_remove.hide();} $(document).on("change",".sorting",function(){var sortingMethod=$(this).val();sortByPrice(sortingMethod);});function sortByPrice(method){var roomrate=$('.roomrate');if(method=="price_desc"){roomrate.sort(function(a,b){return $(b).data("price")-$(a).data("price")});} else if(method=="price_asc"){roomrate.sort(function(a,b){return $(a).data("price")-$(b).data("price")});} $("#hotels_grid").html(roomrate);}});if($('.roomrate:visible,.rateplan_step2:visible').length==0){$(".unavailable_dates").removeClass("d-none");}else{$(".unavailable_dates").addClass("d-none");}