function setBackgrounds(){var t,e=document.querySelectorAll("*[data-bg-src]");e.length&&(e.forEach((function(e){t=e.getAttribute("data-bg-src"),e.style.backgroundImage=""!=t&&"false"!=t&&t&&null!=t?"url("+t+")":""})),window.devicePixelRatio>1.1&&(e=document.querySelectorAll("*[data-bg-src-2x]")).forEach((function(e){""!=(t=e.getAttribute("data-bg-src-2x"))&&"false"!=t&&!1!==t&&null!=t||(t=e.getAttribute("data-bg-src")),e.style.backgroundImage=""!=t&&"false"!=t&&t&&null!=t?"url("+t+")":""})))}function switchControlSlider(){var t,e,r=document.querySelectorAll(".form-switch input[data-bs-target]"),a={};r.length&&r.forEach((function(r){t=document.querySelector(r.getAttribute("data-bs-target")),e=new bootstrap.Carousel(t,{interval:!1,touch:!1}),a[r.getAttribute("data-bs-target")]=e,r.addEventListener("change",(function(t){a[this.getAttribute("data-bs-target")].next(),a[this.getAttribute("data-bs-target")].pause()}))}))}function stopYouTubeOnModalClose(){var t,e=document.querySelectorAll(".modal");e.length&&e.forEach((function(e){(t=e.querySelector("iframe"))&&(-1==t.src.indexOf("youtube.com")&&-1==t.src.indexOf("youtu.be")||e.addEventListener("hide.bs.modal",(function(t){var e=this.querySelector("iframe");e.setAttribute("data-src",e.src),e.src="",setTimeout((function(){e.src=e.getAttribute("data-src")}),100)})))}))}function initAnimations(t){"undefined"!=typeof AOS&&(t||(t=500),AOS.init({easing:"ease-out-cubic",once:!0,offset:50,duration:t}))}function ajaxFormInit(){var t=document.querySelectorAll("form.js-ajax-form");t.length&&t.forEach((function(t){t.addEventListener("submit",(function(e){if(e.preventDefault(),t.getAttribute("data-sitekey")){var r=t.querySelector("input[name='g-recaptcha-response']");if(r)document.querySelector(".grecaptcha-badge").style.display="block",grecaptcha.execute(t.getAttribute("data-sitekey"),{action:"submit"}).then((function(e){r.setAttribute("value",e),ajaxFormSubmit(t)}));else{var a=document.getElementById("grecaptcha-"+t.getAttribute("data-sitekey"));if(a)document.querySelector(".grecaptcha-badge").style.display="block",grecaptcha.execute(t.getAttribute("data-sitekey"),{action:"submit"}).then((function(e){(r=document.createElement("input")).setAttribute("type","hidden"),r.setAttribute("name","g-recaptcha-response"),r.setAttribute("value",e),t.append(r),ajaxFormSubmit(t)}));else{var o=document.querySelector("head");(a=document.createElement("script")).setAttribute("src","https://www.google.com/recaptcha/api.js?render="+t.getAttribute("data-sitekey")),a.setAttribute("id","grecaptcha-"+t.getAttribute("data-sitekey")),a.addEventListener("load",(function(){grecaptcha.ready((function(){grecaptcha.execute(t.getAttribute("data-sitekey"),{action:"submit"}).then((function(e){(r=document.createElement("input")).setAttribute("type","hidden"),r.setAttribute("name","g-recaptcha-response"),r.setAttribute("value",e),t.append(r),ajaxFormSubmit(t)}))}))})),o.append(a)}}}else ajaxFormSubmit(t)}))}))}function ajaxFormSubmit(t){var e=new FormData(t);if("post"!=t.method.toLowerCase())return ajaxFormSubmitResult('AJAX form submit works only with the "post" method set.',t),!1;t.querySelectorAll("input, textarea, select").forEach((function(e){if(e.required&&""==e.value||e.required&&"checkbox"==e.type&&!1===e.checked||!0!==e.validity.valid)return ajaxFormSubmitResult("Not all required fields were filled or filled incorrectly.",t),!1}));var r=new XMLHttpRequest;r.addEventListener("loadend",(function(){200!=r.status?ajaxFormSubmitResult("Error: HTTP status code is "+r.status,t):ajaxFormSubmitResult(r.responseText,t)})),r.addEventListener("timeout",(function(){ajaxFormSubmitResult("Request timed out, data was not sent.",t)})),r.open(t.method,t.action),r.send(e)}function ajaxFormSubmitResult(t,e){var r=e.querySelectorAll(".js-form-result"),a="";try{JSON.parse(t)}catch(e){return console.error(t),ajaxFormShowResult(!1,a=t,r),!1}(t=JSON.parse(t)).success?!0===t.success?ajaxFormShowResult(!0,a=e.querySelector(".js-form-result[data-result='success'] .js-form-alert-text").getAttribute("data-default-text"),r):ajaxFormShowResult(!0,a=t.success,r):t.error?(a=t.error,console.error(t),ajaxFormShowResult(!1,a,r)):(a="Unknown error. Please, check if your hosting supports PHP.",console.error(a),ajaxFormShowResult(!1,a,r))}function ajaxFormShowResult(t,e,r){r.length&&r.forEach((function(r){t&&"success"==r.getAttribute("data-result")||!t&&"error"==r.getAttribute("data-result")?(r.classList.remove("invisible"),r.classList.add("show"),r.querySelector(".js-form-alert-text").innerText=e,setTimeout((function(){r.classList.remove("show"),r.addEventListener("transitionend",(function(){this.classList.contains("show")||this.classList.add("invisible")})),document.querySelector(".grecaptcha-badge")&&(document.querySelector(".grecaptcha-badge").style.display="none")}),5e3)):(r.classList.add("invisible"),r.classList.remove("show"))}))}document.addEventListener("DOMContentLoaded",(function(){setBackgrounds(),switchControlSlider(),stopYouTubeOnModalClose(),initAnimations(),ajaxFormInit()}));