function getPriceCalculation(){var f;estimatedCostXHR&&(estimatedCostXHR.abort(),estimatedCostXHR=null);var i=$("#HouseID").val(),r=parseInt(adultDDL.val())+parseInt(childDDL.val()?childDDL.val():0),t=$(".js-hidden-arriveDate").val(),u=$(".js-hidden-departDate").val(),e=moment(t,"YYYY/MM/DD"),o=moment(u,"YYYY/MM/DD"),n=0;t.length>0&&u.length>0&&(n=o.diff(e,"days"));f=n>1?"nights":"night";i>0&&r>0&&n>0?estimatedCostXHR=$.ajax({url:"/api/RateCalculation/"+i+"/"+t+"/"+n+"/"+r,type:"GET",success:function(t){t!="$0 NZD"?($(".EstimatedCost").text("Estimated price for "+n+" "+f),$(".estimatedPrice").html(t),$(".estimatedPrice").show(),$(".Price").hide()):($(".EstimatedCost").text("From"),$(".estimatedPrice").hide(),$(".Price").show())},error:function(){$(".EstimatedCost").text("From");$(".estimatedPrice").hide();$(".Price").show()}}):($(".EstimatedCost span").text("From"),$(".estimatedPrice").hide(),$(".Price").show())}var estimatedCostXHR=null,guestsDDL=$("#Guests"),adultDDL=$("#AdultGuests"),childDDL=$("#ChildGuests");$(function(){function r(n){n.preventDefault();var t=$(n.target);t.is("DIV.js-Shortlist")&&(t=t.parent());jQuery.get(t.attr("href"),{ajax:"true"},u)}function u(n){var t=$("A.Button--shortlist.js-shortlist"),i=$("A.js-Shortlist");t.attr("href",n.url);i.attr("href",n.url);n.url.search("Remove")>0?(t.html("- SHORTLIST").attr("title","Click to remove from shortlist"),i.removeClass("Shortlist-add").addClass("Shortlist-remove").attr("title","Click to remove from shortlist")):(t.html("+ SHORTLIST").attr("title","Click to add to shortlist"),i.removeClass("Shortlist-remove").removeClass("Shortlist-remove").addClass("Shortlist-add").attr("title","Click to add to shortlist"));hhLib.UpdateShortlistCount(n.count)}hhLib.houseLib={GetBookingDates:function(){var n={arriveDate:"",departDate:""},t=hhLib.houseLib.getArriveDate().val(),i=hhLib.houseLib.getDepartDate().val();return t!=""&&(n.arriveDate=new Date(t)),i!=""&&(n.departDate=new Date(i)),n},SetBookingDates:function(){var f=$(".bookingView .checkinday").val(),e=$(".bookingView .CheckInMonth").val(),n,t,o=parseInt($(".bookingView .BookingDuration").val()),i,r,u;e!=""&&(i=e.split(":"),n=parseInt(i[0]),t=parseInt(i[1]));f!=""&&n!=""&&t!=""&&(r=moment(new Date(t,n-1,f)),u=moment(r),u.add("days",o),hhLib.houseLib.DatePickerCallback(r.toDate(),u.toDate()))},getBookingArriveDay:function(){return $(".bookingView .checkinday")},getBookingMonthYear:function(){return $(".bookingView .CheckInMonth")},getBookingDuration:function(){return $(".bookingView .BookingDuration")},getArriveDD:function(){return $(".CheckinContainer .date-dd")},getArriveMMM:function(){return $(".CheckinContainer .date-month")},getArriveYYYY:function(){return $(".CheckinContainer .date-year")},getArriveDate:function(){return $(".CheckinContainer .rawdate")},getDepartDD:function(){return $(".CheckoutContainer .date-dd")},getDepartMMM:function(){return $(".CheckoutContainer .date-month")},getDepartYYYY:function(){return $(".CheckoutContainer .date-year")},getDepartDate:function(){return $(".CheckoutContainer .rawdate")},DatePickerCallback:function(n,t){n!=null&&(n=new Date(n));t!=null&&(t=new Date(t));hhLib.houseLib.getArriveDate().val("");hhLib.houseLib.getDepartDate().val("");hhLib.houseLib.getArriveDD().html(n?n.getDate():"");hhLib.houseLib.getArriveMMM().html(n?hhLib.monthAbbrevs[n.getMonth()].toUpperCase():"");hhLib.houseLib.getArriveYYYY().html(n?n.getFullYear():"");hhLib.houseLib.getArriveDate().val(n?n.toString():"");hhLib.houseLib.getDepartDD().html(t?t.getDate():"");hhLib.houseLib.getDepartMMM().html(t?hhLib.monthAbbrevs[t.getMonth()].toUpperCase():"");hhLib.houseLib.getDepartYYYY().html(t?t.getFullYear():"");hhLib.houseLib.getDepartDate().val(t?t.toString():"");$(".FormContainer INPUT.ArriveDate").val(n?moment(n).format("ddd Do MMM YYYY"):"");$(".FormContainer INPUT.DepartDate").val(t?moment(t).format("ddd Do MMM YYYY"):"");$("INPUT.js-hidden-arriveDate").val(n?moment(n).format("YYYY-MM-DD"):"");$("INPUT.js-hidden-departDate").val(t?moment(t).format("YYYY-MM-DD"):"");$(".ArriveDateHidden").val(n?n.toString():"");$(".DepartDateHidden").val(t?t.toString():"");$(".js-DateRangePicker").each(function(){var i=$(this);n||t?(i.data("daterangepicker").setStartDate(n),i.data("daterangepicker").setEndDate(t)):i.data("daterangepicker").reset(n)});getPriceCalculation()}};$(".bookingDates .daterangepickertrigger").find('input[type="text"]').prop("readonly",!0);CreateCollapseToggler=function(n){return function(){var t=n,i=t.closest(".js-collapsible-section");AnimateSection(i)}};AnimateSection=function(n){n.find(".section-content").toggle("blind");n.hasClass("collapsed")?(n.removeClass("collapsed").addClass("open"),hhLib.ScrollToAnchor(n.attr("id")),n.find(".section-content").find(".js-gmap").length>0&&google.maps.event.trigger(map,"resize")):n.removeClass("open").addClass("collapsed")};$(".collapsible-header").each(function(n,t){t=$(t);t.click(CreateCollapseToggler(t)).attr("title","Click to show/hide this section")});var t=$(".js-hidden-arriveDate").val(),i=$(".js-hidden-departDate").val(),n={availabilityDates:$("#js-ShowAvailability").val()==="true"};t&&(n.startDate=t,i&&(n.endDate=i));$(".js-DateRangePicker").daterangepicker(n,hhLib.houseLib.DatePickerCallback);$(".description.full").hide();$(".ReadMore, .ShowLess").click(function(n){n.preventDefault();$(".description.short").toggle();$(".description.full").toggle()});$(".Reviews .ShowAll").click(function(n){n.preventDefault();$(".ListingComment.hiddenComment").removeClass("hiddenComment");$(n.target).hide()});$(".bookingView .checkinday").change(function(){hhLib.houseLib.SetBookingDates()});$(".bookingView .CheckInMonth").change(function(){hhLib.houseLib.SetBookingDates()});$(".bookingView .BookingDuration").change(function(){hhLib.houseLib.SetBookingDates()});$(".js-listingHeaderGuestsdropdown").select2({minimumResultsForSearch:1e3,dropdownCssClass:"noPaddingDropdown"});$(".Button.Button--enquire, .Button.Button--book").not(".bookingView .Button.Button--book, .enquiryView .Button--enquire").click(function(n){n.preventDefault();var t=$(n.target);$(".Forms.js-collapsible-section.collapsed").length==1&&AnimateSection($(".Forms.js-collapsible-section"));hhLib.ScrollToAnchor("booking-enquiry-form")});hhLib.AttachHandlerIfCookiesAreOn($(".Button--shortlist.js-shortlist, A.js-Shortlist"),r);$("ctl00_PH_Content_ListingHeader_DisplayPrice").show();guestsDDL.change(function(){adultDDL.select2("val",guestsDDL.val());childDDL.select2("val",0);getPriceCalculation()});adultDDL.change(function(){guestsDDL.select2("val",adultDDL.val());getPriceCalculation()});childDDL.change(function(){getPriceCalculation()})})