VYG.checkavailabilitybookingbar={elGlobal:$J(".find-tour-wrapper.uxchange"),showPrice:!1,productsMinAge:0,productsMaxAge:99,productsInfantAge:0,productsInfantAllow:!1,productsChildAllow:!0,init:function(){VYG.checkavailabilitybookingbar.compileTemplates();VYG.checkavailabilitybookingbar.initBookingBarForm()},compileTemplates:function(){VYG.checkavailabilitybookingbar.compileRoomFormTemplate()},childAgeFormTemplateCompiled:{},childCheckboxFormTemplateCompiled:{},childFormTemplateCompiled:{},compileRoomFormTemplate:function(){VYG.checkavailabilitybookingbar.childAgeFormTemplateCompiled=Hogan.compile('<div class="control-group"><label class="control-label {{classHide}}" for="{{selectChildAgeId}}">Age<\/label><div class="controls"><span class="child-number">Child {{childAgeNumber}}<\/span><select id="{{selectChildAgeId}}" class="select2 select-child-age {{classValMaxEmpty}}"  data-placeholder="">{{{chidlAgeOption}}}><\/select><\/div><\/div>');VYG.checkavailabilitybookingbar.childCheckboxFormTemplateCompiled=Hogan.compile('<ul class="list-children-checkbox">{{{childList}}}<li class="add-another-child-wrap"><div class="control-group add-another-child-form"><div class="controls"><span class="child-number">Child {{childNumberNext}} Age<\/span><select id="bookingbar_select_child_age_add_{{childIndex}}" class="select2 select-child-age-add select-empty pull-left" data-placeholder="">{{{chidlAgeOption}}}<\/select><button class="save-another-child pull-left" data-index="{{childIndex}}">Save<\/button><\/div><\/div><\/li><li class="{{classHide}}"><button class="add-another-child pull-left" data-index="{{childIndex}}"><em><\/em> Add Another Child<\/button><\/li><\/ul>');VYG.checkavailabilitybookingbar.childFormTemplateCompiled=Hogan.compile('<label class="control-label {{classHide}}" for="{{selectChildId}}">Children <span class="icon-info popinfo" data-toggle="popover" data-original-title="" data-content="{{infoIconChildren}}">info<\/span><\/label><div class="controls"><select id="{{selectChildId}}" class="select2 select-child-qty" data-index="{{index}}">{{{childOption}}}<\/select><\/div>')},initBookingBarForm:function(){var n=VYG.checkavailabilitybookingbar.elGlobal;$J(".main-navigation li.dropdown").mouseover(function(){$J(n).addClass("hide");$J("ft-sticky.expanded").length==0&&$J("body").removeClass("static-fft")});$J(n).on("focus","#bookingbar_selected_checkin",function(){$J(this).val()==""&&VYG.checkavailabilitybookingbar.setDefaultStartDate($J("#bookingbar_selected_checkin"))});$J(n).on("blur","#bookingbar_selected_checkin",function(){$J(this).val()==""&&n.find(".check-avail").addClass("disabled")});$J(n).on("click",".icon-date-select",function(){$J(n).find("#bookingbar_selected_checkin").val()==""&&VYG.checkavailabilitybookingbar.setDefaultStartDate($J("#bookingbar_selected_checkin"))});$J(n).on("change","select.select-child-qty",function(){var t=$J(this).val(),i=$J(this).data("index")?$J(this).data("index"):$J(n).find("select.select-child-qty").index($J(this));VYG.checkavailabilitybookingbar.renderChildAgeForm(t,i);VYG.checkavailabilitybookingbar.isAllChildAgeSelected()?$J(n).find(".check-avail").removeClass("disabled"):VYG.checkavailabilitybookingbar.elGlobal.find(".check-avail").addClass("disabled")});$J(n).on("change","select.select-child-age",function(){VYG.checkavailabilitybookingbar.isAllChildAgeSelected()&&$J(n).find(".check-avail").removeClass("disabled")});$J(n).on("change","select.select-child-age, .select-child-age-add",function(){var i=$J(this).val(),t=$J(this).attr("id");$J(n).find(".select2-container#s2id_"+t).removeClass("select-empty");i>9?$J(n).find(".select2-container#s2id_"+t).addClass("max-val"):$J(n).find(".select2-container#s2id_"+t).removeClass("max-val")});$J(n).on("click",".check-avail",function(){var u,i,f,t,s,h,r,e,o;$J(".save-another-child").popover("destroy");VYG.checkavailabilitybookingbar.isDataValid()&&!$J(this).hasClass("disabled")?(u=!1,i=$J.cookie("experience-search")||null,i&&i.length>1&&(f=$J("a[href='"+i+"']"),f.length>0&&(u=!0,$J("html, body").animate({scrollTop:$J(f).offset().top-150},0))),r=$J(window).width(),r<768&&$J(".title-cont a.experience-product, .title-cont .experience-product").each(function(){$J(this).css("display","block");$J(this).parents(".accordion-header").find(".prices-cont h3, .prices-cont p").hide()}),u||(t=$J(".tourItems"),VYG.cookie.read("WISHLISTPROD")&&(t=$J(".tourItems .tourItem .accordion-header .title-cont h3").filter(function(){return $J(this).text()===VYG.cookie.read("WISHLISTPROD")}),t==="undefined"&&(t=$J(".tourItems"))),VYG.cookie.erase("WISHLISTPROD"),s=$J(window).scrollTop(),h=s==0?170:70,$J("html, body").animate({scrollTop:$J(t).offset().top-150},0)),VYG.checkavailability.resetResultData(),VYG.checkavailabilitybookingbar.saveCheckAvailData(n),VYG.checkavailabilitybookingbar.renderChildCheckbox(),VYG.checkavailabilitybookingbar.showPrice=!0,$J.cookie("experience-search","",{expires:-1,path:"/"})):(r=$J(window).width(),r<768&&(e=$J("div.row-fluid.feat-top.pos-relative a.dropdown-mobile-button"),e.length>0&&e.parents("div.inner-pad").hide(),o=$J("div.container-fluid.event-detail a.dropdown-mobile-button"),o.length>0&&o.parents("div.control-buttons").hide()))});$J(n).find(".check-avail").mouseleave(function(){$J(this).popover("hide")});$J(n).on("click",".add-another-child",function(){VYG.checkavailabilitybookingbar.addAnotherChildCheckbox($J(this),"addForm")});$J(n).on("click",".save-another-child",function(){VYG.checkavailabilitybookingbar.addAnotherChildCheckbox($J(this),"save")});$J(".add-itinerary").on("click",".view-tours",function(){return $J(".header.mini").length>0?$J("html,body").animate({scrollTop:$J(".find-tour-wrapper.uxchange").offset().top-80},500):$J("html,body").animate({scrollTop:$J(".find-tour-wrapper.uxchange").offset().top-180},500),!1});VYG.checkavailabilitybookingbar.renderBookingBarForm()},isAllChildAgeSelected:function(){for(var u,o,t,f=1,i=0,r=[],e=0,n=0;n<f;n++)$J("#bookingbar_select_child_qty_"+n).length>0&&(i=i+parseInt($J("#bookingbar_select_child_qty_"+n).val()==null?0:$J("#bookingbar_select_child_qty_"+n).val()));for(r.length=i;e<i;)r[e++]=!1;for(u=0,n=0;n<f;n++)for(o=$J("#bookingbar_select_child_qty_"+n).val(),t=0;t<o;t++)$J("#bookingbar_select_child_age_"+n+"_"+t).val()!=""&&parseInt($J("#bookingbar_select_child_age_"+n+"_"+t).val())>=0&&(r[u]=!0),u++;return r.indexOf(!1)==-1&&$J("#bookingbar_selected_checkin").val()!=""?!0:!1},renderChildAgeForm:function(n,t){var i=VYG.checkavailabilitybookingbar.elGlobal,v="",u=JSON.parse($J.cookie("check-avail-data")||null),p=window.location.href.indexOf("?checkmode=on")>-1,w=window.location.href.indexOf("upi=")>-1,b,y,c,o,r,f,a;if($J(i).find(".room-form:eq("+t+") .find-avail-child-age").remove(),$J(i).find(".find-avail-rooms-people").css("width","auto"),n>0){if(b=u?u.tourData:"",y=0,$J(b).each(function(n,t){y+=t.child}),c=0,u==null||y!=n)for(r=0;r<n;r++){var l="<option><\/option>",e=u&&u.tourData[t]&&u.tourData[t].childData[r]?u.tourData[t].childData[r]:"",s="",h="select-empty";if(p&&w){var k=$J("#UserProductItineraryData"),d=$J(k).attr("data-userproductitinerary-childrenage"),g=d.split(",");e=g[r]}for(f=0;f<=15;f++)s=e==f&&e!=""?'selected="selected"':"",s&&(h=""),l+="<option "+s+' value="'+f+'">'+f+"<\/option>";a={childAgeNumber:r+1,selectChildAgeId:"bookingbar_select_child_age_"+t+"_"+r,chidlAgeOption:l,classHide:r>0||t>0?"invsbl-accessible":"",classValMaxEmpty:e>9?"max-val "+h:h};v+=VYG.checkavailabilitybookingbar.childAgeFormTemplateCompiled.render(a)}else for(o=0;o<u.tourData.length;o++)for(r=0;r<u.tourData[o].child;r++){var l="<option><\/option>",e=u&&u.tourData[o]&&u.tourData[o].childData[r]?u.tourData[o].childData[r]:"",s="",h="select-empty";if(p&&w){var k=$J("#UserProductItineraryData"),d=$J(k).attr("data-userproductitinerary-childrenage"),g=d.split(",");e=g[r]}for(f=0;f<=15;f++)s=e==f&&e!=""?'selected="selected"':"",s&&(h=""),l+="<option "+s+' value="'+f+'">'+f+"<\/option>";a={childAgeNumber:c+1,selectChildAgeId:"bookingbar_select_child_age_"+t+"_"+c,chidlAgeOption:l,classHide:c>0||t>0?"invsbl-accessible":"",classValMaxEmpty:e>9?"max-val "+h:h};v+=VYG.checkavailabilitybookingbar.childAgeFormTemplateCompiled.render(a);c++}$J('<div class="span1 find-avail-child-age"><\/div>').insertAfter(".find-tour-wrapper.uxchange .room-form:eq("+t+") .find-avail-children");$J(i).find(".room-form:eq("+t+") .find-avail-child-age").html($J.parseHTML(v));$J(i).find(".room-form:eq("+t+") .find-avail-child-age select").each(function(){$J(this).addClass("select2");$J(this).select2({minimumResultsForSearch:-1})})}else $J(i).find(".find-avail-rooms-people .room-form:eq("+t+")").removeClass("multiple-children"),$J(i).find(".find-avail-child-age").length==0&&($J(i).find(".find-avail-adults label.invsbl-accessible-hide").addClass("invsbl-accessible"),$J(i).find(".find-avail-children label.invsbl-accessible-hide").addClass("invsbl-accessible"));n>1||$J(i).find(".find-avail-child-age").length>1||$J(i).find("select.select-child-age").length>1||$J(i).find(".room-form.multiple-children").length>1||$J(i).find(".room-form .list-children-checkbox").length>0?($J(i).find(".find-avail-rooms-people .room-form:eq("+t+")").addClass("multiple-children"),$J(i).find(".find-avail-adults label.invsbl-accessible").removeClass("invsbl-accessible").addClass("invsbl-accessible-hide"),$J(i).find(".find-avail-children label.invsbl-accessible").removeClass("invsbl-accessible").addClass("invsbl-accessible-hide"),$J(i).find(".find-avail-child-age").each(function(){$J(this).find(".control-group:eq(0) label.invsbl-accessible").removeClass("invsbl-accessible")}),$J(i).find(".room-form").length>1&&($J(i).find(".find-avail-rooms-people").css("width","555px"),$J($J(i).find(".check-avail-promo")).insertAfter($J(i).find(".room-form").last().find(".find-avail-children"))),$J(i).find("select.select-child-age").length==0&&$J(i).find(".list-children-checkbox").length==0&&($J(i).find(".find-avail-rooms-people .room-form").removeClass("multiple-children"),$J(i).find(".find-avail-adults label.invsbl-accessible-hide").addClass("invsbl-accessible"),$J(i).find(".find-avail-children label.invsbl-accessible-hide").addClass("invsbl-accessible"))):$J($J(i).find(".check-avail-promo")).appendTo($J(i).find(".check-avail-promo-temp"))},renderChildCheckbox:function(){VYG.checkavailabilitybookingbar.setMinMaxAge();var n=VYG.checkavailabilitybookingbar.elGlobal;$J(n).find(".room-form").each(function(n){var t=$J(this).find("select.select-child-qty").length>0?$J(this).find("select.select-child-qty").val():0,i=n;t=parseInt(t);$J(this).find(".list-children-checkbox").find("[name=childAge]").each(function(){$J(this).attr("checked")&&t++});VYG.checkavailabilitybookingbar.renderChildCheckboxForm(t,i)})},renderInfoBar:function(n){var t=parseInt($J("#bookingbar_select_adult_qty_0").val()),r,i;t+=t>1?" Adults":" Adult";r=n>0?" <em>&middot;<\/em> ":"";n+=n>1?" Children":n>0?" Child":"";n=n==0?"":n;i="Select tour(s) & preferred time";$J(".find-avail-info p > span.consumerInfo").remove();$J(".find-avail-info p > strong").text(i);$J(".tourItem .prices-default .price-info-text").addClass("hide")},renderChildCheckboxForm:function(n,t){var h,c,r,u,a,v,e,y,l,p,o,w;VYG.checkavailabilitybookingbar.renderInfoBar(n);var i=VYG.checkavailabilitybookingbar.elGlobal,s="",f=JSON.parse($J.cookie("check-avail-data")||null);if(n>0){for(h="",c="<option><\/option>",r=0;r<f.tourData.length;r++)for(u=0;u<f.tourData[r].child;u++)a=f&&f.tourData[r]&&f.tourData[r].childData[u]?f.tourData[r].childData[u]:0,v="bookingbar_checkbox_child_age_"+r+"_"+u,h+=this.childValidateMessage(a,v,u);for(e=0;e<=15;e++)c+='<option value="'+e+'">'+e+"<\/option>";y={childIndex:t,childList:h,chidlAgeOption:c,childNumberNext:parseInt(n)+1,classHide:n==8?"hide":""};s=VYG.checkavailabilitybookingbar.childCheckboxFormTemplateCompiled.render(y);$J(i).find(".room-form:eq("+t+") .find-avail-children").addClass("children-checkbox").addClass("children-rule-applay").find(".controls").html($J.parseHTML(s));$J(i).find(".room-form:eq("+t+') .find-avail-children input[type="checkbox"]').prettyCheckable({});$J(i).find(".room-form:eq("+t+") .find-avail-children select").each(function(){$J(this).addClass("select2");$J(this).select2({minimumResultsForSearch:-1})});$J(i).find(".room-form:eq("+t+") .find-avail-child-age").remove();$J(i).find(".find-avail-rooms-people .room-form:eq("+t+")").addClass("multiple-children");$J(i).find(".find-avail-adults label.invsbl-accessible").removeClass("invsbl-accessible").addClass("invsbl-accessible-hide");$J(i).find(".find-avail-children label.invsbl-accessible").removeClass("invsbl-accessible").addClass("invsbl-accessible-hide");$J(i).find(".find-avail-child-age").each(function(){$J(this).find(".control-group:eq(0) label.invsbl-accessible").removeClass("invsbl-accessible")});$J(i).find(".room-form").length>1&&($J(i).find(".find-avail-rooms-people").css("width","555px"),$J($J(i).find(".check-avail-promo")).insertAfter($J(i).find(".room-form").last().find(".find-avail-children")))}else{for(l="",p=$J(i).find(".info-icon-children").val(),o=0;o<9;o++)l+='<option value="'+o+'">'+o+"<\/option>";w={index:t,selectChildId:"bookingbar_select_child_qty_"+t,childOption:l,classHide:"",infoIconChildren:p};s=VYG.checkavailabilitybookingbar.childFormTemplateCompiled.render(w);$J(i).find(".room-form:eq("+t+")").removeClass("multiple-children");$J(i).find(".room-form:eq("+t+") .find-avail-children").removeClass("children-checkbox").removeClass("children-rule-applay").html($J.parseHTML(s));$J(i).find(".room-form:eq("+t+") .find-avail-adults .control-label").hasClass("invsbl-accessible")&&$J(i).find(".room-form:eq("+t+") .find-avail-children .control-label").addClass("invsbl-accessible");$J(i).find(".room-form:eq("+t+") .find-avail-children select").each(function(){$J(this).addClass("select2");$J(this).select2({minimumResultsForSearch:-1})})}$J(i).find(".find-avail-children .icon-info").mouseover(function(){$J(this).popover("show")});$J(i).find(".find-avail-children .icon-info").mouseleave(function(){$J(this).popover("hide")})},addAnotherChildCheckbox:function(n,t){var r=VYG.checkavailabilitybookingbar.elGlobal,i=$J(n).data("index"),u,f;if(t=="addForm")$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child-wrap .add-another-child-form").show(),$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child").hide(),$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .find-avail-children .check-avail-children-rule-ifo").length==0?$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child-wrap .add-another-child-form").addClass("max-width"):$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child-wrap .add-another-child-form").removeClass("max-width");else if(t=="save")if(u=$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .save-another-child"),f=$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") select.select-child-age-add").val(),f=="")errormessage="Please select child age",$J(u).popover("destroy"),$J(u).addClass("popinfo"),$J(u).attr("data-toggle","popover"),$J(u).attr("data-content",errormessage),$J(u).popover("show");else{f=parseInt(f);var e=$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") [name=childAge]").length,o="bookingbar_checkbox_child_age_"+i+"_"+(parseInt(e)+1),s=this.childValidateMessage(f,o,parseInt(e));$J(s).insertBefore($J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child-wrap"));$J(r).find(".find-avail-rooms-people .room-form:eq("+i+') .find-avail-children input[type="checkbox"]').prettyCheckable({});$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child-wrap .add-another-child-form").hide();$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child-wrap .add-another-child-form .child-number").text("Child "+(parseInt(e)+2)+" Age");e<7&&$J(r).find(".find-avail-rooms-people .room-form:eq("+i+") .add-another-child").show();$J(u).removeClass("popinfo");$J(u).removeAttr("data-toggle");$J(u).removeAttr("data-content");$J(u).popover("hide")}},childValidateMessage:function(n,t,i){var r="";return VYG.checkavailabilitybookingbar.productsChildAllow?n<VYG.checkavailabilitybookingbar.productsMinAge?r=this.genMessage("young","young"):n>VYG.checkavailabilitybookingbar.productsMaxAge&&(r=this.genMessage("adult","adult")):r=this.genMessage("young","young"),VYG.checkavailabilitybookingbar.productsInfantAllow||r==""&&VYG.checkavailabilitybookingbar.productsInfantAge>=VYG.checkavailabilitybookingbar.productsMinAge&&(r=this.genMessage("young","young")),'<li><input value="'+n+'" type="checkbox" checked="checked" id="'+t+'" name="childAge"/><label for="'+t+'">Child '+(i+1)+" | "+n+" Years old<\/label>"+r+"<\/li>"},setDefaultStartDate:function(n,t){var n=n,t=t,u=new Date,i=new Date(u.getFullYear(),u.getMonth(),u.getDate(),0,0,0,0),f=t>=i?t:i,e,o,s=VYG.vars.getItineraryPlanDate(),v=s.isFixedDate,h,c,a,r,l;s.planDate&&(f=new Date(s.planDate),i=new Date(s.planDate));typeof isEventPage!="undefined"&&(h=new Date(bookableFrom),i=new Date(h.getFullYear(),h.getMonth(),h.getDate()),c=new Date(bookableTo),o=new Date(c.getFullYear(),c.getMonth(),c.getDate()),u>i&&i<=o&&(i=u),a=VYG.checkavailabilitybookingbar.getEventSelectedDate(),a!=null&&(f=a));f&&(e=moment(f).format("YYYY-MM-DD"),$J(n).datepicker({format:"dd/mm/yyyy",onRender:function(n){return v?n.valueOf()!=i.valueOf()?"disabled":"":typeof isEventPage!="undefined"?n.valueOf()<i.valueOf()?"disabled":n.valueOf()>o.valueOf()?"disabled":n.valueOf()<i.valueOf()?"disabled":n.valueOf()>o.valueOf()?"disabled":"":n.valueOf()<i.valueOf()?"disabled":""}}),browserDetect.browser=="Explorer"?$J(n).val(moment(e).format("DD/MM/YYYY")).datepicker("update"):(e=moment(f).format("DD/MM/YYYY"),$J(n).datepicker("setValue",e)),r=JSON.parse($J.cookie("check-avail-data")||null),l=!0,r?(r.tourData&&r.tourData.length>0&&r.tourData[0]&&r.tourData[0].child&&(l=!1),!l&&VYG.checkavailabilitybookingbar.isAllChildAgeSelected()?VYG.checkavailabilitybookingbar.elGlobal.find(".check-avail").removeClass("disabled"):l&&VYG.checkavailabilitybookingbar.elGlobal.find(".check-avail").removeClass("disabled")):VYG.checkavailabilitybookingbar.elGlobal.find(".select-child-qty option:selected").val()>0&&VYG.checkavailabilitybookingbar.isAllChildAgeSelected()?VYG.checkavailabilitybookingbar.elGlobal.find(".check-avail").removeClass("disabled"):VYG.checkavailabilitybookingbar.elGlobal.find(".select-child-qty option:selected").val()==0&&VYG.checkavailabilitybookingbar.elGlobal.find(".check-avail").removeClass("disabled"))},showContactTravelCenter:function(){bootbox.dialog("<p>For requests of <strong>10 or more rooms<\/strong>, please contact the Voyages Travel Centre to discuss your group requirements. Email <strong>groups@voyages.com.au<\/strong> or call <strong>1300 134 044<\/strong>.<\/p>",[{label:"Ok","class":"",callback:function(){$J(".bootbox.modal").modal("hide")}}],{header:"Please Contact The Voyages Travel Centre"})},isDataValid:function(){var t="",n=VYG.checkavailabilitybookingbar.elGlobal,r=$J(n).find("#bookingbar_selected_checkin").val(),o=r==""||!moment(r,"DD/MM/YYYY",!0).isValid()?!1:!0,u=!1,s,h;if(o){var f=r.split("/"),c=parseInt(f[0]),l=parseInt(f[1])-1,i=f[2];i.length<4&&(i=String(2e3+parseInt(i)));var a=new Date(i,l,c,0,0,0,0),e=new Date,v=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0);a<v&&(u=!0)}return o?u?t="For bookings within 24 hours of arrival please contact the Voyages Travel Centre, call +61 2 8296 8010 or from within Australia 1300 134 044. <br /><br />Opening hours are Monday to Friday between 8am and 6:30pm (AEST), and from 9am to 5pm (AEST) on Saturday and Sunday.":$J(n).find(".find-avail-child-age select.select-child-age").each(function(){var n=$J(this).val();n==""&&(t="To show prices we need the age of each child")}):t="To show prices we need your check in date please",$J(n).find(".check-avail").popover("destroy"),t?(s=$J(window).width(),s>=768&&($J(n).find(".check-avail").addClass("popinfo"),$J(n).find(".check-avail").attr("data-toggle","popover"),$J(n).find(".check-avail").attr("data-content",t),$J(n).find(".check-avail").popover("show")),u&&(h="<p>"+t+"<\/p>",bootbox.dialog(h,[],{header:"Cannot book within 24 hours"})),!1):($J(n).find(".check-avail").removeClass("popinfo"),$J(n).find(".check-avail").removeAttr("data-toggle"),$J(n).find(".check-avail").removeAttr("data-content"),$J(n).find(".check-avail").popover("hide"),!0)},renderBookingBarForm:function(){var n=VYG.checkavailabilitybookingbar.elGlobal,i=JSON.parse($J.cookie("check-avail-data")||null),l=window.location.href.indexOf("?checkmode=on")>-1,a=window.location.href.indexOf("upi=")>-1,s=$J(window).width(),r,o,e,f,t,h;if(l&&a)r=$J("#UserProductItineraryData"),e=new Date($J(r).attr("data-userproductitinerary-date")),VYG.checkavailabilitybookingbar.setDefaultStartDate($J("#bookingbar_selected_checkin"),e),s<768?($J(n).find("select.select-adult-qty").prop("selectedIndex",-1),$J(n).find("select.select-adult-qty").val(parseInt($J(r).attr("data-userproductitinerary-adults"))),$J(n).find("select.select-child-qty").prop("selectedIndex",-1),$J(n).find("select.select-child-qty").val(parseInt($J(r).attr("data-userproductitinerary-children"))).trigger("change")):($J(n).find("select.select-adult-qty").select2("val",parseInt($J(r).attr("data-userproductitinerary-adults"))),$J(n).find("select.select-child-qty").select2("val",parseInt($J(r).attr("data-userproductitinerary-children"))).trigger("change")),setTimeout(function(){$J(n).find(".check-avail").trigger("click")},2500);else if(i){var c=i.checkinDateTour?i.checkinDateTour:i.checkinDate,u=i.tourData,v=i.currencyCode;c!=""&&(o=c.split("/"),e=new Date(parseInt(o[2]),parseInt(o[1])-1,parseInt(o[0]),0,0,0,0),VYG.checkavailabilitybookingbar.setDefaultStartDate($J("#bookingbar_selected_checkin"),e));$J(n).find("#bookingbar_currency_code").val(v);f=2;t=0;u&&u.length>0&&(u[0].adult&&(f=u[0].adult),u[0].child&&(t=u[0].child));$J(n).find('select.select-adult-qty option[value="'+parseInt(f)+'"]').attr("selected",!0);s<768?($J(n).find("select.select-adult-qty").prop("selectedIndex",-1),$J(n).find("select.select-adult-qty").val(parseInt(f))):$J(n).find("select.select-adult-qty").select2("val",parseInt(f));t>0&&(s<768?($J(n).find("select.select-child-qty").prop("selectedIndex",-1),$J(n).find('select.select-child-qty option[value="'+parseInt(t)+'"]').attr("selected",!0),$J(n).find("select.select-child-qty").val(parseInt(t)).trigger("change")):($J(n).find('select.select-child-qty option[value="'+parseInt(t)+'"]').attr("selected",!0),$J(n).find("select.select-child-qty").select2("val",parseInt(t)).trigger("change")))}typeof isEventPage!="undefined"&&(h=VYG.checkavailabilitybookingbar.getEventSelectedDate(),h!=null&&VYG.checkavailabilitybookingbar.setDefaultStartDate($J("#bookingbar_selected_checkin"),h))},saveCheckAvailData:function(n){var u=$J(n).find("#bookingbar_selected_checkin").val(),l=[],t=JSON.parse($J.cookie("check-avail-data")||null),p=t?t.accommodation:"",w=t?t.roomNumber:1,b=t?t.roomData:"",tt=t?t.tourData:"",k=t?t.checkinDate:"",d=t?t.checkinDateTour:"",a="AUD",e,v,c,y;t!=null&&(a=t.currencyCode?t.currencyCode:"AUD");var o=u.split("/"),g=o[0],nt=o[1],f=o[2];f.length<4&&(f=String(2e3+parseInt(f)),u=g+"/"+nt+"/"+f);var i=0,s=$J(n).find("#bookingbar_select_adult_qty_"+i).val(),h=[],r=0;if($J(n).find("#bookingbar_select_child_qty_"+i).length)for(r=$J(n).find("#bookingbar_select_child_qty_"+i).val(),e=0;e<r;e++)v=$J(n).find("#bookingbar_select_child_age_"+i+"_"+e).val(),h.push(parseInt(v));$J(n).find(".room-form:eq("+i+") .list-children-checkbox").length&&$J(n).find(".room-form:eq("+i+") .list-children-checkbox").find("[name=childAge]").each(function(){if($J(this).attr("checked")){var n=$J(this).val();h.push(parseInt(n));r++}});s=parseInt(s);r=parseInt(r);l.push({adult:s,child:r,childData:h});c=$J(window).width();y={accommodation:p,checkinDate:c<768?k:u,checkinDateTour:c<768?d:u,duration:t?t.duration:1,roomNumber:w,roomData:b,tourData:l,currencyCode:a,triggerShowPrice:!1};$J.cookie("check-avail-data",JSON.stringify(y),{expires:30,path:"/"})},setMinMaxAge:function(){for(var n=$J("[id*=productid-]"),f=n.length,i=0,r=99,u=99,t=0;t<f;t++)i=Math.max(i,parseInt($J(n[t]).data("product-child-min-age"),10)),r=Math.min(r,parseInt($J(n[t]).data("product-child-max-age"),10)),u=Math.min(u,parseInt($J(n[t]).data("product-infant-age"),10));VYG.checkavailabilitybookingbar.productsMinAge=i;VYG.checkavailabilitybookingbar.productsMaxAge=r;VYG.checkavailabilitybookingbar.productsInfantAge=u;VYG.checkavailabilitybookingbar.productsInfantAllow=$J(n[0]).data("product-infant-status")=="True"?!0:!1;VYG.checkavailabilitybookingbar.productsChildAllow=$J(n[0]).data("product-child-allowed")=="True"?!0:!1},genMessage:function(n,t){return n=n=="young"?"too young":n=="adult"?"Classed as adult":n,t=t=="young"?"Some items will not available":t=="adult"?"Adult price will be applied":t,'<span class="check-avail-children-rule-ifo"><em class="icon-info popinfo" data-toggle="popover" data-original-title="" data-content="'+t+'"><\/em> '+n+"<\/span>"},getEventSelectedDate:function(){if(bookableFrom.length>0&&bookableTo.length>0){var r=new Date(bookableFrom),t=new Date(r.getFullYear(),r.getMonth(),r.getDate()),u=new Date(bookableTo),f=new Date(u.getFullYear(),u.getMonth(),u.getDate()),o=new Date,n=o,i=JSON.parse($J.cookie("check-avail-data")||null);if(i){var s=i.checkinDateTour?i.checkinDateTour:i.checkinDate,e=s.split("/"),h=new Date(parseInt(e[2]),parseInt(e[1])-1,parseInt(e[0]),0,0,0,0);n=h}return f<o?n=null:n<=t?n=t:n>=t&&n<=f?n=n:n>f&&(n=t),n}return null}};$J(document).ready(function(){VYG.checkavailabilitybookingbar.init()})