$(document).ready(function(){WESendMailCoreJs.Initialize()});var WESendMailCoreJs={CurrSendMail:null,LoadingOpen:!1,Initialize:function(){for(elemID in OEConfWESendMail)WESendMailCoreJs.IniSendMail(elemID);$(document).ajaxError(function(){OE.Loading.close();var n=OE.Common.getLocString(OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.NoPopupMessage);n+="\n - Error Ajax.";OE.ModalPopup.show(n)})},IniSendMail:function(n){var u=OEConfWESendMail[n].ScriptVersion,t=OEConfWESendMail[n],r,i;(OE.Form.Validator.initialize(t.FormLinks.ElementsID),this.idRecaptcha=window.WEGoogleRecaptcha?window.WEGoogleRecaptcha.getUsedElementID(t.FormLinks.ElementsID):null,r={beforeSubmit:this.ShowRequest,success:this.ShowResponse,data:null,url:WEInfoPage.RelativePath+"WEFiles/Server/WESendMail-v"+u+".php"},i=$("#"+t.FormLinks.ButtonSubmitID),i.length<1||WEInfoPage.RenderMode=="Editor")||i.click(function(){return WESendMailCoreJs.CurrSendMail=n,WESendMailCoreJs.Submit(n,r),!1})},Submit:function(n,t,i){var f=this,e=OEConfWESendMail[n].ScriptVersion,u,r;if(t.data={PagePath:WEInfoPage.PageAssociatePath,WESendMailID:n,Culture:WEInfoPage.Culture,RelativePath:WEInfoPage.RelativePath,OEVersion:e},!i||!i.ignoreValidation){if(!this.CheckValidators(t))return!1;if(this.idRecaptcha){window.WEGoogleRecaptcha.run(this.idRecaptcha,function(){f.Submit(n,t,{ignoreValidation:!0})});return}}return document.URL.startsWith("http://localhost:")?(OE.ModalPopup.show("Sending form only works on a server."),!1):WEInfoPage.PHPVersion==""||WEInfoPage.PHPVersion=="undefined"||WEInfoPage.PHPVersion==null?(OE.ModalPopup.show("WESendMail : "+OE.Common.htmlDecode(OE.Text.NoPHP)),!1):(u=OEConfWESendMail[n].FormLinks.ElementsID,r=OE.Form.getCloneForm(u,t.data,t.url),!r)?!1:(OE.Loading.open(),r.ajaxSubmit(t),!1)},CleanFormFields:function(n){var i=OEConfWESendMail[n].FormLinks.ElementsID,t;for(ID in i)t=$("#"+ID).find(":input"),t.clearFields();this.idRecaptcha&&WEGoogleRecaptcha.resetByID(this.idRecaptcha)},CheckValidators:function(n){return OE.Form.Validator.validate(OEConfWESendMail[n.data.WESendMailID].FormLinks.ElementsID)},ShowRequest:function(){return!0},ShowResponse:function(n,t,i,r){var s,u,f,e,o;OE.Loading.close();s=n;n=n.substr(n.indexOf("{"),n.lastIndexOf("}")-n.indexOf("{")+1);try{n=JSON.parse(n);e=OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.PopupConfirm;o=OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.PageReturn;t=="success"?n.State=="success"?(e==!0&&(u=OE.Common.getLocString(OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.OkpopupMessage),u+="<br /><br /><span style='font-size: 12px;font-style: italic;'>"+n.ErrorDescription+"<\/span>",u!=""&&OE.ModalPopup.show(u),WESendMailCoreJs.CleanFormFields(WESendMailCoreJs.CurrSendMail)),o==!0&&(f=OE.Common.Link.getPath(OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.OkPageLink),f!=""&&(window.location=f))):(e==!0&&(u=OE.Common.getLocString(OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.NoPopupMessage),u+="<br /><br /><span style='font-size: 12px;font-style: italic;'>"+n.State+" - "+n.ErrorDescription+"<\/span>",u!=""&&OE.ModalPopup.show(u)),o==!0&&(f=OE.Common.Link.getPath(OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.NoPageLink),f!=""&&(window.location=f))):(u=GetLocalizableString(OEConfWESendMail[WESendMailCoreJs.CurrSendMail].SendMailResponse.NoPopupMessage),u+="\nErreur Ajax",OE.ModalPopup.show(u));r&&!r.attr("id")&&r.remove()}catch(h){u=OE.Common.htmlDecode(OE.Text.NoResponse)+"<br />"+n+"<br /><span style='font-size:12px'>Error :"+h.description+s+"<\/span>";OE.ModalPopup.show(u)}}}