function t835_init(t){var e=document.querySelector("#rec"+t),r;if(e&&e.querySelector(".t835")){var n=e.querySelector(".t-form");if(n){var o=e.querySelector(".t835__quiz-wrapper"),a=e.querySelectorAll(".t-input-group"),s=e.querySelector(".t835__btn_prev"),i=e.querySelector(".t835__btn_next"),c=e.querySelector(".t835__btn_result"),l=e.querySelector(".t-form__submit"),u=e.querySelector(".t-submit"),p=e.querySelector(".t-form__errorbox-middle");if(p)var d=p.querySelector(".t-form__errorbox-wrapper");var _='
';p.insertAdjacentHTML("beforebegin",_),n.classList.remove("js-form-proccess");var f=e.querySelector(".t835__capture-form"),S=e.querySelector(".t835__result-title"),m=S?S.textContent:"",y=Boolean(o.getAttribute("data-auto-step-change")),v=!1,h,g=300,b=!1;t835_workWithAnswerCode(e),Array.prototype.forEach.call(a,(function(t,e){t.setAttribute("data-step-number",e)})),t835_wrapCaptureForm(e);var L=Boolean(f.innerHTML||m),A=0,w=n.classList.contains("t-conditional-form"),q=null,C;t835_createSteps(a);var E=t835_createStepsArray(e),x=E.length,F=e.querySelectorAll(".t835__screen-wrapper"),k;E[A]&&(w?t_onFuncLoad("t_form__conditionals__initStepForm",(function(){var r;q=t_form__conditionals__initStepForm({recId:t,steps:F,activeStepIndex:A,ignoredSteps:[".t835__capture-form"],ignoredInputGroups:[".t835__t-input-group_capture"],onConditionalFieldChange:function(t){x=t.totalActiveStepsCount-1,C=updateProgressValue(),t835_showCounter(e,C.counterCurrentStep,C.counterAllSteps),t835_setProgress(e,C.progressCurrentStep,C.progressAllSteps),checkIfShouldSubmitForm(),showOrHideButtons()}}),x=q.getState().totalActiveStepsCount-1,initForm()})):initForm())}}function initForm(){showStep(A),t835_disabledPrevBtn(e,A),C=updateProgressValue(),t835_showCounter(e,C.counterCurrentStep,C.counterAllSteps),e.setAttribute("data-animationappear","off"),e.style.opacity=1,y&&initAutoStepChange(),s.addEventListener("click",(function(t){handleGoPrevStep(t)})),i.addEventListener("click",(function(t){handleGoNextStep(t)})),Array.prototype.forEach.call(a,(function(t){t.addEventListener("keypress",(function(t){var e=n.querySelector(".t-step-form__step_active");"Enter"!==t.code&&13!==t.keyCode||n.classList.contains("js-form-proccess")||e.querySelector(".t-input-group_ta")||handleGoNextStep(t)}))})),c.addEventListener("click",(function(t){handleGoNextStep(t)})),e.addEventListener("click",(function(t){var r=t.target,n;!!r.closest('[type="submit"]')&&r&&t835_adjustStepToHeight(e)})),t835_adjustHeightOnResize(e)}function handleGoPrevStep(t){b||(t.preventDefault(),resetAutoStepChangeProgress(),checkFirstStep()||(A=q?q.getState().prevStepIndex:getActiveStepIndex()-1,q&&q.onStepChange(A),C=updateProgressValue(),t835_setProgress(e,C.progressCurrentStep,C.progressAllSteps),t835_showCounter(e,C.counterCurrentStep,C.counterAllSteps),t835_awayFromResultScreen(e),t835_hideError(e,A),t835_disabledPrevBtn(e,A),showStep(A),t835_scrollToTop(o),n.classList.contains("js-form-proccess")&&n.classList.remove("js-form-proccess")))}function handleGoNextStep(t){if(!b){t.preventDefault(),resetAutoStepChangeProgress();var r=t835_showError(e,o,A);if(r&&d&&(d.style.display="none"),!r){var n=checkLastStep();A=q?q.getState().nextStepIndex:getActiveStepIndex()+1,q&&q.onStepChange(A),C=updateProgressValue(),t835_setProgress(e,C.progressCurrentStep,C.progressAllSteps),t835_showCounter(e,C.counterCurrentStep,C.counterAllSteps),t835_disabledPrevBtn(e,A),n&&L?showCaptureForm():showStep(A),t835_scrollToTop(o)}}}function getActiveStepIndex(){return q?q.getState().activePossibleStepIndex:A}function updateProgressValue(){return{counterCurrentStep:getActiveStepIndex()+1,counterAllSteps:x,progressCurrentStep:getActiveStepIndex(),progressAllSteps:L?x:x-1}}function checkLastStep(){return getActiveStepIndex()===x-1}function checkFirstStep(){return 0===getActiveStepIndex()}function checkNextToLast(){return getActiveStepIndex()===x-2}function showOrHideButtons(){if(!L){if(checkNextToLast())return i.style.display="none",c.style.display="block",void(l.style.display="none");if(checkLastStep())return i.style.display="none",c.style.display="none",void(l.style.display="block")}if(checkLastStep())return i.style.display="none",c.style.display="block",void(l.style.display="none");i.style.display="block",c.style.display="none",l.style.display="none"}function showStep(t){var r=n.querySelector(".t-step-form__step_active"),o=E[t];if(r)animateStepSwitch(r,o,{onNewStepAnimationStart:function(){t835_runLazyLoad(),checkIfShouldSubmitForm(),showOrHideButtons(),enableButtons(e);var t=e.querySelector(".t-range");t&&t_triggerEvent(t,"displayChanged"),b=!1,t835_adjustStepToHeight(e)},onAnimationStart:function(){b=!0,disableButtons(e)}});else{o&&o.classList.add("t-step-form__step_active"),t835_runLazyLoad(),checkIfShouldSubmitForm(),showOrHideButtons();var a=e.querySelector(".t-range");a&&t_triggerEvent(a,"displayChanged"),setTimeout((function(){t835_adjustStepToHeight(e)}),100)}}function showCaptureForm(){n.classList.add("js-form-proccess");var t=e.querySelector(".t835__quiz-description"),r;animateStepSwitch(n.querySelector(".t-step-form__step_active"),f,{onAnimationStart:function(){b=!0,t&&(t.style.display="none"),S&&(S.style.display="block"),c&&(c.style.display="none"),l&&(l.style.display="block"),disableButtons(e)},onNewStepAnimationStart:function(){t835_runLazyLoad(),enableButtons(e),b=!1,t835_adjustStepToHeight(e)}})}function animateStepSwitch(t,e,r){function handleFadeInEnd(){e.classList.remove("t-step-form__step_fadeIn"),e.removeEventListener("animationend",handleFadeInEnd),e.removeEventListener("animationcancel",handleFadeInCancel),r.onAnimationComplete&&r.onAnimationComplete()}function handleFadeInCancel(){e.classList.remove("t-step-form__step_fadeIn"),e.removeEventListener("animationend",handleFadeInEnd),e.removeEventListener("animationcancel",handleFadeInCancel)}function animateStepIn(){e.addEventListener("animationend",handleFadeInEnd),e.addEventListener("animationcancel",handleFadeInCancel),e.classList.add("t-step-form__step_active"),e.classList.add("t-step-form__step_fadeIn"),r.onNewStepAnimationStart&&r.onNewStepAnimationStart()}function handleFadeOutEnd(){t.classList.remove("t-step-form__step_fadeOut"),t.classList.remove("t-step-form__step_active"),t.removeEventListener("animationend",handleFadeOutEnd),e&&animateStepIn()}function animateStepOut(){t.addEventListener("animationend",handleFadeOutEnd),t.classList.add("t-step-form__step_fadeOut")}return r.onAnimationStart&&r.onAnimationStart(),t?animateStepOut():animateStepIn()}function disableButtons(){s&&(s.disabled=!0),i&&(i.disabled=!0),c&&(c.disabled=!0),u&&(u.disabled=!0)}function enableButtons(){checkFirstStep()||s&&(s.disabled=!1),i&&(i.disabled=!1),c&&(c.disabled=!1),u&&(u.disabled=!1)}function initAutoStepChange(){var t=["ri","rd","rs","sb","cb"],e;E.filter((function(e){var r=e.querySelector(".t-input-group");return-1!==t.indexOf(r.getAttribute("data-field-type"))})).forEach((function(t){var e=Array.prototype.slice.call(t.querySelectorAll(".js-tilda-rule"));(e=e.filter((function(t){return!t.classList.contains("t-radio-ownanswer")}))).forEach((function(t){t.addEventListener("change",handleAutoStepChange)}))}))}function handleAutoStepChange(t){checkLastStep()&&!L||v||(v=!0,h=setTimeout((function(){handleGoNextStep(t),resetAutoStepChangeProgress()}),g))}function resetAutoStepChangeProgress(){clearTimeout(h),v=!1}function checkIfShouldSubmitForm(){!L&&checkLastStep()?n.classList.add("js-form-proccess"):n.classList.remove("js-form-proccess")}}function t835_workWithAnswerCode(t){var e=t.querySelector(".t-input-group_ri");if(e){var r=e.querySelectorAll("input");Array.prototype.forEach.call(r,(function(t){var e;if(-1!==t.value.indexOf("value::")){t835_setAnswerCode(t);var r,n=t.parentNode.querySelector(".t-img-select__text");n.textContent=n.textContent.split("value::")[0].trim()}}))}var n=t.querySelector(".t-input-group_rd");if(n){var o=n.querySelectorAll("input");Array.prototype.forEach.call(o,(function(t){var e,r;-1!==t.value.indexOf("value::")&&(t835_setAnswerCode(t),t.parentNode.innerHTML=function(){var e;return t.innerHTML.split("value::")[0].trim()})}))}var a=t.querySelector(".t-input-group_sb");if(a){var s=a.querySelectorAll("option");Array.prototype.forEach.call(s,(function(t){var e;-1!==t.value.indexOf("value::")&&(t835_setAnswerCode(t),t.textContent=t.textContent.split("value::")[0].trim())}))}}function t835_createSteps(t){Array.prototype.forEach.call(t,(function(t){if(!t.classList.contains("t835__t-input-group_capture")){var e=document.createElement("div");e.classList.add("t835__screen-wrapper"),e.classList.add("t-step-form__step"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}))}function t835_runLazyLoad(){var t;if(document.querySelector(".t-records:not([data-tilda-mode])")){var e=document.querySelector("#allrecords");"y"!==window.lazy&&"yes"!==e.getAttribute("data-tilda-lazy")||t_onFuncLoad("t_lazyload_update",(function(){t_lazyload_update()}))}}function t835_setAnswerCode(t){var e=t.value.split("value::")[1].trim();t.value=e}function t835_wrapCaptureForm(t){var e=t.querySelector(".t835__capture-form"),r=t.querySelectorAll(".t-input-group"),n=t.querySelector(".t835__quiz-form-wrapper");Array.prototype.forEach.call(r,(function(t){var o=t,a=o.classList.contains("t-input-group_em"),s=o.classList.contains("t-input-group_nm"),i=o.classList.contains("t-input-group_ph"),c=o.classList.contains("t-input-group_cb"),l=o.getAttribute("data-step-number"),u=n.classList.contains("t835__quiz-form-wrapper_withcheckbox")?4:3;if(l>=r.length-u){var p=!0;if(n.classList.contains("t835__quiz-form-wrapper_newcapturecondition")){var d=t835_getNextAll(o);Array.prototype.forEach.call(d,(function(t){p=t.classList.contains("t-input-group_cb")||t.classList.contains("t-input-group_em")||t.classList.contains("t-input-group_nm")||t.classList.contains("t-input-group_ph")}))}p&&(n.classList.contains("t835__quiz-form-wrapper_withcheckbox")?(a||s||i||c)&&(o.classList.add("t835__t-input-group_capture"),e.appendChild(o)):(a||s||i)&&(o.classList.add("t835__t-input-group_capture"),e.appendChild(o)))}}))}function t835_showCounter(t,e,r){var n=t.querySelector(".t835__quiz-description-counter");n&&(n.innerHTML=e+"/"+r)}function t835_setProgress(t,e,r){var n=t.querySelector(".t835__progressbar"),o=parseFloat(getComputedStyle(n).width),a=t.querySelector(".t835__progress"),s=o/r,i=100*Math.abs(e*s/o)+"%";a&&(a.style.width=i)}function t835_scrollToTop(t){var e=t.getBoundingClientRect().top+window.pageYOffset,r=t.closest(".t835");if(!(e>=window.scrollY||r.classList.contains("t835_scroll-disabled"))){var n;if(!!document.querySelector(".t228__positionfixed")){var o=document.querySelector(".t228__positionfixed:not(.t228__mobile)"),a=parseFloat(window.getComputedStyle(o).height);window.isMobile||isNaN(a)||(e=e-a-5)}window.scrollTo(0,e)}}function t835_createStepsArray(t){var e=t.querySelectorAll(".t835__screen-wrapper"),r=[];return Array.prototype.forEach.call(e,(function(t){t.classList.contains("t835__capture-form")||r.push(t)})),r}function t835_disabledPrevBtn(t,e){var r=t.querySelector(".t835__btn_prev");0===e?r.setAttribute("disabled",!0):r.removeAttribute("disabled")}function t835_hideError(t,e){var r,n=t835_createStepsArray(t)[e];n&&(n.classList.remove("js-error-control-box"),n.querySelector(".t-input-error").innerHTML="")}function t835_awayFromResultScreen(t){var e=t.querySelector(".t835__quiz-description"),r=t.querySelector(".t835__result-title");r&&(r.style.display="none"),e&&(e.style.display="block")}function t835_showError(t,e,r){if(e.classList.contains("t835__quiz-published"))return t835_setError(t,r)}function t835_setError(t,e){var r,n=t835_createStepsArray(t)[e],o;if("object"!=typeof window.tildaForm)return o;var a=window.tildaForm.validate(n),s=a[0];if(s){var i=s.type[0],c=t.querySelector(".t-form .t-form__errorbox-middle .js-rule-error-"+i),l="";c&&(l=c.textContent),l||t_onFuncLoad("t_forms__getMsg",(function(){l=t_forms__getMsg(i)})),"emptyfill"===i?o=!1:(n&&n.classList.add("js-error-control-box"),o=window.tildaForm.showErrors(n,a));var u=n.querySelector(".t-input-error");u&&(u.innerHTML=l)}return o}var t835_debounceAdjustheight=t835_debounce(t835_adjustStepToHeight,200);function t835_adjustHeightOnResize(t){window.addEventListener("resize",(function(){t835_debounceAdjustheight(t)}))}function t835_debounce(t,e){var r;return function(){var n=Array.prototype.slice.call(arguments);clearTimeout(r),r=setTimeout((function(){t.apply(null,n)}),e)}}function t835_adjustStepToHeight(t){var e=30,r=1,n=t.querySelector(".t835__quiz-form-wrapper"),o=t.querySelector(".t835__quiz-nofixedheight"),a=n?n.offsetHeight:0;if(!(a<=0)&&o){var s=parseInt(getComputedStyle(o).height,10),i=Math.abs(s-a);1s&&(o.style.overflow="hidden",setTimeout((function(){o.style.overflow=""}),300)),o.style.height=a+"px")}}function t835_getNextAll(t){for(var e=[],r=t;r.nextElementSibling;)r.nextElementSibling.classList.contains("t-input-group")&&e.push(r.nextElementSibling),r=r.nextElementSibling;return e}function t835_onSuccess(t){t_forms__onSuccess(t)}Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.msMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.webkitMatchesSelector||Element.prototype.oMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(t){for(var e=this;e&&1===e.nodeType;){if(Element.prototype.matches.call(e,t))return e;e=e.parentElement||e.parentNode}return null});