$(document).ready(function(){for(var n in OEConfWESendForm)WESendFormCoreJs.Initialize(n)});var WESendFormCoreJs={DataWESendForm:null,Initialize:function(n){WESendFormCoreJs.DataWESendForm=OEConfWESendForm[n].Config;WESendFormCoreJs.InitializeForm();WESendFormCoreJs.InitializeButton()},ChooseCorrectSendForm:function(n){var i,t;for(i in OEConfWESendForm)if(t=OEConfWESendForm[i].Config,t.FormLinks!==undefined&&t.FormLinks.ButtonSubmitID!==undefined&&t.FormLinks.ButtonCancelID!==undefined&&(n==t.FormLinks.ButtonSubmitID||n==t.FormLinks.ButtonCancelID)){this.DataWESendForm=t;break}},InitializeForm:function(){var u="post",i,t="",r=WESendFormCoreJs.DataWESendForm,f=WESendFormCoreJs.GetActionURL(),n;OE.Form.Validator.initialize(r.FormLinks.ElementsID);switch(r.Method){case 0:u="post";break;case 1:u="get"}switch(r.Enctype){case 1:i="multipart/form-data";break;default:i="application/x-www-form-urlencoded"}switch(r.Target){case 0:t="_self";break;case 1:t="_blank";break;case 2:t="_parent";break;case 3:t="_top"}n=$("#XForm");n.attr("action",f);n.attr("method",u);n.attr("target",t);n.attr("enctype",i);n.attr("encoding",i)},InitializeButton:function(){for(var i=WESendFormCoreJs.DataWESendForm,f=i.FormLinks.ButtonSubmitID,e=i.Validator,n=-1,r,u;;){n++;var o=n==0?"":"_R"+n,s=f+o,t=$("#"+s);if(n>0&&(!t||t.length<1))break;if(t.length<1)return;t.click(function(){var n,t;return WEInfoPage.RenderMode=="Editor"?!1:(n=$(this),n&&n.length>0&&(t=n.attr("id"),WESendFormCoreJs.ChooseCorrectSendForm(t),WESendFormCoreJs.SetCurrentIterSuffix(t),WESendFormCoreJs.SetAltTargetFromButton(n)),e?WESendFormCoreJs.ExecuteValidation()&&WESendFormCoreJs.submit():WESendFormCoreJs.submit(),!1)})}if(r=i.FormLinks.ButtonCancelID,!!r){if(u=$("#"+r),u.length<1)return;u.click(function(){var n,t;return WEInfoPage.RenderMode=="Editor"?!1:(n=$(this),n&&n.length>0&&(t=n.attr("id"),WESendFormCoreJs.ChooseCorrectSendForm(t),WESendFormCoreJs.SetCurrentIterSuffix(t)),WESendFormCoreJs.CleanFormFields(),!1)})}},ExecuteValidation:function(){return OE.Form.Validator.validate(WESendFormCoreJs.DataWESendForm.FormLinks.ElementsID,WESendFormCoreJs.CurrentIterSuffix)},SetCurrentIterSuffix:function(n){if(this.CurrentIterSuffix="",n){var t=n.lastIndexOf("_");t>=0&&(this.CurrentIterSuffix=n.substring(t))}},ElemetsIDWithSuffix:function(n){if(this.CurrentIterSuffix==""||!n)return n;var t={};return jQuery.each(n,function(n,i){var r=n+this.CurrentIterSuffix;$("#"+r).length||(r=n);t(r)=i}),t},SetAltTargetFromButton:function(n){var r,t,i,u;if(n&&n.length&&(r=n.find(":button"),r.length)&&(t=r.attr("data-oe-target-url"),t)){if(i=WESendFormCoreJs.GetActionURL(),t.substring(0,1)=="?"){if(!i)return;u=i.indexOf("?");i+=u<0?t:t.substring(1)}else i=t;OE.Common.setLocString(this.DataWESendForm.Action.Links,i)}},CleanFormFields:function(){var i=WESendFormCoreJs.DataWESendForm,r=i.FormLinks.ElementsID,n,t;for(n in r)t=$("#"+n).find(":input"),t.clearFields()},GetActionURL:function(){var a=WEInfoPage.RelativePath,n=OE.Common.Link.getPath(WESendFormCoreJs.DataWESendForm.Action),r,t,o,i,s,c,l,h,u,f,e;if(WEInfoPage.RelativePath="",r=OE.Common.Link.getPath(WESendFormCoreJs.DataWESendForm.Action),WEInfoPage.RelativePath=a,r!=n&&(t=WEInfoPage.PagePath,o=t.lastIndexOf("/"),o>=0&&(t=t.substring(o+1)),r.indexOf(t)==0&&(n=r)),WESendFormCoreJs.DataWESendForm.KeepURLParams&&n.length!==0){if(i="",UrlVars)for(s in UrlVars)c=UrlVars[s],l=(i?"&":"")+s+"="+c,i+=l;i.length!==0&&(h="",u=n.indexOf("#"),u>=0&&(h=n.substr(u),n=n.substr(0,u)),f=i,e=n.indexOf("?"),e>=0&&(f=n.substr(e+1)+"&"+f,n=n.substr(0,e)),n+="?"+f+h)}return n},submit:function(){var i=WESendFormCoreJs.ElemetsIDWithSuffix(WESendFormCoreJs.DataWESendForm.FormLinks.ElementsID),t,n;if(WESendFormCoreJs.DataWESendForm.Action){if(t=WESendFormCoreJs.GetActionURL(),n=OE.Form.getCloneForm(i,null,t),!n)return!1;n.submit()}}}