function hideFormFieldInVisibilityTrigger(n){$(n).hide();$(n).is("[required]")&&($(n).attr("data-required","true"),$(n).removeAttr("required"))}var $datePickers,dpStartId,formnametocompare,customDataAttirbutes,arrayOfcustomAttributes;$(function(){$("form textarea[maxlength]").on("keyup change",function(){var t=$(this),n=parseInt(t.attr("maxlength")),i=$(this).val().replace(/\r(?!\n)|\n(?!\r)/g,"\r\n"),r=i.length;isNaN(n)||(r>n?this.value=i.substring(0,n):$('[data-id="'+t.attr("name")+'"]').text(n-r+" / "+n))})});$datePickers=$(".date-picker");dpStartId=$datePickers.eq(0).attr("id");dpEndId=$datePickers.eq(1).attr("id");formnametocompare="Membership_Cancellation_Request";$(function(){var i=window.BGV,n,t;typeof dpStartId!="undefined"&&typeof dpEndId!="undefined"?(n=$("#"+dpStartId),t=$("#"+dpEndId),n.datetimepicker({timepicker:!0,format:i.formatter.dateTime,onShow:function(){this.setOptions({maxDate:t.val()?t.val():!1})},onChangeDateTime:function(){n.val()&&n.parent().removeClass("error")}}),t.datetimepicker({timepicker:!0,format:i.formatter.dateTime,onShow:function(){this.setOptions({minDate:n.val()?n.val():!1})},onChangeDateTime:function(){t.val()&&t.parent().removeClass("error")}})):$datePickers.datetimepicker({format:i.formatter.date,timepicker:!1})}),function(){function t(){var t=$(".chosen-select"),n=t.filter("[multiple]");n.each(function(){var n=$(this),t=n.children().first().text().trim();n.attr("data-placeholder",t);n.children().first().remove()});t.chosen().not(n).on("change",function(){$this=$(this);$this.valid()&&$this.parent().closest(".error").removeClass("error")});n.change(function(){var n=$(this),t=$(".search-choice"),i=n.attr("id"),r=$("."+i);$("#"+r[0].id).val(n.val().join("|"));$(".chosen-search-input default valid").prop("required",t.length<1?!0:!1);n.valid()})}var n=!1;$(document).ready(function(){window.innerWidth>=768&&(t(),n=!0)});$(window).resize(function(){n&&window.innerWidth<768?($(".chosen-select").chosen("destroy").css({position:"static",opacity:1}),n=!1):!n&&window.innerWidth>=768&&(t(),n=!0)})}();var customDataAttirbutes={dataComparisionValue:"data-comparision-value",dataVisibilityControl:"data-visibility-control",dataFieldToHide:"data-field-hide"},arrayOfcustomAttributes=[],componentForm={StreetAddress:"StreetAddress",Suburb:"Suburb",PostCode:"PostCode",State:"State"},addressnotfound="I can’t find my address";$(function(){var n,t=$("*[data-field-hide]");$(t).each(function(){customDataAttirbutes={};customDataAttirbutes.dataComparisionValue=$(this).map(function(){return $(this).attr("data-comparision-value")}).get();customDataAttirbutes.dataVisibilityControl=$(this).map(function(){return $(this).attr("data-visibility-control")}).get();customDataAttirbutes.dataFieldToHide=$(this).map(function(){return $(this).attr("data-field-hide")}).get();arrayOfcustomAttributes.push(customDataAttirbutes)});$("#autocomplete").autocomplete({source:function(t,i){$.ajax({url:"/api/Autocomplete",data:"{ 'search': '"+t.term+"'}",dataType:"json",type:"POST",contentType:"application/json; charset=utf-8",success:function(t){var r=t;r.push({label:n,value:n});r.push({label:addressnotfound,value:addressnotfound});i(r)},error:function(){},failure:function(){}})},select:function(n,t){if(n.preventDefault(),$(n.target).val(t.item.label),$("#hfautocomplete").val(t.item.label),t.item.value===addressnotfound){$("#googleplacesearch").hide();$("#autocomplete").removeAttr("required");$("#autocomplete").val("");for(var i in componentForm)$("#"+i).prop("required",!0),$("[name ="+i+"]").show(),$("#"+i).val("")}else $.ajax({url:"/api/AutoComplete/Detail",data:JSON.stringify({id:t.item.value}),dataType:"json",type:"POST",contentType:"application/json; charset=utf-8",success:function(n){var i=$.extend(n,t.item.components);$("#"+componentForm.PostCode).val(i.postcode);$("#"+componentForm.StreetAddress).val(i.streetAddress);$("#"+componentForm.Suburb).val(i.suburb);$("#"+componentForm.State).val(i.state)},error:function(){},failure:function(){}})},focus:function(n,t){n.preventDefault();$(n.target).val(t.item.label)},minLength:4,change:function(n,t){$(this).val(t.item?t.item.label:"")}}).attr("autocomplete","new-password")});$("#btnSubmit").click(function(n){var t="";$("#"+n.currentTarget.form.id).valid()&&$("#autocomplete").val()===""&&(t=$("#"+componentForm.StreetAddress).val()+", "+$("#"+componentForm.Suburb).val()+" "+$("#"+componentForm.PostCode).val()+" "+$("#"+componentForm.State).val(),$("#autocomplete").val(""),$("#autocomplete").val(t))});$(function(){function p(n){return n?n.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","):null}function f(n){return n.trim().replace(/\s\S/g,"-")}function e(){var n=s.childNodes.length,t="No files uploaded";n&&(t=n+" "+(n>1?"files":"file")+" uploaded");a.innerHTML=t}var o=document.querySelector(".btn--upload");if(o){var s=document.querySelector(".upload__list"),i=document.querySelector(".upload__error"),a=document.querySelector(".upload__count"),r=$("#filesUpload").removeAttr("required"),v=(r.attr("data-extensions")||"").split("|"),h=parseInt(r.attr("data-max-count"))||3,c=parseInt(r.attr("data-max-size")),l=$("#FileUpload").attr("data-msg-required",r.attr("data-msg-required")).val(""),y=(r.attr("data-extensions")||"").split("|").join(", "),u={duplicate:"You cannot upload the same file twice. Please choose a different file.",extensions:"Please ensure you only upload the allowed file types ("+y+"). Please try again.",maxCount:"You have exceeded the maximum number of files allowed ("+h+").",maxSize:"The file exceeded the max file size of "+p(c)+"KB. Please try again."},n=[],t=[];new ss.SimpleUpload({button:o,url:"/MultiFileUpload/Upload",responseType:"json",name:"upload",multiple:!0,allowedExtensions:v,maxSize:c,hoverClass:"hover",focusClass:"focus",disabledClass:"disabled",onChange:function(r){return n.length+t.length>=h?(i.innerHTML=u.maxCount,!1):n.indexOf(r)!==-1||t.filter(function(n){return n.indexOf(r)!==-1}).length?(i.innerHTML=u.duplicate,!1):void 0},onSubmit:function(t){n.push(t);var i=document.createElement("li"),u=document.createElement("span"),e=document.createElement("button"),r=document.createElement("div"),o=document.createElement("div");i.id=f(t);i.className="upload__file";u.className="upload__percent";e.className="upload__cancel ui-button ui-corner-all ui-widget";r.className="upload__progress";o.className="upload__bar upload__bar--success";i.innerHTML='<span class="upload__name">'+t+"<\/span>";r.appendChild(o);i.appendChild(u);i.appendChild(r);i.appendChild(e);s.appendChild(i);this.setAbortBtn(e);this.setPctBox(u);this.setProgressBar(o);this.setProgressContainer(r)},onProgress:function(){},onAbort:function(t){var i=n.indexOf(t);i>-1&&n.splice(i,1);document.getElementById(f(t)).outerHTML="";e()},onDone:function(t){var r=n.indexOf(t),u,i;r>-1&&n.splice(r,1);e();u=document.getElementById(f(t));i=u.querySelector(".upload__percent");i.innerHTML="100%";i.classList.add("upload__percent--complete")},onComplete:function(n,r){if(!r)return alert(n+"upload failed"),!1;$.each(r.files,function(n,i){t.push(i.kenticoUploadName);l.val(t)});e();i.innerHTML="";var u=document.getElementById(f(n)),s=u.querySelector(".upload__percent"),o=u.querySelector(".upload__cancel");o.classList.add("upload__cancel--delete");o.addEventListener("click",function(n){n.preventDefault();n.stopPropagation();$.each(r.files,function(n,i){var n=t.indexOf(i.kenticoUploadName);n>-1&&t.splice(n,1)});l.val(t);u.outerHTML="";i.innerHTML="";e()})},onExtError:function(){i.innerHTML=u.extensions},onSizeError:function(){i.innerHTML=u.maxSize}})}});customDataAttirbutes={dataComparisionValue:"data-comparision-value",dataVisibilityControl:"data-visibility-control",dataFieldToHide:"data-field-hide"};arrayOfcustomAttributes=[];$(function(){var n=$("*[data-field-hide]");$(n).each(function(){customDataAttirbutes={};customDataAttirbutes.dataComparisionValue=$(this).map(function(){return $(this).attr("data-comparision-value")}).get();customDataAttirbutes.dataVisibilityControl=$(this).map(function(){return $(this).attr("data-visibility-control")}).get();customDataAttirbutes.dataFieldToHide=$(this).map(function(){return $(this).attr("data-field-hide")}).get();arrayOfcustomAttributes.push(customDataAttirbutes)});$(arrayOfcustomAttributes).each(function(n,t){if(t!==undefined){var i=t.dataVisibilityControl[0],r=t.dataFieldToHide[0],u=t.dataComparisionValue[0],f=$("[name="+r+"]");$("input[name="+i+"]:radio")?r&&u&&i!==null&&hideFormFieldInVisibilityTrigger(f):r&&u&&i!==null&&hideFormFieldInVisibilityTrigger(f)}})});$("input[type=radio]").change(function(n){var t=n.target.name,i=n.target.id;$(arrayOfcustomAttributes).each(function(n,r){var e=r.dataVisibilityControl[0],o=r.dataFieldToHide[0],f=r.dataComparisionValue[0],u;f=f.replace(/"/g,"");$("input[name="+e+"]:radio")&&t===e&&(u=$("[name="+o+"]"),i===f?($(u).show(),$(u).is("[data-required]")&&$(u).prop("required",!0)):hideFormFieldInVisibilityTrigger(u))})});$("input[type=checkbox]").change(function(n){var t=n.target.name,i=$(n.target).is(":checked")?"true":"false";$(arrayOfcustomAttributes).each(function(n,r){var e=r.dataVisibilityControl[0],o=r.dataFieldToHide[0],f=r.dataComparisionValue[0],u;f=f.replace(/"/g,"");e!==null&&t===e&&(u=$("[name="+o+"]"),i===f?($(u).show(),$(u).is("[data-required]")&&$(u).prop("required",!0)):hideFormFieldInVisibilityTrigger(u))})});$("select").change(function(n){var t=n.target.name,i=n.target.value;$(arrayOfcustomAttributes).each(function(n,r){var e=r.dataVisibilityControl[0],o=r.dataFieldToHide[0],f=r.dataComparisionValue[0],u;f=f.replace(/"/g,"");e!==null&&t===e&&(u=$("[name="+o+"]"),i===f?($(u).show(),$(u).is("[data-required]")&&$(u).prop("required",!0)):hideFormFieldInVisibilityTrigger(u))})});var customDataAttirbutesName={dataNameValue:"data-validate-name",dataNameMessage:"data-validate-name-msg"},customDataAttirbutesAge={dataAgeValue:"data-validate-age",dataAgeMessage:"data-validate-age-msg"},customDataAttirbutesPostCode={dataPostCodeValue:"data-validate-postcode",dataPostCodeMessage:"data-validate-postcode-msg"},customDataAttirbutesPhone={dataPhoneNumberValue:"data-validate-phonenumber",dataPhoneNumberMessage:"data-validate-phonenumber-msg"},customDataAttirbutesEmail={dataEmailValue:"data-validate-email",dataEmailMessage:"data-validate-email-msg"},customDataAttirbutesNumberOfPeople={dataNumberOfPeopleExpectedValue:"data-validate-people-count",dataNumberOfPeopleExpectedMessage:"data-validate-people-count-msg"},arrayOfcustomDataAttirbutesName=[],arrayOfcustomDataAttirbutesAge=[],arrayOfcustomDataAttirbutesPostCode=[],arrayOfcustomDataAttirbutesPhone=[],arrayOfcustomDataAttirbutesEmail=[],arrayOfcustomDataAttirbutesPeopleCount=[],previousErrorList;$.validator.setDefaults({focusInvalid:!1,ignore:":hidden:not(.chosen-select, #FileUpload)",invalidHandler:function(n,t){if(($.each(previousErrorList,function(n,t){$(t.element).removeClass("error")}),t.numberOfInvalids())&&($.each(t.errorList,function(n,t){$(t.element).attr("aria-invalid",!0).parent().addClass("error")}),previousErrorList=t.errorList,window.innerHeight<800&&window.scrollY)){const n=$(t.errorList[0].element).closest(".grid-x");$("html, body").animate({scrollTop:n.offset().top},300)}},errorPlacement:function(n,t){var i=$(t),r=i.attr("type"),u;if(r==="checkbox")i.closest(".grid-x").next().find(".static-text").length?i.closest(".grid-x").next().find(".cell").append(n):i.closest(".ctrl-checkbox").append(n);else{if(r==="radio")return;r==="file"?n.insertAfter(i.closest(".fileupload-container")):i.hasClass("chosen-select")&&i.next(".chosen-container").length?n.insertAfter(i.next(".chosen-container")):n.insertAfter(i)}u=i.closest(".selectdiv-small-down");u.length&&u.addClass("error")},success:function(n){var t=n.closest(".selectdiv-small-down");t.length&&(t.removeClass("error"),n.remove())}});$(document).ready(function(){var e=window.BGV,s=$("*[data-validate-name]"),h=$("*[data-validate-age]"),c=$("*[data-validate-postcode]"),l=$("*[data-validate-phonenumber]"),a=$("*[data-validate-email]"),v=$("*[data-validate-people-count]"),t,r,o,n,u,f;$(v).each(function(){customDataAttirbutesPeopleCount={};customDataAttirbutesPeopleCount.dataNumberOfPeopleExpectedValue=$(this).map(function(){return $(this).attr("data-validate-people-count")}).get();customDataAttirbutesPeopleCount.dataNumberOfPeopleExpectedMessage=$(this).map(function(){return $(this).attr("data-validate-people-count-msg")}).get();arrayOfcustomDataAttirbutesPeopleCount.push(customDataAttirbutesPeopleCount)});$(s).each(function(){customDataAttirbutesName={};customDataAttirbutesName.dataNameValue=$(this).map(function(){return $(this).attr("data-validate-name")}).get();customDataAttirbutesName.dataNameMessage=$(this).map(function(){return $(this).attr("data-validate-name-msg")}).get();arrayOfcustomDataAttirbutesName.push(customDataAttirbutesName)});$(h).each(function(){customDataAttirbutesAge={};customDataAttirbutesAge.dataAgeValue=$(this).map(function(){return $(this).attr("data-validate-age")}).get();customDataAttirbutesAge.dataAgeMessage=$(this).map(function(){return $(this).attr("data-validate-age-msg")}).get();arrayOfcustomDataAttirbutesAge.push(customDataAttirbutesAge)});$(c).each(function(){customDataAttirbutesPostCode={};customDataAttirbutesPostCode.dataPostCodeValue=$(this).map(function(){return $(this).attr("data-validate-postcode")}).get();customDataAttirbutesPostCode.dataPostCodeMessage=$(this).map(function(){return $(this).attr("data-validate-postcode-msg")}).get();arrayOfcustomDataAttirbutesPostCode.push(customDataAttirbutesPostCode)});$(l).each(function(){customDataAttirbutesPhone={};customDataAttirbutesPhone.dataPhoneNumberValue=$(this).map(function(){return $(this).attr("data-validate-phonenumber")}).get();customDataAttirbutesPhone.dataPhoneNumberMessage=$(this).map(function(){return $(this).attr("data-validate-phonenumber-msg")}).get();arrayOfcustomDataAttirbutesPhone.push(customDataAttirbutesPhone)});$(a).each(function(){customDataAttirbutesEmail={};customDataAttirbutesEmail.dataEmailValue=$(this).map(function(){return $(this).attr("data-validate-email")}).get();customDataAttirbutesEmail.dataEmailMessage=$(this).map(function(){return $(this).attr("data-validate-email-msg")}).get();arrayOfcustomDataAttirbutesEmail.push(customDataAttirbutesEmail)});$.validator.addMethod("peoplecount",function(n,i,r){var u=new RegExp("^(?:[1-9][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[1-9])$");return $(arrayOfcustomDataAttirbutesPeopleCount).each(function(n,i){r[0]===i.dataNumberOfPeopleExpectedValue[0]&&(t=i.dataNumberOfPeopleExpectedMessage.length>0?i.dataNumberOfPeopleExpectedMessage[0]:"Expected people count max. 4 digits. ")}),this.optional(i)||u.test(n)},function(){return t});$.validator.addMethod("email",function(n,t){var i=new RegExp("^([a-zA-Z0-9_.+-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$");return $(arrayOfcustomDataAttirbutesEmail).each(function(n,i){t.id===i.dataEmailValue[0]&&(r=i.dataEmailMessage.length>0?i.dataEmailMessage[0]:"Please enter a valid email.")}),this.optional(t)||i.test(n)},function(){return r});$.validator.addMethod("phonenumber",function(t,i,r){$(arrayOfcustomDataAttirbutesPhone).each(function(t,i){r[0]===i.dataPhoneNumberValue[0]&&(i.dataPhoneNumberMessage.length>0?n=i.dataPhoneNumberMessage[0]:o="Please enter a valid phone number.")});var u=/^(?:\s*-*\s*\d)+$/.test(t);return e.facilityDetails.country==="au"&&(u=/^(?:\+?61|0)[2-478](?:[ -]?[0-9]){8}$/.test(t)),this.optional(i)||u},function(){return o});$.validator.addMethod("age",function(t,i,r){var u=new RegExp("^(?:100|[1-9]?[0-9])$");return $(arrayOfcustomDataAttirbutesAge).each(function(t,i){r[0]===i.dataAgeValue[0]&&(n=i.dataAgeMessage.length>0?i.dataAgeMessage[0]:"Please enter a valid age")}),this.optional(i)||u.test(t)},function(){return n});$.validator.addMethod("name",function(n,t){var r=new RegExp("^[a-zA-Z- /s']*$"),i=[];return($(arrayOfcustomDataAttirbutesName).each(function(n,r){i.push(r.dataNameValue[0]);t.id===r.dataNameValue[0]&&(u=r.dataNameMessage.length>0?r.dataNameMessage[0]:"Alphabets only")}),t.id.toLowerCase().includes("Organisation".toLowerCase())||t.id.toLowerCase().includes("School".toLowerCase())||t.id.toLowerCase().includes("Address".toLowerCase()))?!0:i.includes(t.id)?this.optional(t)||r.test(n):!0},function(){return u});$.validator.addMethod("postcode",function(n,t,i){var r,u;return $(arrayOfcustomDataAttirbutesPostCode).each(function(n,t){i[0]===t.dataPostCodeValue[0]&&(f=t.dataPostCodeMessage.length>0?t.dataPostCodeMessage[0]:"Please enter a valid postcode.")}),r=!0,e.facilityDetails.country==="au"&&(u=new RegExp("^[0-9]{4}$"),r=u.test(n)),this.optional(t)||r},function(){return f});$("#customform").validate();$("#customformfooter").validate();arrayOfcustomDataAttirbutesAge.length>0&&$(arrayOfcustomDataAttirbutesAge).each(function(n,t){var i=t.dataAgeValue;$("#"+i).rules("add",{age:i})});arrayOfcustomDataAttirbutesName.length>0&&$(arrayOfcustomDataAttirbutesName).each(function(n,t){var i=t.dataNameValue;$("#"+i).rules("add",{name:i})});arrayOfcustomDataAttirbutesPostCode.length>0&&$(arrayOfcustomDataAttirbutesPostCode).each(function(n,t){var i=t.dataPostCodeValue;$("#"+i).rules("add",{postcode:i})});arrayOfcustomDataAttirbutesPhone.length>0&&$(arrayOfcustomDataAttirbutesPhone).each(function(n,t){var i=t.dataPhoneNumberValue;$("#"+i).rules("add",{phonenumber:i})});arrayOfcustomDataAttirbutesEmail.length>0&&$(arrayOfcustomDataAttirbutesEmail).each(function(n,t){var i=t.dataEmailValue;$("#"+i).rules("add",{email:i})});arrayOfcustomDataAttirbutesPeopleCount.length>0&&$(arrayOfcustomDataAttirbutesPeopleCount).each(function(n,t){var i=t.dataNumberOfPeopleExpectedValue;$("#"+i).rules("add",{peoplecount:i})}),function(){for(i=0;i<document.forms.length;i++)document.forms[i].reset();$(".chosen-select[id]").trigger("chosen:updated")}()})