var iframe,baseurl="https://app.buzzlead.com.br",cdnurl="https://static.buzzlead.com.br";try{!function(a,t){try{a.addEventListener("load",function(){try{var e;inicializeWidget(),setEventsToOpenModal(),a.jQuery?loadModalPlugin():((e=t.createElement("script")).src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js",e.onload=loadModalPlugin,t.getElementsByTagName("head")[0].appendChild(e))}catch(e){console.error(e)}})}catch(e){console.error(e)}}(window,document)}catch(e){console.error(e)}function getCookie(e){for(var a=e+"=",t=document.cookie.split(";"),o="",n=0;n'}):"vex.open.facebook.compartilharCodigoPromocional"==e.data.ref?vex.open({content:'
'}):"vex.open.campaignRules"==e.data.ref?vex.open({content:"
"+e.data.campaignRules+"
"}):"vex.open.termsOfService"==e.data.ref?vex.open({content:"
"+e.data.termsOfService+"
"}):"vex.open.privacyPolicy"==e.data.ref?"text"==e.data.privacyPolicy.type?vex.open({content:"
"+e.data.privacyPolicy.texto+"
"}):window.open(e.data.privacyPolicy.url):"vex.open.preview"==e.data.ref?showPreview(e.data.formData):"vex.open.contactsList"==e.data.ref?e.data.isMobile?window.open("","_self").document.write(e.data.html):vex.open({content:e.data.html,afterOpen:function(){function e(e){a.contentWindow.postMessage({ref:"prompt.contactsList",response:e},"*")}setTimeout(function(){load(e)},500)}}):"whatsapp"==e.data.ref?window.location.href=e.data.url:"return.facebook"==e.data.ref?(a.contentWindow.postMessage({ref:"prompt.facebook",error:e.data.error},"*"),closeModalWindow()):"painel"==e.data.ref?window.location.href=e.data.url:"convert"==e.data.ref?window.Tracker(e.data.formData):"vex.open.spreadsheet"==e.data.ref?vex.open({content:'

Limite: 20 linhas

'}):"setLocalStorageAmbassador"==e.data.ref?e.data.ambassador&&0
"}),new XMLHttpRequest);e.onload=function(){try{var e;200===this.status&&((e=document.getElementById("preview-email").contentWindow.document).open(),e.write(this.responseText),e.close())}catch(e){alerteErro(e)}},e.open("POST",baseurl+"/widget/"+window.campaignId+"/email",!0),e.setRequestHeader("Content-Type","application/json"),e.send(JSON.stringify(o)),document.getElementById("finalizar").addEventListener("click",function(e){try{document.getElementById("finalizar").disabled=!0,document.getElementById("finalizar").style.backgroundColor="#7F7F7F";var a=document.getElementById("preview-email").contentWindow.document.getElementById("message"),t=(a&&(o.message=a.value),new XMLHttpRequest);t.onload=function(){try{var e;200===this.status&&(e=JSON.parse(this.responseText),document.getElementById("finalizar").disabled=!1,document.getElementById("finalizar").style.backgroundColor="#3288e6",iframe.contentWindow.postMessage({ref:"prompt.success",referral:e,email:!0},"*"),vex.close())}catch(e){iframe.contentWindow.postMessage({ref:"prompt.error",email:!0,message:"alalala"},"*"),document.getElementById("finalizar").disabled=!1,vex.close()}},t.open("POST",baseurl+"/widget/"+window.campaignId,!0),t.setRequestHeader("Content-Type","application/json"),t.send(JSON.stringify(o))}catch(e){iframe.contentWindow.postMessage({ref:"prompt.error",email:!0,message:"alalala"},"*")}})}function validatePastedSpreadSheet(){document.getElementById("pasteArea").style.display="none";var e=document.getElementById("pasteAreaInput"),a=new XMLHttpRequest,e=(a.onload=function(){var d,r;0===(indications=JSON.parse(this.response)).length?(document.getElementById("pasteArea").style.display="none",document.getElementById("indicationsArea").style.display="none",document.getElementById("errorArea").style.display="block"):(d=document.getElementById("indicationsTable"),d.setAttribute("style","border-collapse: collapse; width: 100%"),r=document.createElement("tbody"),indications.forEach(function(e,a){var t,o,n=document.createElement("tr"),i=document.createElement("td");for(t in i.setAttribute("style","padding: 8px; text-align: left;border-bottom: 1px solid #ddd;"),i.appendChild(document.createTextNode(a+1)),n.appendChild(i),e)e.hasOwnProperty(t)&&((o=document.createElement("td")).setAttribute("style","padding: 8px; text-align: left;border-bottom: 1px solid #ddd;"),o.appendChild(document.createTextNode(e[t])),n.appendChild(o));r.appendChild(n),d.appendChild(r)}),document.getElementById("indicationsArea").style.display="block")},{data:e.value});a.open("POST",baseurl+"/widget/"+window.campaignId+"/spreadsheet/validate",!0),a.setRequestHeader("Content-Type","application/json"),a.send(JSON.stringify(e))}function setCookie(e,a,t,o){t||0===t||(t=365);var n=new Date,n=(n.setTime(n.getTime()+24*t*60*60*1e3),"expires="+n.toGMTString());o=o?"path="+o:"path=/",document.cookie=e+"="+a+"; "+n+"; "+o,0==t&&(document.cookie=e+"="+a+"; "+n+"; "+o+";")}function sendIndicationBySpreadsheet(){iframe.contentWindow.postMessage({ref:"indicationsFromSpreadsheet",destinatarios:indications,email:!0},"*"),vex.close()}