function calculateDays(n,t){var u=+new Date(n),f=+new Date(t),i=864e5,r=f-u;return Math.round(r/i)}function renderChildren(){for(i=0;i<$("#Children").val();i++)$("#ChildrenList").append(' \t\t\t\t\t<select data-val="true" data-val-number="The field Nullable`1 must be a number." id="ChildAges_'+i+'_" name="ChildAges['+i+']"> \t\t\t\t\t\t<option selected="selected"></option> \t\t\t\t\t\t<option value="0">0</option> \t\t\t\t\t\t<option value="1">1</option> \t\t\t\t\t\t<option value="2">2</option> \t\t\t\t\t\t<option value="3">3</option> \t\t\t\t\t\t<option value="4">4</option> \t\t\t\t\t\t<option value="5">5</option> \t\t\t\t\t\t<option value="6">6</option> \t\t\t\t\t\t<option value="7">7</option> \t\t\t\t\t\t<option value="8">8</option> \t\t\t\t\t\t<option value="9">9</option> \t\t\t\t\t\t<option value="10">10</option> \t\t\t\t\t\t<option value="11">11</option> \t\t\t\t\t\t<option value="12">12</option> \t\t\t\t\t\t<option value="13">13</option> \t\t\t\t\t\t<option value="14">14</option> \t\t\t\t\t\t<option value="15">15</option> \t\t\t\t\t\t<option value="16">16</option> \t\t\t\t\t\t<option value="17">17</option> \t\t\t\t\t</select>')}$(function(){var u;moment().format(),$(function(){$("input, textarea").placeholder()});var r=new Date,i=new moment(new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0,0)),t=$("#CheckIn").datepicker({format:"dd M yyyy",beforeShowDay:function(n){return n.valueOf()>=i.valueOf()}}).on("changeDate",function(r){var u,f;r.date==undefined&&(r.date=i.toDate(),t.setValue(i.toDate()),t.setDate(i.toDate())),r.date.valueOf()>n.getDate().valueOf()&&(u=new Date(r.date),u.setDate(u.getDate()+1),n.setValue(u),n.setDate(u),n.update()),$("#CheckIn").hasClass("input-validation-error")&&$("#CheckIn").removeClass("input-validation-error"),$("#CheckOut").val().length>0&&(f=calculateDays($("#CheckIn").val(),$("#CheckOut").val()),$("#txtNights").val(f)),t.hide(),$("#CheckOut")[0].focus()}).data("datepicker"),n=$("#CheckOut").datepicker({format:"dd M yyyy",beforeShowDay:function(n){return n.valueOf()>t.getDate().valueOf()}}).on("changeDate",function(i){var u=new moment(new Date(t.getDate())),r;i.date==undefined&&(r=$("#txtNights").val(),i.date=u.add("days",r).toDate(),n.setValue(i.date),n.setDate(i.date)),$("#CheckOut").hasClass("input-validation-error")&&$("#CheckOut").removeClass("input-validation-error"),$("#CheckIn").val().length>0&&(r=calculateDays($("#CheckIn").val(),$("#CheckOut").val()),$("#txtNights").val(r)),n.hide()}).data("datepicker");$(".input-daterange").datepicker({format:"dd M yyyy",startDate:i.toDate(),orientation:"auto left",weekStart:1,todayHighlight:!0});$("#Children").on("change",function(){$("#ChildrenList").empty(),$(this).val()>0?$("#ChildrenList").append('<label for="ChildAges">Child Ages</label>'):$("#ChildrenList").html("&nbsp"),renderChildren(),$("#ChildrenList").show()});$("#liCheckIn .calendar-icon").on("click",function(){$("#CheckIn").datepicker("show")});$("#liCheckOut .calendar-icon").on("click",function(){$("#CheckOut").datepicker("show")});$("#txtNights").on("focusout",function(){if($("#CheckIn").val().length>0){var t=$(this).val(),n=new moment(new Date($("#CheckIn").val()));$("#CheckOut").datepicker("setDate",n.add("days",t).toDate())}});parseInt($("#Children").val())>0?($("#ChildrenList select").each(function(){$(this).val().length>0?$(this).show():$(this).hide()}),$("#ChildrenList").show()):$("#ChildrenList").html("&nbsp"),$("#CheckIn").val().length>0&&$("#CheckOut").val().length>0&&(u=calculateDays($("#CheckIn").val(),$("#CheckOut").val()),$("#txtNights").val(u))})