function t806__init(t){t_onFuncLoad("tvote__init",(function(){tvote__init(t)}));var e=document.querySelector("#rec"+t);if(e){var r=e.querySelector(".t806__test");if(r){var o=e.querySelectorAll(".t806__answers"),n=e.querySelectorAll(".t806__result-wrap"),l=e.querySelectorAll(".t806__social-btn-vk"),a=e.querySelectorAll(".t806__social-btn-fb"),c=e.querySelectorAll(".t806__social-btn-twitter"),s=e.querySelector(".t806__start-title"),i=[],_=[],u=s?s.textContent:"",y=window.location.href;r.classList.add("t806__counter"),r.setAttribute("data-count",0),Array.prototype.forEach.call(n,(function(t){var e=t.querySelector("img");if(e){var r=e.getAttribute("src");""!==r&&_.push(r)}})),1==_.length&&Array.prototype.forEach.call(n,(function(t){var e=t.querySelector("img"),r=t.querySelector(".t806__result-desc"),o=t.querySelectorAll(".t806__result-count, .t806__result-variant");e&&e.setAttribute("src",_[0]),r.classList.remove("t806__result-desc_withoutimg"),Array.prototype.forEach.call(o,(function(t){t.style.color="#ffffff"}))})),Array.prototype.forEach.call(o,(function(t){var e=t.getAttribute("data-right-answer")||"";i.push(e.trim()),t.removeAttribute("data-right-answer")})),t806__changeRadio(t,i),t806__changeTestInput(t),t806__clickStartButton(t),t806__clickCheckButton(t,i),t806__clickNextButton(t),t806__clickResultButton(t),t806__clickRestartButton(t),l&&Array.prototype.forEach.call(l,(function(e){e.addEventListener("click",(function(){t806_shareVK(t,u,y)}))})),a&&Array.prototype.forEach.call(a,(function(e){e.addEventListener("click",(function(){t806_shareFB(t,u,y)}))})),c&&Array.prototype.forEach.call(c,(function(e){e.addEventListener("click",(function(){t806_shareTwitter(t,y)}))})),t806__clearFormOnBackClick(e)}}}function t806__showNumber(t,e){var r=document.querySelector("#rec"+t),o=r.querySelectorAll(".t806__number"),n=r.querySelectorAll(".t806__question");Array.prototype.forEach.call(o,(function(t){var r=""+e+"/"+n.length+"";t.innerHTML=r}))}function t806__clickStartButton(t){var e=document.querySelector("#rec"+t),r=1,o;e.querySelector(".t806__start-btn").addEventListener("click",(function(r){var o=this.closest(".t806__start"),n;o.style.display="none",o.nextElementSibling.style.display="block",t806__showNumber(t,1),t806_fixcontentheight(t),t806_scrollToTop(e),t806__runLazyLoad(),r.preventDefault()}))}function t806__runLazyLoad(){"y"!==window.lazy&&"yes"!==document.getElementById("allrecords").getAttribute("data-tilda-lazy")||t_onFuncLoad("t_lazyload_update",(function(){t_lazyload_update()}))}function t806__changeRadio(t,e){var r=document.querySelector("#rec"+t),o=r.querySelectorAll('.t806__input[type="radio"]'),n=r.querySelectorAll(".t806__question"),l;0!==n.length&&(n[n.length-1].classList.add("t806__lastquestion"),Array.prototype.forEach.call(o,(function(o){o.addEventListener("change",(function(){var o=r.querySelector(".t806__counter"),n=o.getAttribute("data-count"),l=this.closest(".t806__question"),a=this.closest(".t806__answers"),c=l.querySelectorAll(".t806__input"),s=a.nextElementSibling,i=s.querySelector(".t806__btn_result"),_=s.querySelector(".t806__btn_next"),u=a.querySelectorAll(".t806__answer .t-vote__btn-res"),y=e[l.getAttribute("data-question-num")-1];y=y.split(",")[0];var n=o.getAttribute("data-count");if("radio"===this.getAttribute("type")){var p=this.value;a.classList.add("t806__answers_answered"),l.classList.contains("t806__lastquestion")?i.classList.add("t806__btn_show"):_.classList.add("t806__btn_show"),Array.prototype.forEach.call(c,(function(t){t.setAttribute("disabled",!0)})),+p==+y&&(n++,o.setAttribute("data-count",n));var d=l.querySelector(".t806__input:checked"),h,f;if(Number(d.value)!==Number(y))d.closest(".t806__answer").classList.add("t806__answer_wrong");d.parentNode.nextElementSibling.style.display="block";var v=l.querySelector('.t806__input[value="'+y+'"]'),w;if(v)v.closest(".t806__answer").classList.add("t806__answer_correct");Array.prototype.forEach.call(u,(function(t){t.classList.add("t806__answer-vote_show")}));var b=d.closest(".t806__answer_correct");b&&b.classList.add("t806__answer_withoutopacity"),Array.prototype.forEach.call(c,(function(t){var e=t.closest(".t806__answer_correct");e&&e.classList.add("t806__answer_withoutopacity")}))}t806_fixcontentheight(t)}))})))}function t806__changeTestInput(t){var e=document.querySelector("#rec"+t),r=e.querySelectorAll('.t806__input[type="checkbox"]'),o=e.querySelectorAll(".t806__answers"),n=e.querySelectorAll(".t806__question");if(0!==n.length){var l=n[n.length-1],a=[];return Array.prototype.forEach.call(o,(function(t){t.setAttribute("data-test-checked","")})),l.classList.add("t806__lastquestion"),Array.prototype.forEach.call(r,(function(e){e.addEventListener("change",(function(){var e=this.closest(".t806__answers"),r=this.value,o=this.getAttribute("type"),n,l;"checkbox"===o&&e.nextElementSibling.querySelector(".t806__btn_check").classList.add("t806__btn_show");"checkbox"===o&&this.checked&&-1===a.indexOf(r)&&a.push(r),"checkbox"!==o||this.checked||a.splice(a.indexOf(r),1),e.setAttribute("data-test-checked",a.join(",")),t806_fixcontentheight(t)}))})),a}}function t806__clickCheckButton(t,e){var r=document.querySelector("#rec"+t),o=r.querySelectorAll(".t806__btn_check"),n=[];Array.prototype.forEach.call(o,(function(o){o.addEventListener("click",(function(o){var l=r.querySelector(".t806__counter"),a=this.closest(".t806__question"),c=a.querySelectorAll(".t806__input"),s=a.querySelector(".t806__answers"),i=this.closest(".t806__btn-wrapper"),_;Array.prototype.forEach.call(i.parentNode.children,(function(t){t.classList.contains("t806__answers")&&(_=t)}));for(var u=a.querySelector(".t806__btn_result"),y=a.querySelector(".t806__btn_next"),p=_.querySelectorAll(".t806__answer .t-vote__btn-res"),d=l.getAttribute("data-count"),h=[],f=e[a.getAttribute("data-question-num")-1].split(","),v=s.getAttribute("data-test-checked").split(","),w=0;w=c&&e<=s)return void((i=r.querySelector(".t806__result_"+(a+2))).style.display="block")}if(e>100*(o-1)/o)return void(l.style.display="block")}else{e<=100/o&&n&&(n.style.display="block");for(var a=0;a100*(a+1)/o&&e<=100*(a+2)/o)(i=r.querySelector(".t806__result_"+(a+2))).style.display="block"}e>100*(o-1)/o&&l&&(l.style.display="block")}}function t806__clickRestartButton(t){var e=document.querySelector("#rec"+t),r=e.querySelectorAll(".t806__btn_restart"),o=e.querySelectorAll(".t806__question");Array.prototype.forEach.call(r,(function(r){r.addEventListener("click",(function(r){var n;e.querySelector(".t806__start").style.display="block";var l=e.querySelectorAll(".t806__result");Array.prototype.forEach.call(l,(function(t){t.style.display="none"}));var a=e.querySelectorAll(".t806__btn_next");Array.prototype.forEach.call(a,(function(t){t.classList.remove("t806__btn_show")}));var c=e.querySelectorAll(".t806__btn_result");Array.prototype.forEach.call(c,(function(t){t.classList.remove("t806__btn_show")}));var s=e.querySelectorAll(".t806__btn_check");Array.prototype.forEach.call(s,(function(t){t.classList.remove("t806__btn_show")}));var i=e.querySelectorAll(".t806__details");Array.prototype.forEach.call(i,(function(t){t.style.display="none"}));var _=e.querySelectorAll(".t806__answers");Array.prototype.forEach.call(_,(function(t){t.classList.remove("t806__answers_answered"),t.setAttribute("data-test-checked","")}));var u=e.querySelectorAll(".t806__answer");Array.prototype.forEach.call(u,(function(t){t.classList.remove("t806__answer_correct"),t.classList.remove("t806__answer_wrong")}));var y=e.querySelectorAll(".t806__input");Array.prototype.forEach.call(y,(function(t){var e;t.closest(".t806__answer").classList.remove("t806__answer_withoutopacity"),t.checked=!1,t.removeAttribute("disabled")}));var p=e.querySelectorAll(".t806__answer .t-vote__btn-res"),d;Array.prototype.forEach.call(p,(function(t){t.classList.remove("t806__answer-vote_show")})),e.querySelector(".t806__counter").setAttribute("data-count",0);var h=e.querySelectorAll(".t806__number");Array.prototype.forEach.call(h,(function(t){t.textContent="1/"+o.length})),t806_fixcontentheight(t),r.preventDefault()}))}))}function t806_scrollToTop(t){var e=t.querySelector(".t806"),r=t.getBoundingClientRect().top+window.pageYOffset;r>=window.scrollY||e.classList.contains("t806_scroll-disabled")||window.scrollTo(0,r)}function t806__clearFormOnBackClick(t){window.addEventListener("pagehide",(function(){var e=t.querySelectorAll(".t806__input");Array.prototype.forEach.call(e,(function(t){t.checked=!1}))}))}function t806_fixcontentheight(t){var e=document.querySelector("#rec"+t),r=e.querySelector(".t-cover");if(r){var o=e.querySelector(".t-cover__filter"),n=e.querySelector(".t-cover__carrier"),l=e.querySelector(".t-cover__wrapper"),a=e.querySelector("div[data-hook-content]");if(a){var c=parseFloat(getComputedStyle(r,null).height.replace("px","")),s=a.offsetHeight;s>300&&c1e3&&(s+=100),r.style.height=s+"px",o.style.height=s+"px",n.style.height=s+"px",l.style.height=s+"px",/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||setTimeout((function(){var t=n,e;t.querySelector("iframe").length>0&&setWidthAndHeightVideo(t,s+"px","youtube")}),2e3))}}}function t806_changeShareFBUrl(t,e){var r=t.split("?")[0]+"?",o,n;return decodeURIComponent(e.substring(1)).split("&").forEach((function(t){-1==t.indexOf("fb_action_ids")&&-1==t.indexOf("fb_action_types")&&-1==t.indexOf("result")&&(r=r+t+"&")})),r=r.substring(0,r.length-1)}function t806_shareVK(t,e,r){var o=t806__showResult(t),n=o[0],l=o[1],a=0==(o[2]||"").indexOf("/")?"":"/",c=window.location.pathname.length>1?window.location.pathname:"",s=-1!=(o[2]||"").indexOf("://")?o[2]:window.location.protocol+"//"+window.location.host+c+a+o[2],i,_=t+o[3]+"vk",u="https://vote.tildacdn.com/vote/2/share/index.php?text="+n;u+="&result="+l,(o[2]||"").length>0&&(u+="&url="+s),u+="&id="+_,u+="&social=vk&name="+e;var y=Date.now(),p=new XMLHttpRequest;p.open("GET",u,!0),p.onload=function(){if(this.status>=200&&this.status<400){var t,o=(JSON.parse(p.response).url||"").replace(/\?.*/,""),n,l;t806__openPopup("http://vkontakte.ru/share.php?url="+(-1!=window.location.href.indexOf("#")?r.split("#")[0]:r)+"&title="+e+"&description="+e+"&image="+o+"&noparse=true")}},p.onerror=function(){var t=p.response,e=Date.now()-y;0==t.status&&e<100&&0!==t.readyState&&alert("Request error (get posts). Please check internet connection...")},p.send()}function t806_shareFB(t,e,r){var o=t806__showResult(t),n=o[0],l=o[1],a=0==(o[2]||"").indexOf("/")?"":"/",c=window.location.pathname.length>1?window.location.pathname:"",s=-1!=(o[2]||"").indexOf("://")?o[2]:window.location.protocol+"//"+window.location.host+c+a+o[2],i,_=t+o[3]+"fb",u=l.substring(0,l.indexOf("/"))+l.substring(l.indexOf("/")+1),y="https://vote.tildacdn.com/vote/2/share/index.php?text="+n;y+="&result="+l,(o[2]||"").length>0&&(y+="&url="+s),y+="&id="+_,y+="&social=fb&name="+e;var p=Date.now(),d=new XMLHttpRequest;d.open("GET",y,!0),d.onload=function(){if(this.status>=200&&this.status<400){var t=window.location.search;r=(""!==t?t806_changeShareFBUrl(r,t):r)+"?result="+u,FB.ui({method:"share_open_graph",action_type:"og.shares",action_properties:JSON.stringify({object:{"og:url":r}})})}},d.onerror=function(){var t=d.response,e=Date.now()-p;0==t.status&&e<100&&0!==t.readyState&&alert("Request error (get posts). Please check internet connection...")},d.send()}function t806_shareTwitter(t,e){var r,o=document.querySelector("#rec"+t).querySelector(".t806"),n=t806__showResult(t),l=n[0],a=n[1],c=a.substring(0,a.indexOf("/")),s=a.substring(a.indexOf("/")+1),i;o.classList.contains("t806__ru")&&(i="Мой результат: "+c+" из "+s+". "+l),o.classList.contains("t806__en")&&(i="My result: "+c+" out of "+s+". "+l);var _="https://twitter.com/share?url="+(e=e.replace(/&/g,"%26"))+"&text="+i;t806__openPopup(_=encodeURI(_))}function t806__openPopup(t){window.open(t,"","toolbar=0,status=0,width=626,height=436")}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});