(function(n){if(typeof epi=="undefined"||typeof epi.EPiServer=="undefined"||typeof epi.EPiServer.Forms=="undefined"){console.error("Forms is not initialized correctly");return}if(typeof n=="undefined"){console.error("Forms cannot work without jQuery");return}var t=epi.EPiServer.Forms.Utils,i=epi.EPiServer.Forms.Data,r=epi.EPiServer.Forms.Extension;epi.EPiServer.Forms.__DebounceTimer=null;epi.EPiServer.Forms.__Initialized=!(epi.EPiServer.Forms.__Initialized===undefined);n.extend(!0,epi.EPiServer.Forms,{Utils:{debounce:function(n,t){return function(){var i=this,r=arguments;clearTimeout(this.__DebounceTimer);this.__DebounceTimer=setTimeout(function(){n.apply(i,r)},t)}},loadExternalScriptOnDemand:function(n,t,i){for(var o=document.getElementsByTagName("head")[0],u=0,f=n.length,e=null,r;u<\/div>").text(t).html()},htmlDecodeEntities:function(n){var t=document.createElement("textarea");return t.innerHTML=n,t.value},isMatchedReg:function(n,t){var r=new RegExp(t),i=r.exec(n);return i!=null&&i.length>0},raiseFormsEvent:function(t,i){var u=n.extend(!0,{type:"forms",workingFormInfo:t},i),r;t?t.$workingForm.triggerHandler(u):(r=n(".EPiServerForms:eq(0)"),(!r||r.length<1)&&(r=n("body")),r.triggerHandler(u))},injectVisitorData:function(t){var r=n(".FormHidden[data-epiforms-visitordatasources]",t.$workingForm),i;r&&r.length!==0&&(i=null,r.each(function(){if(i=n(this),i&&i.length>0){var t=null;n(i.data("epiforms-visitordatasources").split(",")).each(function(n,r){t=epi.EPiServer.Forms.VisitorData[r];typeof t=="function"&&t(i)})}}))},getElementValue:function(t){return t.hasClass("FormFileUpload")?this.getPreviousPostedFiles(t):t.hasClass("FormChoice")?t.find(".FormChoice__Input:checked").map(function(t,i){return n(i).val()}).get():t.hasClass("FormSelection")?[].concat(t.find("select").val()):t.hasClass("FormCaptcha")||t.hasClass("FormTextbox")||t.hasClass("FormTextbox--Textarea")?n.trim(n(".FormTextbox__Input",t).val()):t.hasClass("FormRange")?n.trim(n(".FormRange__Input",t).val()):epi.EPiServer.Forms.Extension.getCustomElementValue(t)},getFormStepBlock:function(t,i){return t?n(".Form__Element [data-epiforms-element-name='"+t+"']",i):[]},getWorkingFormFromInnerElement:function(t){return n(t).parents(".EPiServerForms:first")},getFormIdentifier:function(n){return n.prop("id")},getPreviousPostedFiles:function(t){var i=t.find(".FormFileUpload__Input"),u=i.attr("name")||i.data("epiforms-element-name"),f=epi.EPiServer.Forms.Data.loadCurrentFormDataFromStorage(this.getWorkingFormFromInnerElement(i)),r=i[0].files;return n.each(f,function(n,t){if(n.indexOf("__TempData")!=-1&&n.replace("__TempData","")==u&&r.length==0)return r=t,!1}),r},getCurrentStepIndex:function(t){var i=n("input[name=__FormCurrentStepIndex]",t.$workingForm).val();return i===undefined||i.trim()===""||isNaN(+i)||+i>t.StepsInfo.Steps.length-1?t.StepsInfo.AllStepsAreNotLinked?i=0:n.each(t.StepsInfo.Steps,function(n,u){if(u.attachedContentLink==epi.EPiServer.CurrentPageLink&&r.isStepSatisfyDependentCondition(u,t))return i=n,!1}):i=+i,i},setCurrentStepIndex:function(t,i){return n("input[name=__FormCurrentStepIndex]",t.$workingForm).val(i),i},validateRegularExpressionValidator:function(n,i,r){if(!r||!r.model||!r.model.jsPattern||i==="")return{isValid:!0};if(!t.isMatchedReg(i,r.model.jsPattern)){var u=t.stringFormat(r.model.message,[r.model.jsPattern,r.description]);return{isValid:!1,message:u}}return{isValid:!0}},showNextStepOnEnterKeyDown:function(t){var i=n(t.target).parents(".EPiServerForms:first");return(keyCode=t.keyCode,$nextStepButton=n(".Form__NavigationBar .Form__NavigationBar__Action.btnNext",i),$buttonSubmitSections=n(".Form__Element.FormSubmitButton",i).parent(".FormStep").filter(function(){return!n(this).hasClass("hide")}),keyCode==13&&$buttonSubmitSections.length==0&&$nextStepButton!=null&&$nextStepButton.length)?(t.preventDefault(),t.stopPropagation(),$nextStepButton.trigger("click"),!0):!0}},Extension:{getSummarizedText:function(i,r,u){var h=u?"
":"\n",y=u?i.ConfirmMessage:t.htmlDecodeEntities(i.ConfirmMessage),c=i.ElementsInfo,l=[],a=[],p=["__FormGuid","__FormLanguage","__FormCurrentStepIndex","__FormSubmissionId"],v=i.ConfirmMessage?y+h+h:"",s=null,f=null,e,o;for(e in r)if(l.indexOf(e.replace("__TempData",""))==-1){if(o=e.indexOf("__TempData")!=-1?c[e.replace("__TempData","")]:c[e],s=o&&o.friendlyName?o.friendlyName:"",f=o&&o.customBinding==!0?epi.EPiServer.Forms.CustomBindingElements[o.type](o,r[e]):r[e],(f==null||f instanceof Array&&f.length===0||n.isEmptyObject(f))&&(f=""),f instanceof Array?f=n.map(f,function(n){return n?typeof n=="string"?n:typeof n=="object"?n.name:void 0:null}).join(", "):f instanceof FileList&&f.length==0?f="":(f=f.toString().substr(0,46).trim(),f.length>=45&&(f+=" ...")),n("[name="+e+"]",i.$workingForm).hasClass("FormHideInSummarized")&&a.push(e),s==""||s==null||f==""||f==null||p.indexOf(e)>=0||a.indexOf(e)>=0)continue;else l.push(e);v+=u?t.stringFormat("{0}: {1}"+h,[s,t.htmlEncodeEntities(f)]):t.stringFormat("{0}: {1}"+h,[t.htmlDecodeEntities(s),f])}return v},showSummarizedText:function(t,i){var r=n.Deferred(),u=this.getSummarizedText(i,t,!1),f;return!u||u.trim()===""?(r.resolve(!0),r.promise()):(f=confirm(u),r.resolve(f),r.promise())},getCustomElementValue:function(n){return n.val()},bindCustomElementValue:function(n,t){var i=n.find(".Form__CustomInput");i.val(t)},isStepSatisfyDependentCondition:function(n,t){if(!n)return!1;var r=n.dependField,u=i.loadCurrentFormDataFromStorage(t.$workingForm),f=epi.EPiServer.Forms.DependConditions[n.dependCondition];return!r||!f||!u?!0:f(u[r],n.dependValue)}},Data:{loadCurrentFormDataFromStorage:function(t){var r=this.getStorage(),i=r[epi.EPiServer.Forms.Utils.getFormIdentifier(t)];return i?(i=n.parseJSON(i),!i)?{}:i:{}},saveCurrentFormDataToStorage:function(n,t){var i=this.getStorage();return i.setItem(epi.EPiServer.Forms.Utils.getFormIdentifier(n),JSON.stringify(t)),t},clearFormDataInStorage:function(n){this.getStorage().removeItem(epi.EPiServer.Forms.Utils.getFormIdentifier(n))},getStorage:function(){return sessionStorage}}});var u=i.getStorage(),f={VisitorData:{"EPiServer.Forms.Implementation.VisitorData.GeoVisitorDataSource":function(t){n.ajax({url:"/EPiServer.Forms/DataSubmit/GetGeoData",type:"POST",success:function(n){var r=t.val(),i;r||(i=t.data("epiforms-visitordataproperty"),n!=null&&n[i]&&t.val(n[i]))}})}}},e={Validators:{"EPiServer.Forms.Implementation.Validation.RequiredValidator":function(n,t,i){return i&&(t==""||t&&!t.length)?{isValid:!1,message:i.model.message}:{isValid:!0}},"EPiServer.Forms.Implementation.Validation.RegularExpressionValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.EmailValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.UrlValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.DateDDMMYYYYValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.DateMMDDYYYYValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.DateYYYYMMDDValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.IntegerValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.PositiveIntegerValidator":t.validateRegularExpressionValidator,"EPiServer.Forms.Implementation.Validation.AllowedExtensionsValidator":function(n,t,i){function h(n,t,i){var r=c(n);return r.length<1?!1:(r=r.toLowerCase(),t.indexOf(r)>=0)?!1:i.length<1?!0:i.indexOf(r)>-1}function c(n){return n.substr((~-n.lastIndexOf(".")>>>0)+2)}if(!t||t instanceof Array&&t.length==0)return{isValid:!0};var o=t,r=i.model.accept,l=epi.EPiServer.Forms.UploadExtensionBlackList.split(","),u=r==undefined||r.length<1?[]:r.split(","),f=0,e=0,s=u.length,a=o.length;if(s>0)for(;ff)return{isValid:!1,message:epi.EPiServer.Forms.Utils.stringFormat(i.model.message,[f/1048576])};return{isValid:!0}},"EPiServer.Forms.Implementation.Validation.NumericValidator":function(t,i,r){return!i||n.isNumeric(i)==!0?{isValid:!0}:{isValid:!1,message:r.model.message}},"EPiServer.Forms.Implementation.Validation.CaptchaValidator":{initialize:function(t){var i=this;t.parents(".FormCaptcha").find(".FormCaptcha__Refresh").on("click",function(t){i._refreshCaptcha(n(this));t.preventDefault()})},validate:function(n,t){var i=t.trim();return i!=null&&i!=""},onServerValidateFailed:function(n){this._refreshCaptcha(n);n.focus()},_refreshCaptcha:function(n){var t=n.hasClass("FormCaptcha")?n:n.parents(".FormCaptcha"),i=t.find(".FormCaptcha__Image"),r=t.find(".FormTextbox__Input");i.attr("src",i.attr("src")+"&d="+Math.random());r.val("")}}}},o={DependConditions:{Equals:function(n,t){return n=n?epi.EPiServer.Forms.Utils.getConcatString(n,",").toUpperCase():"",t=t?t.toUpperCase():"",n===t},NotEquals:function(n,t){return n=n?epi.EPiServer.Forms.Utils.getConcatString(n,",").toUpperCase():"",t=t?t.toUpperCase():"",n!=t},Contains:function(n,t){return n=n?epi.EPiServer.Forms.Utils.getConcatString(n,",").toUpperCase():"",t=t?t.toUpperCase():"",n.indexOf(t)>=0},NotContains:function(n,t){return n=n?epi.EPiServer.Forms.Utils.getConcatString(n,","):"",!n&&t||n&&!t||n&&t&&n.toUpperCase().indexOf(t.toUpperCase())<0},MatchRegularExpression:function(n,t){var i=new RegExp(t,"igm");return i.ignoreCase=i.global=i.multiline=!0,!t||t&&i.test(n)}}};n.extend(!0,epi.EPiServer.Forms,f);n.extend(!0,epi.EPiServer.Forms,e);n.extend(!0,epi.EPiServer.Forms,o);n.extend(!0,epi.EPiServer.Forms,{CustomBindingElements:{}});epi.EPiServer.Forms.init=function(){epi.EPiServer.Forms.__Initialized||(epi.EPiServer.Forms.__Initialized=!0,n(document).ready(function(){function v(i){var u,r,c,o;if(i.preventDefault(),i.stopPropagation(),u=t.getWorkingFormFromInnerElement(i.target),r=e(u),r.SubmittableStatus.submittable===!1)return f(r,r.SubmittableStatus.message),!1;if(c=h(r),!g(c,r))return s(c),!1;o=et(u);n.when(ut(r,o)).then(function(e){var h,c,s,v,a,y;if(!e)return!1;h=[];c=null;for(s in o)s.indexOf("__TempData")==-1&&(c=t.getFormStepBlock(s,u),c.parents(".FormStep:first").hasClass("hide")||(v=l(r.ValidationInfo,s),h=h.concat(nt(s,o[s],v))));if(a=n.grep(h,function(n){return n.isValid==!1}),a.length>0)return y=n.map(a,function(n){return r.ElementsInfo[n.fieldName].friendlyName+": "+n.message}),f(r,y.join(" ")),!1;w(i)})}function y(n){n.preventDefault();n.stopPropagation();var r=t.getWorkingFormFromInnerElement(n.target),i=e(r);t.raiseFormsEvent(i,{type:"formsReset",sourceEvent:n});p(r,i);o(i.StepsInfo.Steps[0],i)}function p(t,r){t.get(0).reset();r.SubmittableStatus&&r.SubmittableStatus.submittable===!1?f(r,r.SubmittableStatus.message):f(r,"");i.clearFormDataInStorage(t);n(".Form__Element",t).each(function(t,i){var r=n(i);c(r).text("");r.hasClass("FormChoice")?r.find("input[type=checkbox], input[type=radio]").each(function(t,i){var r=n(i);r.prop("checked",r.data("epiforms-default-value")?!0:!1)}):r.hasClass("FormSelection")?(r.find("option[disabled]:eq(0)").prop("selected",!0),r.find("option").each(function(t,i){var r=n(i);r.prop("disabled")===!1&&r.prop("selected",r.data("epiforms-default-value")?!0:!1)})):r.hasClass("FormFileUpload")&&(b(r).text(""),rt(r.find(".FormFileUpload__Input")))})}function w(r){var y=t.getWorkingFormFromInnerElement(r.target),lt=epi.EPiServer.Forms.Utils.getFormIdentifier(y),u=e(y),it=i.saveCurrentFormDataToStorage(y,k(y)),v=new FormData,ft=t.getCurrentStepIndex(u),ut=tt(ft,u),g=ut?!1:!0,b=n(r.srcElement||r.target),at=b.val(),ct=!!b.data("epiforms-is-progressive-submit"),w,d,et,ot,ht,nt;g=g||!!b.data("epiforms-is-finalized");it[b.prop("name")]=b.val();v.append("__FormGuid",lt);v.append("__FormHostedPage",epi.EPiServer.CurrentPageLink);v.append("__FormLanguage",epi.EPiServer.CurrentPageLanguage);v.append("__FormCurrentStepIndex",ft);v.append("__FormWithJavaScriptSupport","true");for(d in it)if(it.hasOwnProperty(d))if(w=it[d],Array.isArray(w)&&w.length>0&&w[0]!==null&&typeof w[0]=="object"&&w[0].file&&Object.getPrototypeOf(w[0].file)===File.prototype){for(et=w,ot="",nt=0;nt0){if(e.hasClass("FormExcludeDataRebind"))return;if(e.hasClass("FormChoice__Input--Checkbox")){n.each(e,function(){var t=n(this).val();n(this).attr("checked",f.indexOf(t)>-1)});return}if(e.hasClass("FormChoice__Input--Radio")){s=n.isArray(f)?f[0]:f;n.each(e,function(){var t=n(this).val();n(this).attr("checked",s==t)});return}if(e.parents(".FormSelection:first").length>0){n("option",e).each(function(t,i){n(i).attr("selected",f.indexOf(n(i).val())>-1)});return}if(e.hasClass("FormCaptcha__Input"))return;if(e.hasClass("FormFileUpload__Input")){o=f instanceof Array&&f.length>0?f[0].name:"";h=e.parents(".FormFileUpload:first");o&&(c=t.stringFormat(epi.EPiServer.Forms.Messages.fileUpload.postedFile,[o]),l=b(h),l.text(c).show());return}if(e.hasClass("Form__CustomInput")){a=e.parents(".Form__CustomElement:first");r.bindCustomElementValue(a,f);return}e.val(f)}})}function b(n){return n.find(".FormFileUpload__PostedFile")}function k(t,r){var u=e(t),f=h(u),o=d(f,r),s=i.loadCurrentFormDataFromStorage(t);return n.extend(s,o)}function et(t){var r=d(t),u=i.loadCurrentFormDataFromStorage(t);return n.extend(u,r)}function e(n){var r=t.getFormIdentifier(n),i=epi.EPiServer.Forms[r];return i.$workingForm=n,i}function d(i,r){var u={};return n(".Form__Element, .Form__CustomElement",i).not(".FormStep,.Form__Element--NonData").each(function(i,f){if(($el=n(f),typeof r!="function"||!r($el))&&!$el.parents(".FormStep:first").hasClass("hide")){var e=f.name||$el.data("epiforms-element-name");e&&(u[e]=t.getElementValue($el))}}),n(".FormFileUpload .FormFileUpload__Input",i).each(function(){var i,o,f,e;if((typeof r!="function"||!r(n(this)))&&this.name&&this.files!=undefined)if(i=this.name+"__TempData",u[this.name]=[],u[i]=[],this.files.length===0)o=t.getPreviousPostedFiles(n(this).parents(".FormFileUpload:first")),u[this.name]=o,u[i]=o;else for(f=0;f0&&(y=nt(s,a,h),e=n.grep(y,function(n){return n.isValid==!1}),e&&e.length>0?(p=n.map(e,function(n){return n.message}),u.addClass("ValidationFail"),o.text(p.join(" ")).show(),f=!1):f=!0),t.raiseFormsEvent(r,{type:"elementValidated",isValid:f,elementName:s,elementValue:a,elementIdentifier:v,element:i,$messageContainer:o}),f}function nt(t,i,r){var u=[];return n(r).each(function(r,f){var e=epi.EPiServer.Forms.Validators[f.type],o=null,s;typeof e=="function"?o=e:typeof e.validate=="function"&&(o=e.validate);o&&(s=o(t,i,f),n.extend(s,{fieldName:t,fieldValue:i}),u.push(s))}),u}function c(i){var r=i.attr("name")||i.data("epiforms-element-name"),u=t.stringFormat("{0}[data-epiforms-linked-name='{1}'], {0}[data-epiforms-linked-name='{2}']",[".Form__Element__ValidationError",r,i.attr("id")]);return n(u)}function l(n,t){if(n instanceof Array&&n.length!==0&&t)for(var r=0,u=n.length,i=null;r=65&&t<=90||t==32?!1:!n.shiftKey&&!n.altKey&&!n.ctrlKey&&t>=48&&t<=57||t>=96&&t<=105||n.keyCode==65&&n.ctrlKey===!0||t==67&&n.ctrlKey===!0||t==88&&n.ctrlKey===!0||t>=35&&t<=39||t==8||t==9||t==13||t==46||t==45?!0:(i=this.value,(t==109||t==189)&&i[0]==="-")?!1:(!n.shiftKey&&!n.altKey&&!n.ctrlKey&&t==190||t==188||t==110)&&/[\.,]/.test(i)?!1:void 0}).on("keyup",function(){var n=this.value;+n||n&&(n=(n[0]==="-"?"-":"")+n.replace(/[^0-9\.]/g,""),n=n.replace(/\.(?=(.*)\.)+/g,""),this.value=n)});n(".EPiServerForms input.FormTextbox__Input,.FormChoice__Input.FormChoice__Input--Checkbox,.FormRange__Input,.FormTextbox__Input.FormUrl__Input,.FormChoice__Input.FormChoice__Input--Radio,.FormTextbox__Input.FormCaptcha__Input.FormHideInSummarized").on("keydown",function(n){return t.showNextStepOnEnterKeyDown(n)})}))};epi.EPiServer.Forms.ExternalScriptSources.length<=0&&epi.EPiServer.Forms.ExternalCssSources.length<=0?epi.EPiServer.Forms.init():(t.loadExternalScriptOnDemand(epi.EPiServer.Forms.ExternalScriptSources,function(){t.raiseFormsEvent(null,{type:"formsLoadExternalScripts",scripts:epi.EPiServer.Forms.ExternalScriptSources});epi.EPiServer.Forms.init()}),t.loadExternalCssOnDemand(epi.EPiServer.Forms.ExternalCssSources,function(){t.raiseFormsEvent(null,{type:"formsLoadExternalCss",Css:epi.EPiServer.Forms.ExternalCssSources})}))})($$epiforms||$);