VYG.childSelect={data:[],childData:[],childAges:[],_productId:undefined,minAge:99,productsMinAge:99,productsMaxAge:0,childAsAdultCount:0,num:null,tplSub1:null,tplSub2:null,tplSub3:null,isAccomodationDetail:!1,selectChildEl:".find-tour-children select.select2, .find-avail-children select.select2, .select-children select.select2",groupIndex:1,optionsDay:function(){for(var t="<option><\/option>",n=1;n<=31;n++)t+='<option value="'+n+'">'+n+"<\/option>\n";return t},optionsMonth:function(){for(var u,i=["January","February","March","April","May","June","July","August","September","October","November","December"],t="<option><\/option>",r=(new Date).getFullYear(),n=1;n<=12;n++)u=new Date(r,n,1),t+='<option value="'+(n-1)+'">'+i[n-1]+"<\/option>\n";return t},optionsYear:function(){for(var t="<option><\/option>",i=(new Date).getFullYear(),n=i-18;n<=i;n++)t+='<option value="'+n+'">'+n+"<\/option>\n";return t},init:function(){$J(".child-select-wrap").length!=0&&(this.compileTemplates(),this.setEvents(),this.isAccomodationDetail=$J(".accommodation-details").length>0?!0:!1)},compileTemplates:function(){this.compileChildrenFormTemplate();this.compileExistingChildrenTemplate()},_templateChildrenFormCompiled:{},compileChildrenFormTemplate:function(){this._templateChildrenFormCompiled=Hogan.compile('<div class="row-fluid child-fields" data-index={{num}}><div class="span6 wrap-child-name"><span class="label-spans">Name of Child {{num}}<\/span><div class="row-fluid extend-width"><div class="control-group name-div"><label class="control-label invsbl-accessible" for="child_name_id{{num}}">First Name<\/label><div class="controls"><input type="text" class="child-name" id="child_name_id{{num}}" placeholder="ENTER FIRST NAME"><\/div><\/div><div class="control-group name-first-div"><label class="control-label invsbl-accessible" for="child_last_name_id{{num}}">Last Name<\/label><div class="controls"><input type="text" class="child-name" id="child_last_name_id{{num}}" placeholder="ENTER LAST NAME"><\/div><\/div><\/div><\/div><div class="span6"><span class="label-spans">Date of Birth<\/span><div class="row-fluid extend-width"><div class="control-group day-div"><label class="control-label invsbl-accessible" for="select_date_id{{num}}">Select Day<\/label><div class="controls"><select id="select_date_id{{num}}" class="select2" data-placeholder="Day">{{{optSelDay}}}<\/select><\/div><\/div><div class="control-group month-div"><label class="control-label invsbl-accessible" for="select_month_id{{num}}">Select Month<\/label><div class="controls"><select id="select_month_id{{num}}" class="select2" data-placeholder="Month">{{{optSelMonth}}}<\/select><\/div><\/div><div class="control-group year-div"><label class="control-label invsbl-accessible" for="select_year_id{{num}}">Select Year<\/label><div class="controls"><select id="select_year_id{{num}}" class="select2" data-placeholder="Year">{{{optSelYear}}}<\/select><\/div><\/div><\/div><\/div><\/div>')},_templateExistingChildrenCompiled:{},compileExistingChildrenTemplate:function(){this._templateExistingChildrenCompiled=Hogan.compile('<div class="span3" ><div class="control-group"><div class="controls"><input type="checkbox" id="cb_child_name_id{{index}}" data-birthday="{{birthday}}" data-index="{{index}}" {{#isChecked}}{{checked}}{{/isChecked}} {{disabled}} /><label class="child-name" for="cb_child_name_id{{index}}">{{name}} {{lastname}}<\/label><span class="child-birthday">{{birthday}}<\/span><div class="popover-box bottom {{warningVisible}}"><div class="arrow"><\/div><div class="popover-box-content">{{warningMessage}}<\/div><span class="icon-info popinfo" data-toggle="popover" data-original-title="" data-content="{{warningDescription}}">Info<\/span><\/div><\/div><\/div><\/div>')},registerChildSelect:function(){var f,e,s,o;VYG.childSelect.cleanUpRoomAndSummaryIfAny();VYG.childSelect._productId=VYG.childSelect.isAccomodationDetail?$J(this).attr("data-product-ids"):$J(this).attr("data-product-id");VYG.childSelect._productId=VYG.childSelect._productId||$J(this).attr("data-product-id");var n={},u={},t={},i={},r={};VYG.childSelect.validationIsValid=!0;VYG.childSelect._productId!=undefined?VYG.childSelect.isAccomodationDetail?(n=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-wrap'),u=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-rows'),t=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .select-children select.select2'),i=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-form'),r=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-existing')):(n=$J("#productid-"+VYG.childSelect._productId+" .child-select-wrap"),u=$J("#productid-"+VYG.childSelect._productId+" .child-rows"),t=$J("#productid-"+VYG.childSelect._productId+" .select-children select.select2"),i=$J("#productid-"+VYG.childSelect._productId+" .child-select-form"),r=$J("#productid-"+VYG.childSelect._productId+" .child-select-existing")):(n=$J(".child-select-wrap"),u=$J(".child-rows"),t=$J(".select-children select.select2"),i=$J(".child-select-form"),r=$J(".child-select-existing"));f=0;e=!0;u.html("");$J(VYG.childSelect.selectChildEl).each(function(){$J(this).val()!=0&&(e=!1)});VYG.childSelect.setMinMaxAge();$J(this).val()=="0"&&e?(n.slideUp("fast").addClass("hide"),VYG.childSelect.enableCheckAvailBtn()):(s=t.length,s>1?(t.each(function(){f+=parseInt($J(this).val())}),VYG.childSelect.num=f):VYG.childSelect.num=parseInt($J(this).val()),VYG.childSelect.tplSub1=VYG.childSelect.optionsDay(),VYG.childSelect.tplSub2=VYG.childSelect.optionsMonth(),VYG.childSelect.tplSub3=VYG.childSelect.optionsYear(),n.slideDown().removeClass("hide"),o=JSON.parse($J.cookie("children-data")||null),$J.cookie("children-data")&&o?(i.addClass("hide"),r.removeClass("hide"),VYG.childSelect.data=o,VYG.childSelect.populateExisting()):(r.addClass("hide"),i.removeClass("hide"),VYG.childSelect.populate(VYG.childSelect.num)));VYG.childSelect.enableDisableCheckAvailBtn.call(this)},cleanUpRoomAndSummaryIfAny:function(){var t=$J(".room-result"),n,i;t.length>0&&t.each(function(){$J(this).html("")});n=$J(".summary");n.length>0&&n.each(function(){$J(this).slideUp("fast")});i=$J(".find-avail-error, .find-tour-error");i.hide()},setEvents:function(){$J(".child-select-form .save-children").on("click",VYG.childSelect.saveChildren);$J(".child-select-existing .save-children").on("click",VYG.childSelect.updateChildren);$J(".child-select-wrap .btn-add-plus").on("click",VYG.childSelect.addToExisting);$J("body").off("change",VYG.childSelect.selectChildEl).on("change",VYG.childSelect.selectChildEl,function(){VYG.childSelect.groupIndex=parseInt($J(this).data("group-index"))||1;VYG.childSelect.registerChildSelect.call(this)})},enableDisableCheckAvailBtn:function(){var r=$J(".child-select-wrap").is(":visible"),u=$J(".itinerary-details").length>0?".find-avail-upper":$J(".experience-details").length>0?".find-tour-wrapper":".find-avail-wrapper",f=$J(this).closest(u).find(".child-select-wrap"),e=f.parent(),t=$J(".flight-container").length>0?$J('input[type="submit"]#finder_find'):e.find("button.check-avail"),i=$J("button.check-avail"),n=!0;$J(VYG.childSelect.selectChildEl).each(function(){$J(this).val()!=0&&(n=!1)});(!r||n)&&n?(i.removeAttr("disabled"),i.removeClass("disabled")):(t.attr("disabled","disabled"),t.addClass("disabled"))},enableCheckAvailBtn:function(){var n=$J('button.check-avail, input[type="submit"]#finder_find');n.removeAttr("disabled");n.removeClass("disabled")},setMinMaxAge:function(){var n;if($J(".itinerary-details").length>0)this.productsMinAge=parseInt($J("#suggested_itinerary_id").data("child-min-age"),10),this.productsMaxAge=parseInt($J("#suggested_itinerary_id").data("child-max-age"),10);else if($J(".experience-details").length>0){var t=$J("[id*=productid-]"),u=t.length,i=0,r=99;for(n=0;n<u;n++)i=Math.max(i,parseInt($J(t[n]).data("product-child-min-age"),10)),r=Math.min(r,parseInt($J(t[n]).data("product-child-max-age"),10));this.productsMinAge=i;this.productsMaxAge=r}else if($J(".accommodation-details").length>0){var t=$J(".accordion-body[id*=accordion_acc_detail_collapsible_]"),u=t.length,i=0,r=99;for(n=0;n<u;n++)i=Math.max(i,parseInt($J(t[n]).data("product-child-min-age"),10)),r=Math.min(r,parseInt($J(t[n]).data("product-child-max-age"),10));this.productsMinAge=i;this.productsMaxAge=r}else this.productsMinAge=0,this.productsMaxAge=150},populateExisting:function(){var n,i,t,r,u,f;for(this.setMinMaxAge(),n=0;n<VYG.childSelect.data.length;n++)VYG.childSelect.data[n].warningVisible=!1,VYG.childSelect.data[n].disabled="",i=VYG.childSelect.getChildAge(VYG.childSelect.data[n].birthday),i<this.productsMinAge&&$J("#find_flight_form").length==0&&(VYG.childSelect.data[n].warningMessage="Too young",VYG.childSelect.data[n].warningDescription="Some items will not available",VYG.childSelect.data[n].warningVisible="error",VYG.childSelect.data[n].checked=!1,VYG.childSelect.data[n].disabled="disabled"),i>this.productsMaxAge&&$J("#find_flight_form").length==0&&(VYG.childSelect.data[n].warningMessage="Classified as adult",VYG.childSelect.data[n].warningDescription="Adult price will be applied",VYG.childSelect.data[n].warningVisible="error",VYG.childSelect.data[n].checked=!1,VYG.childSelect.data[n].disabled="disabled",VYG.childSelect.childAsAdultCount++);if(t={},t=VYG.childSelect._productId!=undefined?VYG.childSelect.isAccomodationDetail?$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-existing > .existing-children'):$J("#productid-"+VYG.childSelect._productId+" .child-select-existing > .existing-children"):$J(".child-select-existing > .existing-children"),r="",t&&(t.html(""),$J.each(VYG.childSelect.data,function(){r+=VYG.childSelect._templateExistingChildrenCompiled.render(this)}),t.append(r)),VYG.childSelect.num>VYG.childSelect.data.length&&VYG.childSelect.validationIsValid)for(u=0,f=VYG.childSelect.num-VYG.childSelect.data.length;u<f;u++)VYG.childSelect.addToExisting();VYG.childSelect.styleNewAddedEls()},addToExisting:function(){var n="",t=0;VYG.childSelect._productId!=undefined?VYG.childSelect.isAccomodationDetail?(n='.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-existing > .child-rows',t=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-existing > .child-rows > .row-fluid').last().attr("data-index")||VYG.childSelect.data.length):(n="#productid-"+VYG.childSelect._productId+" .child-select-existing > .child-rows",t=$J("#productid-"+VYG.childSelect._productId+" .child-select-existing > .child-rows > .row-fluid").last().attr("data-index")||VYG.childSelect.data.length):(n=".child-select-existing > .child-rows",t=$J(".child-select-existing > .child-rows > .row-fluid").last().attr("data-index")||VYG.childSelect.data.length);var i=+parseInt(t)+1,r={num:i,optSelDay:VYG.childSelect.tplSub1,optSelMonth:VYG.childSelect.tplSub2,optSelYear:VYG.childSelect.tplSub3},u=VYG.childSelect._templateChildrenFormCompiled.render(r);$J(n).append(u);VYG.childSelect.styleNewAddedEls()},styleNewAddedEls:function(){var t={},n={};VYG.childSelect._productId!=undefined?VYG.childSelect.isAccomodationDetail?(t=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .existing-children input[type=checkbox]'),n=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-fields select.select2')):(t=$J("#productid-"+VYG.childSelect._productId+" .existing-children input[type=checkbox]"),n=$J("#productid-"+VYG.childSelect._productId+" .child-fields select.select2")):(t=$J(".existing-children input[type=checkbox]"),n=$J(".child-fields select.select2"));t.prettyCheckable();n.select2({minimumResultsForSearch:1});n.on("select2-opening",function(){$J(".select2-results").css({"font-size":"12px"})}).on("select2-close",function(){$J(".select2-results").css({"font-size":""})});$J(".prettycheckbox label.child-name:empty").remove();$J(".prettycheckbox + label.child-name").each(function(){var n=$J(this).prev(".prettycheckbox");$J(this).appendTo(n)})},populate:function(n){for(var i={},r="",u,i=VYG.childSelect._productId!=undefined?VYG.childSelect.isAccomodationDetail?$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-wrap .child-select-form .child-rows'):$J("#productid-"+VYG.childSelect._productId+" .child-select-wrap .child-select-form .child-rows"):$J(".child-select-wrap .child-select-form .child-rows"),t=0;t<n;t++)u={num:t+1,optSelDay:VYG.childSelect.tplSub1,optSelMonth:VYG.childSelect.tplSub2,optSelYear:VYG.childSelect.tplSub3},r+=VYG.childSelect._templateChildrenFormCompiled.render(u);$J(r).appendTo(i);VYG.childSelect.styleNewAddedEls()},getChildAges:function(){return _.pluck(_.where(VYG.childSelect.data,{checked:"checked"}),"birthday").map(function(n){return VYG.childSelect.getChildAge(n)}).valueOf().join(",")},getChildData:function(){return _.where(VYG.childSelect.data,{checked:"checked"}).map(function(n){return{FirstName:n.name,LastName:n.lastname,BirthDate:moment(n.birthday,"MMMM DD, YYYY").format(),GroupIndex:n.groupIndex}})},validationIsValid:!0,validationMessage:"",validationMessages:[],saveChildren:function(){var r={},t=!1,n="",u=[],l=!0,a=!0,i,f,v,c;this.validationIsValid=!0;var e=$J(".child-select-wrap"),o=$J(".child-fields"),s=$J(".child-select-form"),h=$J(".child-select-existing");if(VYG.childSelect._productId!=undefined&&(VYG.childSelect.isAccomodationDetail?(o=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-fields'),e=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-wrap'),s=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-form'),h=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-existing')):(o=$J("#productid-"+VYG.childSelect._productId+" .child-fields"),e=$J("#productid-"+VYG.childSelect._productId+" .child-select-wrap"),s=$J("#productid-"+VYG.childSelect._productId+" .child-select-form"),h=$J("#productid-"+VYG.childSelect._productId+" .child-select-existing"))),i=!0,$J("input[id^=child_name_id]").each(function(){var n=$J(this).val();n||(i=!1)}),$J("input[id^=child_last_name_id]").each(function(){var n=$J(this).val();n||(i=!1)}),$J("select[id^=select_date_id]").each(function(){var n=$J(this).val();n||(i=!1)}),$J("select[id^=select_month_id]").each(function(){var n=$J(this).val();n||(i=!1)}),$J("select[id^=select_year_id]").each(function(){var n=$J(this).val();n||(i=!1)}),i)VYG.childSelect.validationIsValid=!0;else{VYG.childSelect.validationIsValid=!1;n="Please enter details for all the children attending";VYG.childSelect.validationMessage=n;VYG.childSelect.showValidationMessage(n);t=!0;return}o.each(function(){var i=parseInt($J(this).attr("data-index")),e=$J("#child_name_id"+i).val(),y=$J("#child_last_name_id"+i).val(),o=$J("#select_date_id"+i).val(),s=$J("#select_month_id"+i).val(),h=$J("#select_year_id"+i).val(),c,f,v;if(e||o||s||h){if(!e||!o||!s||!h){VYG.childSelect.validationIsValid=!1;n==""&&i==1&&(n="Name and Date of Birth are required for each child",VYG.childSelect.validationMessage=n);t=!0;return}}else{VYG.childSelect.validationIsValid=!1;n="Please enter details for all the children attending";VYG.childSelect.validationMessage=n;t=!0;return}c=moment({y:h,M:s,d:o});f=VYG.childSelect.getChildAge(c);VYG.childSelect.minAge>f&&(VYG.childSelect.minAge=f);r={index:i,name:e,lastname:y,birthday:c.format("MMMM D, YYYY"),checked:"checked",isChecked:!0,warningVisible:"",warningMessage:"",warningDescription:"",groupIndex:VYG.childSelect.groupIndex};VYG.childSelect.productsMinAge<=99&&f<VYG.childSelect.productsMinAge?(VYG.childSelect.validationIsValid==!0&&(l=!1),n="There is a minimum age requirement for the tours.<br>"+r.name+" is too young.",VYG.childSelect.validationMessage=n,u[u.length]=n,t=!0):VYG.childSelect.productsMinAge<=99&&f>VYG.childSelect.productsMaxAge&&(VYG.childSelect.validationIsValid==!0&&(a=!1),n=r.name+" is classified as adult.",VYG.childSelect.validationMessage=n,u[u.length]=n,t=!0);JSLINQ(VYG.childSelect.data).Any(function(n){return n.index==r.index})||(VYG.childSelect.data.push(r),v=JSON.stringify(VYG.childSelect.data),$J.cookie("children-data",v,{expires:30,path:"/"}))});VYG.childSelect.validationIsValid&&(l===!1||a===!1)?(f=_.size(_.where(VYG.childSelect.data,{checked:"checked"})),$J(VYG.childSelect.childSelectEl()).select2("val",f).trigger("change"),VYG.childSelect.showValidationMessage(u)):VYG.childSelect.validationIsValid?(VYG.childSelect.cleanValidationMesage(),VYG.childSelect.data.length&&(f=_.size(_.where(VYG.childSelect.data,{checked:"checked"})),$J(VYG.childSelect.childSelectEl()).select2("val",f)),s.addClass("hide"),h.removeClass("hide"),v=JSON.parse($J.cookie("children-data")||null),VYG.childSelect.data=v,VYG.childSelect.populateExisting(),t=$J("input:checked[id^=cb_child_name_id]").length!=VYG.childSelect.num):VYG.childSelect.showValidationMessage(n);VYG.childSelect._productId!=undefined&&VYG.childSelect.isAccomodationDetail&&(c=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"]').data("room-type-shortid"),VYG.childSelect.childData[c]=VYG.childSelect.getChildData(),VYG.childSelect.childAges[c]=VYG.childSelect.getChildAges());t!=!0&&(VYG.childSelect.cleanValidationMesage(),e.slideUp("fast").addClass("hide"),VYG.childSelect.enableCheckAvailBtn())},updateChildren:function(){var i={},n="",u=[],t=!1,r,c,v,h;VYG.childSelect.validationIsValid=!0;var f=$J("input:checked[id^=cb_child_name_id]"),e=$J(".child-fields"),o=$J(".child-select-wrap"),y=$J(".find-avail-error, .find-tour-error");if(VYG.childSelect._productId!=undefined&&(VYG.childSelect.isAccomodationDetail?(f=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] input:checked[id^=cb_child_name_id]'),e=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-fields'),o=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-wrap')):(f=$J("#productid-"+VYG.childSelect._productId+" input:checked[id^=cb_child_name_id]"),e=$J("#productid-"+VYG.childSelect._productId+" .child-fields"),o=$J("#productid-"+VYG.childSelect._productId+" .child-select-wrap"))),r=!0,$J("input[id^=child_name_id]").each(function(){var n=$J(this).val();n||(r=!1)}),$J("input[id^=child_last_name_id]").each(function(){var n=$J(this).val();n||(r=!1)}),$J("select[id^=select_date_id]").each(function(){var n=$J(this).val();n||(r=!1)}),$J("select[id^=select_month_id]").each(function(){var n=$J(this).val();n||(r=!1)}),$J("select[id^=select_year_id]").each(function(){var n=$J(this).val();n||(r=!1)}),r)VYG.childSelect.validationIsValid=!0;else{VYG.childSelect.validationIsValid=!1;n="Please enter details for all the children attending";VYG.childSelect.validationMessage=n;VYG.childSelect.showValidationMessage(n);t=!0;return}$J(VYG.childSelect.data).each(function(){this.checked="";this.isChecked=!1});f.each(function(){var i=parseInt($J(this).attr("data-index")),t=VYG.childSelect.getChildAge($J(this).attr("data-birthday")),n=VYG.childSelect.data[i-1];VYG.childSelect.minAge>t&&(VYG.childSelect.minAge=t);n.checked="checked";n.isChecked=!0;n.groupIndex=VYG.childSelect.groupIndex});e.each(function(){var r=parseInt($J(this).attr("data-index")),e=$J("#child_name_id"+r).val(),v=$J("#child_last_name_id"+r).val(),o=$J("#select_date_id"+r).val(),s=$J("#select_month_id"+r).val(),h=$J("#select_year_id"+r).val(),l=!1,c,f,a;if(e||o||s||h){if(!e||!o||!s||!h){VYG.childSelect.validationIsValid=!1;n="Name and Date of Birth are required for each child";t=!0;return}}else{VYG.childSelect.validationIsValid=!1;n="Please enter details for all the children attending";t=!0;return}c=moment({y:h,M:s,d:o});f=VYG.childSelect.getChildAge(c);VYG.childSelect.minAge>f&&(VYG.childSelect.minAge=f);i={index:r,name:e,lastname:v,birthday:c.format("MMMM D, YYYY"),checked:"",disabled:"",warningVisible:"",warningMessage:"",warningDescription:"",groupIndex:VYG.childSelect.groupIndex};i.checked=l?"checked":"";i.isChecked=l?!0:!1;VYG.childSelect.productsMinAge<=99&&f<VYG.childSelect.productsMinAge?(VYG.childSelect.validationIsValid=!1,n="There is a minimum age requirement for the tours.<br>"+i.name+" is too young.",u[u.length]=n,t=!0):VYG.childSelect.productsMinAge<=99&&f>VYG.childSelect.productsMaxAge&&(VYG.childSelect.validationIsValid=!1,n=i.name+" is classified as adult.",u[u.length]=n,t=!0);JSLINQ(VYG.childSelect.data).Any(function(n){return n.index==i.index})||(VYG.childSelect.data.push(i),a=JSON.stringify(VYG.childSelect.data),$J.cookie("children-data",a,{expires:30,path:"/"}))});VYG.childSelect.data&&f.length!=VYG.childSelect.num&&$J("input[id^=child_name_id]").length==0&&(VYG.childSelect.validationIsValid=!1,n="Please enter details for all the children, or change the number of Children",VYG.childSelect.validationMessage=n,t=!0);VYG.childSelect.validationIsValid?(VYG.childSelect.cleanValidationMesage(),VYG.childSelect.data.length&&(c=JSON.stringify(VYG.childSelect.data),$J.cookie("children-data",c,{expires:30,path:"/"}))):u.length>0?VYG.childSelect.showValidationMessage(u):VYG.childSelect.showValidationMessage(n);VYG.childSelect.populateExisting();var l=0,a=$J(".find-tour-children select.select2, .find-avail-children select.select2, .acc-form-check-availability .select-children select.select2, .select-children select.select2").val(),s=$J(".select-children select.select2");VYG.childSelect._productId!=undefined&&VYG.childSelect.isAccomodationDetail&&(a=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"]').find(".select-children select.select2, .select-children select.select2").val(),s=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .select-children select.select2'));$J(s).length>1&&($J(s).each(function(){l+=parseInt($J(this).val())}),a=l);v=$J(".existing-children input[type='checkbox']:checked").length;VYG.childSelect._productId!=undefined&&(v=VYG.childSelect.isAccomodationDetail?$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .existing-children input[type="checkbox"]:checked').length:$J("#productid-"+VYG.childSelect._productId+" .existing-children input[type='checkbox']:checked").length);VYG.childSelect.validationIsValid&&(VYG.childSelect._productId!=undefined&&VYG.childSelect.isAccomodationDetail?(h=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"]').data("room-type-shortid"),VYG.childSelect.childData[h]=VYG.childSelect.getChildData(),VYG.childSelect.childAges[h]=VYG.childSelect.getChildAges(),t=$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"]').find("input[id^=child_name_id]").length!=0||$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"]').find("input:checked[id^=cb_child_name_id]").length!=VYG.childSelect.num):t=$J("input[id^=child_name_id]").length!=0||$J("input:checked[id^=cb_child_name_id]").length!=VYG.childSelect.num);$J(".child-rows").children().remove();t!=!0&&(o.slideUp("fast").addClass("hide"),y.slideUp("fast"),VYG.childSelect.enableCheckAvailBtn())},childSelectEl:function(){return el=$J(".itinerary-details").length>0?"#select_child_qty_id":$J(".experience-details").length>0||$J(".accommodation-details").length>0?"#select-child-qty":".select2.select-child-qty"},closePanel:function(n){var t={};t=VYG.childSelect._productId!=undefined?VYG.childSelect.isAccomodationDetail?n?$J('.accordion-body[data-product-ids="'+n+'"] .child-select-wrap'):$J('.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .child-select-wrap'):$J("#productid-"+VYG.childSelect._productId+" .child-select-wrap"):$J(".child-select-wrap");t.slideUp("fast").addClass("hide");VYG.childSelect.skipMyErrorMessage=!1},skipMyErrorMessage:!1,showValidationMessage:function(n){var t,u,i,r;if(!VYG.childSelect.skipMyErrorMessage){if(VYG.childSelect._productId!=undefined?t=VYG.childSelect.isAccomodationDetail?'.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .find-tour-error':"#productid-"+currentProductId+" .find-tour-error":$J(".experience-details").length>0?t=".find-tour-error":$J("#find_flight_form").length>0?t=".error-notification-row":(t=".find-avail-error",u=$J(t).parent(".find-avail-wrapper"),u.hasClass("hide")&&u.css("display","block")),$J(t+" h4").text("Please Correct The Following Error"),i="<ul>",_.isArray(n))for(r=0;r<n.length;r++)i+="<li>"+n[r]+"<\/li>";else i+="<li>"+n+"<\/li>";i+="<\/ul>";$J(t+" .error-items").empty().append(i);$J(t).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn();setTimeout(function(){VYG.scrollToEl(t)},200)}VYG.childSelect.validationIsValid=!1},cleanValidationMesage:function(){var n,t;VYG.childSelect._productId!=undefined?n=VYG.childSelect.isAccomodationDetail?'.accordion-body[data-product-ids="'+VYG.childSelect._productId+'"] .find-tour-error':"#productid-"+currentProductId+" .find-tour-error":$J(".experience-details").length>0?n=".find-tour-error":$J("#find_flight_form").length>0?n=".error-notification-row":(n=".find-avail-error",t=$J(n).parent(".find-avail-wrapper"),t.hasClass("hide")||t.addClass("hide"));$J(n).slideUp("fast");VYG.childSelect.validationIsValid=!0;VYG.childSelect.skipMyErrorMessage=!1},getChildAge:function(n){var t=$J(".datepicker").val();if(t==""){var i=new Date,u=$J("#itinerary_start_date").val(),f=new Date(i.getFullYear(),i.getMonth(),i.getDate()+3,0,0,0,0),t=u?new Date(u):VYG.vars.getItineraryStartDate()?VYG.vars.getItineraryStartDate():VYG.vars.getItineraryStartDateCookie()?VYG.vars.getItineraryStartDateCookie():f,r=VYG.vars.getItineraryPlanDate(),s=r.isFixedDate;r.planDate&&(t=new Date(r.planDate));t=moment(t).format("DD/MM/YYYY")}var e=_.isString(n)?moment(n,"MMMM DD, YYYY"):moment(n),o=moment(t,"DD/MM/YYYY");return VYG.utils.calculateAge(e,o)}};$J(document).ready(function(){VYG.childSelect.init()})