window.kentico=window.kentico||{};window.kentico.updatableFormHelper=function(){function u(t){var e,u,f,s,h;if(!t||!t.formId||!t.targetAttributeName||!t.unobservedAttributeName)throw new Error("Invalid configuration passed.");if(e=["email","number","password","search","tel","text","time"],u=document.getElementById(t.formId),u&&u.getAttribute(t.targetAttributeName))for(i=0;i<u.length;i++)f=u.elements[i],s=!f.hasAttribute(t.unobservedAttributeName)&&f.type!=="submit",s&&(h=f.tagName==="INPUT"&&e.indexOf(f.type)!==-1||f.tagName==="TEXTAREA",h&&(f.previousValue=f.value,f.addEventListener("keyup",o(function(t){setTimeout(function(){u.updating||t.target.previousValue===t.target.value||(u.keyupUpdate=!0,n(u,t.target))},0)},r)),f.addEventListener("blur",function(t){setTimeout(function(){u.updating||t.target.previousValue===t.target.value||n(u,t.relatedTarget)},0)})),f.addEventListener("change",function(){setTimeout(function(){u.updating||n(u)},0)}))}function n(n,i){var u,f,r,o;n&&(u=n.getAttribute("data-ktc-ajax-update"),u)&&($(n).find("input[type='submit']").attr("onclick","return false;"),n.updating=!0,f=new FormData(n),f.append("kentico_update_form","true"),r=i||document.activeElement,o=function(n){var i,f,t;n.target.response.data||(i=selectionEnd=null,r&&(r.type==="text"||r.type==="search"||r.type==="password"||r.type==="tel"||r.type==="url")&&(i=r.selectionStart,selectionEnd=r.selectionEnd),f=$(window).scrollTop(),$(u).replaceWith(n.target.responseText),$(window).scrollTop(f),r.id&&(t=document.getElementById(r.id),t&&(t.focus(),e(t,i,selectionEnd))))},t(n,f,o))}function f(n){n.preventDefault();var i=n.target,r=new FormData(i),u=function(n){var f=n.target.getResponseHeader("Content-Type"),t,r,u;f.indexOf("application/json")===-1?(t=$(window).scrollTop(),r=i.getAttribute("data-ktc-ajax-update"),$(r).replaceWith(n.target.response),$(window).scrollTop(t)):(u=JSON.parse(n.target.response),location.href=u.redirectTo)};t(i,r,u)}function t(n,t,i){var r=new XMLHttpRequest;r.addEventListener("load",i);r.open("POST",n.action);r.send(t)}function e(n,t,i){(t!==null||i!==null)&&n.setSelectionRange&&n.setSelectionRange(t,i)}function o(n,t,i){var r;return function(){var u=this,f=arguments,e=function(){r=null;i||n.apply(u,f)},o=i&&!r;clearTimeout(r);r=setTimeout(e,t||200);o&&n.apply(u,f)}}var r=800;return{registerEventListeners:u,updateForm:n,submitForm:f}}();window.kentico=window.kentico||{};window.kentico._forms=window.kentico._forms||{};window.kentico._forms.formFileUploaderComponent=function(n){function i(n){var i,t,r;for(n.fileUploaderDisabledElements=[],i=n.elements,t=0;t<i.length;t++)r=i[t],r.disabled||(n.fileUploaderDisabledElements.push(t),r.disabled=!0)}function t(n){n.fileUploaderDisabledElements.forEach(function(t){n.elements[t].disabled=!1})}function r(n,t,i,r,u,f){n.value=null;n.removeAttribute("hidden");t.setAttribute("hidden","hidden");i.innerText=i.originalText;r.value="";u.setAttribute("hidden","hidden");f.setAttribute("data-icon","select");f.removeAttribute("title")}function u(u){var f=n.getElementById(u.fileInputId),s=n.getElementById(u.fileInputId+"-placeholder"),c=n.getElementById(u.fileInputId+"-replacement"),e=n.getElementById(u.fileInputId+"-button"),o=n.getElementById(u.fileInputId+"-icon"),h=n.getElementById(u.tempFileIdentifierInputId),a=n.getElementById(u.systemFileNameInputId),v=n.getElementById(u.originalFileNameInputId),l=n.getElementById(u.deletePersistentFileInputId),y=u.tempFileOriginalName,p=u.deleteFileIconButtonTitle;s.originalText=s.innerText;e.originalText=e.innerText;(v.value||y)&&l.value.toUpperCase()==="FALSE"&&(s.innerText=u.originalFileNamePlain||y,e.removeAttribute("hidden"),o.setAttribute("data-icon","remove"),o.setAttribute("title",p),c.removeAttribute("hidden"),f.setAttribute("hidden","hidden"));var w=function(){if(h.value){var n=new XMLHttpRequest;n.open("POST",u.deleteEndpoint+"&tempFileIdentifier="+h.value);n.send()}},b=function(){a.value&&(l.value=!0);w();r(f,c,s,h,e,o)},k=function(n){o.getAttribute("data-icon")==="remove"&&(n.preventDefault(),b())};e.addEventListener("click",b);o.addEventListener("click",k);f.addEventListener("change",function(){var r,y,n;if(f.value){if(e.removeAttribute("hidden"),o.setAttribute("data-icon","loading"),i(f.form),r=f.files[0],r!==undefined&&r.size>u.maxFileSize*1024){f.value=null;h.value="";v="";window.alert(u.maxFileSizeExceededErrorMessage);t(f.form);o.setAttribute("data-icon","select");return}y=new FormData;n=new XMLHttpRequest;n.contentType="multipart/form-data";y.append("file",r);n.addEventListener("load",function(){var i,r;n.readyState===4&&(n.status===200?(i=n.response,typeof i=="string"&&(i=JSON.parse(i)),i.errorMessage?(f.value=null,alert(i.errorMessage),o.setAttribute("data-icon","select"),e.setAttribute("hidden","hidden")):(a.value&&(l.value=!0),w(),r=f.files[0].name,h.value=i.fileIdentifier,s.innerText=r,e.removeAttribute("hidden"),o.setAttribute("data-icon","remove"),o.setAttribute("title",p),c.innerText=r,c.removeAttribute("hidden"),f.setAttribute("hidden","hidden"))):(alert("Error sending file: "+n.statusText),o.setAttribute("data-icon","select"),e.setAttribute("hidden","hidden")),e.innerHTML=e.originalText,t(f.form))});n.upload.addEventListener("progress",function(n){e.innerText=parseInt(n.loaded/n.total*100)+"%"});n.open("POST",u.submitEndpoint);n.responseType="json";n.send(y)}})}return{attachScript:u}}(document)