if("undefined"===typeof frmApiListener)var frmApiListener={trigger:function(type,data){var length,index;length=frmApiListener.callbacks[type].length;for(index=0;index<length;++index)frmApiListener.callbacks[type][index](data)},on:function(type,callback){frmApiListener.callbacks[type].push(callback)},callbacks:{scriptsLoaded:[]}};
(function(){var baseUrl,formId,url,script,xhr,params,backupAjaxUrl;baseUrl="https://www.frontpagemag.com";formId="2";url=baseUrl+"/wp-json/frm/v2/forms/"+formId+"?return=html";script=currentScript();xhr=new XMLHttpRequest;params={};if("object"===typeof frm_js&&"string"===typeof frm_js.ajax_url)backupAjaxUrl=frm_js.ajax_url;xhr.open("get",url,true);xhr.onreadystatechange=handleReadyStateChange;xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.send(params);function currentScript(){if(document.currentScript)return document.currentScript;return document.querySelector('script[src="https://www.frontpagemag.com/frm_embed/newsletter"]')}function handleReadyStateChange(){var response,form,initialScripts,delayedScripts;if(!requestIsSuccessful(xhr))return;response=JSON.parse(xhr.responseText);form=document.createElement("div");form.innerHTML=response.renderedHtml;initialScripts=[];delayedScripts=[];each(form.querySelectorAll("script"),function(current){if(-1!==["jquery-core-js",
"jquery-chosen-js","dropzone-js"].indexOf(current.id))initialScripts.push(current);else delayedScripts.push(current);if(current.parentNode)current.parentNode.removeChild(current)});function loadInitialScripts(){injectScripts(script,initialScripts,loadDelayedScripts)}function loadDelayedScripts(){fixjQueryDropzoneOrderIssues(initialScripts);injectScripts(script,delayedScripts,afterScriptsLoaded)}function afterScriptsLoaded(){frmApiListener.trigger("scriptsLoaded",{form:form.querySelector("form")});
restoreAjaxUrl()}function restoreAjaxUrl(){if("string"===typeof backupAjaxUrl)frm_js.ajax_url=backupAjaxUrl}loadInitialScripts();script.parentNode.insertBefore(form,script)}function injectScripts(embedScript,scripts,callback){var loaded=0;each(scripts,function(current){injectScript(embedScript,current,listenForScriptLoad)});function listenForScriptLoad(){if(++loaded===scripts.length)callback()}}function fixjQueryDropzoneOrderIssues(initialScripts){var foundjQuery,foundDropzone;each(initialScripts,
function(current){if("jquery-core-js"===current.id)foundjQuery=true;else if("dropzone-js"===current.id)foundDropzone=true});if(!foundjQuery||!foundDropzone||"undefined"!==typeof jQuery.fn.dropzone)return;jQuery.fn.dropzone=function(options){return this.each(function(){return new Dropzone(this,options)})}}function requestIsSuccessful(xhr){return xhr.readyState>3&&xhr.status==200&&xhr.responseText!==""}function injectScript(embedScript,scriptToInject,callback){var newScript,callbackWrapper;newScript=
document.createElement("script");newScript.id=scriptToInject.id;if("string"===typeof scriptToInject.id&&scriptToInject.id.length&&document.getElementById(scriptToInject.id)){callbackWrapper();return}if(scriptToInject.src){newScript.src=scriptToInject.src;newScript.addEventListener("load",callbackWrapper)}else callbackWrapper();newScript.innerHTML=scriptToInject.innerHTML;embedScript.parentNode.insertBefore(newScript,embedScript);function callbackWrapper(){if("function"===typeof callback)callback()}
}function each(items,callback){var index,length;length=items.length;for(index=0;index<length;index++)callback(items[index],index)}})();
