var mpCurrentScriptmpFrmf3facc01b9f148fb816cb0e97f8ffa4eContainer = document.currentScript.parentNode; (function () { var containerDiv = document.createElement('div'); containerDiv.id = "mpFrmf3facc01b9f148fb816cb0e97f8ffa4e"; containerDiv.classList.add("mpForm"); containerDiv.setAttribute("data-mpid", "43719"); if (window.self !== window.top) { if (document.currentScript?.parentNode?.nodeName?.toLowerCase() === 'head') { if (document.body) { document.body.appendChild(containerDiv); } else { document.addEventListener('DOMContentLoaded', () => { document.body.appendChild(containerDiv); }); } } else { document.currentScript.parentNode.insertBefore(containerDiv, document.currentScript); } mpFormmpFrmf3facc01b9f148fb816cb0e97f8ffa4eFind(); } else if(document.currentScript && document.currentScript.parentNode && document.currentScript.parentNode.nodeName && document.currentScript.parentNode.nodeName.toLowerCase() === "head") { document.addEventListener("DOMContentLoaded", (event) => { var bodyHolder = document.getElementsByTagName("body"); if (bodyHolder && bodyHolder[0]) { bodyHolder[0].appendChild(containerDiv); } }) } else { document.currentScript.parentNode.insertBefore(containerDiv, document.currentScript); mpFormmpFrmf3facc01b9f148fb816cb0e97f8ffa4eFind(); } })(); function mpFormmpFrmf3facc01b9f148fb816cb0e97f8ffa4eFind() { if(!mpCurrentScriptmpFrmf3facc01b9f148fb816cb0e97f8ffa4eContainer) return; if (mpCurrentScriptmpFrmf3facc01b9f148fb816cb0e97f8ffa4eContainer && mpCurrentScriptmpFrmf3facc01b9f148fb816cb0e97f8ffa4eContainer.nodeName && mpCurrentScriptmpFrmf3facc01b9f148fb816cb0e97f8ffa4eContainer.nodeName.toLowerCase() === "head") { var mpFind = document.querySelectorAll("[data-mpid='43719']"); if (mpFind.length && !mpFind[0].innerHTML) { mpFind[0].id = "mpFrmf3facc01b9f148fb816cb0e97f8ffa4e" } } else { var mpFound = false; Array.from(mpCurrentScriptmpFrmf3facc01b9f148fb816cb0e97f8ffa4eContainer.children).forEach(c => { if (c.id === "mpFrmf3facc01b9f148fb816cb0e97f8ffa4e") mpFound = true; }) if (!mpFound) { var mpOthers = Array.from(mpCurrentScriptmpFrmf3facc01b9f148fb816cb0e97f8ffa4eContainer.children).filter(e => e.dataset && e.dataset.mpid === "43719"); if (mpOthers.length === 1) { mpOthers[0].id = "mpFrmf3facc01b9f148fb816cb0e97f8ffa4e"; } } } } function mpForm156e0146db79452e9fe4bba1d3c88ac1Check() { let checkBoxes = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('input[type="checkbox"]'); if(checkBoxes) { for(var i = 0; i < checkBoxes.length; i++) { let checkBox = checkBoxes[i]; var attr = checkBox.getAttribute('data-prevval'); if (typeof attr !== typeof undefined && attr !== false) { checkBox.value = checkBox.getAttribute("data-prevval"); checkBox.removeAttribute("data-prevval"); checkBox.removeAttribute("checked"); } } } } function mpForm156e0146db79452e9fe4bba1d3c88ac1Submit(event) { event.preventDefault(); let msgHlder = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelector('[id=mpmessageholder]'); let mpMsg = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelector('[id=mpmessage]'); let checkBoxes = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('input[type="checkbox"]'); if(checkBoxes) { for(var i = 0; i < checkBoxes.length; i++) { let checkBox = checkBoxes[i]; if( checkBox.checked == true ) { if(checkBox.getAttribute('data-prevval')) { checkBox.value = checkBox.getAttribute('data-prevval'); } else { checkBox.value = 1; } } else { checkBox.setAttribute('data-prevval',checkBox.value); checkBox.value = 0; } } } let form_data = Array.from( new FormData(document.getElementById('mpform-156e0146db79452e9fe4bba1d3c88ac1')), function(e) { return { name: e[0], value: e[1] } } ) try { for(var i = 0; i < checkBoxes.length; i++) { let checkBox = checkBoxes[i]; let found = form_data.find(f=>f.name == checkBox.name) if(!found) { form_data.push({name: checkBox.name, value: checkBox.checked ? checkBox.value : "0"}) } } } catch(err){} try { form_data.push({ name: "mpTrkH", value: document.location.host }) form_data.push({ name: "mpTrkO", value: document.location.origin }) form_data.push({ name: "mpTrkP", value: document.location.pathname }) form_data.push({ name: "mpTrkQ", value: document.location.search }) form_data.push({ name: "mpTrkUUID", value: getTrackingId156e0146db79452e9fe4bba1d3c88ac1() }) } catch(err){} //check valid telnos var failed = ""; if(msgHlder) { msgHlder.style.display = "none"; } let telInputs = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('input[type=TELNO]'); if(telInputs) { for(var i = 0; i < telInputs.length; i++) { let telInput = telInputs[i]; var iti = window.intlTelInputGlobals.getInstance(telInput); telInput.classList.remove("mpm-field-error"); if(iti.isValidNumber() == false && telInput.value && telInput.value.length) { telInput.classList.add("mpm-field-error"); failed = "Please enter a valid telephone number"; } else { let found = form_data.find(f=> f.name == telInput.name); if (found) { found.value = iti.getNumber(); // intenationally formatted version of the number } } } } if(failed != "") { mpMsg.innerHTML = failed; msgHlder.style.display = "block"; return; } let button = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelector('button'); if(button) { button.disabled = true; button.opacity = "0.5"; } mpMsg.innerHTML = 'Sending your details...'; var xhr = new XMLHttpRequest(); xhr.open("POST", "https://api.transpond.io/form?am=40895&fid=43719", true); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { mpForm156e0146db79452e9fe4bba1d3c88ac1Check(); button.disabled = false; button.style.opacity = "1"; mpMsg.innerHTML = ""; msgHlder.style.display = "block"; let response = JSON.parse(xhr.responseText); if (!response || (!response.download && !response.downloads)) { try { document.getElementById('mpform-156e0146db79452e9fe4bba1d3c88ac1').reset(); } catch(e) {} } if(response) { if (response.redirect) { window.location.href = response.redirect; } else if (response.message) { if (response.download) window.open(response.download, '_blank'); if (response.downloads && response.downloads.length) { const parent = button.parentElement; response.downloads.forEach(link => { const hiddenButton = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelector("a[href='" + link.replace + "']"); if (hiddenButton) { hiddenButton.href = link.link; hiddenButton.closest('[data-type="FORMFILE"]').style.display = 'flex'; } }); parent.style.display = "none"; } if(response.hideForm){ let mpMsgParent = msgHlder.parentElement; if(mpMsgParent && msgHlder){ mpMsg.innerHTML = response.message; mpMsgParent.innerHTML = msgHlder.innerHTML; } } else { mpMsg.innerHTML = response.message; } } else if (response.replace) { document.getElementById('mpform-156e0146db79452e9fe4bba1d3c88ac1').innerHTML = response.form } } } else { mpForm156e0146db79452e9fe4bba1d3c88ac1Check(); button.disabled = false; button.style.opacity = "1"; mpMsg.innerHTML = ""; msgHlder.style.display = "block"; var error = "Error submitting form"; if (xhr.responseText) { const errorJson = JSON.parse(xhr.responseText); if(errorJson.error && typeof errorJson.error === 'string') { error = errorJson.error; } } mpMsg.innerHTML = error; } }; let urlEncodedDataPairs = []; form_data.forEach((m, i) => { let name = m.name; if (name === 'capsule_note') { name += '_' + i; } urlEncodedDataPairs.push(encodeURIComponent(name)+ "=" + encodeURIComponent(m.value)); }); const urlEncodedData = urlEncodedDataPairs.join('&').replace(/%20/g, '+'); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send(urlEncodedData); return; } function getTrackingId156e0146db79452e9fe4bba1d3c88ac1() { try { let uuid = document.cookie.match('(^|;)\s*mpz\s*=\s*([^;]+)')?.pop() || ''; if(!uuid) { let found = document.cookie.split(';').find(c => c.indexOf('mpz=') > -1); if (found) uuid = found.split('=')[1]; } return uuid; } catch(e) { } }; function mpmFormInit156e0146db79452e9fe4bba1d3c88ac1 () { var subscriberData = undefined; var form = '

Please select the Marketing Permission Check Box below if you would like to hear the latest news, including offers and updates from Ascot Headshots.

You can unsubscribe anytime by clicking the link in the footer of our emails.

Marketing Permission
'; let failedCount = 0 function finishedLoading156e0146db79452e9fe4bba1d3c88ac1() { window.mpFormLoading = false; let container = document.getElementById('mpFrmf3facc01b9f148fb816cb0e97f8ffa4e'); if (!container) { mpFormmpFrmf3facc01b9f148fb816cb0e97f8ffa4eFind(); failedCount++; if(failedCount > 10) return console.log('Form failed too many times mpFrmf3facc01b9f148fb816cb0e97f8ffa4e'); return setTimeout(finishedLoading156e0146db79452e9fe4bba1d3c88ac1, 300) } container.innerHTML = form; let containerChildren = container.childNodes; let msgHlder = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelector('[id=mpmessageholder]'); if(msgHlder) { msgHlder.style.display = "none" } let telInputs = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('input[type=TELNO]'); if(telInputs) { let telInputCSSOver = ""; for(var i = 0; i < telInputs.length; i++) { let telInp = telInputs[i]; telInp.style.width = "100%"; telInp.style.paddingLeft = "50px"; window.intlTelInput(telInp, { initialCountry: "us", utilsScript: "https://cdn1.ourmailsender.com/scripts/telinput/utils.js", customContainer: "mpm-tel-input-container-156e0146db79452e9fe4bba1d3c88ac1-" + i } ); let tmpMargin = ""; if(telInp.style.margin) { tmpMargin = telInp.style.margin; telInputCSSOver += ".mpm-tel-input-container-156e0146db79452e9fe4bba1d3c88ac1-" + i + " { margin: " + tmpMargin + " } " } } if(telInputCSSOver) { let style = document.createElement("style"); style.innerHTML = telInputCSSOver; document.getElementsByTagName("head")[0].appendChild(style); } } if(subscriberData) { let customFields = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('input[name*="customField-"]') if(customFields) { var processedRadioNames = {}; for(var i = 0; i < customFields.length; i++) { let customField = customFields[i]; var cfID = customField.name; if(cfID) { cfID = cfID.split("-")[1]; let newValue = ""; if(subscriberData.customFields[cfID]) newValue = subscriberData.customFields[cfID]; if (customField.type === 'radio') { if (!processedRadioNames[customField.name]) { processedRadioNames[customField.name] = true; if (newValue !== "") { var radioGroup = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('input[type="radio"][name="' + customField.name + '"]'); for (var j = 0; j < radioGroup.length; j++) { radioGroup[j].checked = radioGroup[j].getAttribute('value') == newValue; } } } } else if (customField.type === 'checkbox') { customField.checked = newValue === true || newValue === 'true' || newValue === '1' || newValue === 1; } else { customField.value = newValue; } } } } let customFieldsTextArea = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('textarea[name*="customField-"]') if(customFieldsTextArea) { for(var i = 0; i < customFieldsTextArea.length; i++) { let customField = customFieldsTextArea[i]; var cfID = customField.name; if(cfID) { cfID = cfID.split("-")[1]; let newValue = ""; if(subscriberData.customFields[cfID]) newValue = subscriberData.customFields[cfID]; customField.value = newValue; } } } let customFieldsSelect = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('select[name*="customField-"]') if(customFieldsSelect) { for(var i = 0; i < customFieldsSelect.length; i++) { let customField = customFieldsSelect[i]; var cfID = customField.name; if(cfID) { cfID = cfID.split("-")[1]; var newValue = subscriberData.customFields[cfID]; if (newValue === undefined || newValue === null || newValue === '') continue; if (customField.multiple && Array.isArray(newValue)) { for (var j = 0; j < customField.options.length; j++) { customField.options[j].selected = newValue.indexOf(customField.options[j].value) > -1; } } else { customField.value = newValue; } } } } let emailAddressFields = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").querySelectorAll('input[name$="emailAddress"]') if(emailAddressFields) { for(var i = 0; i < emailAddressFields.length; i++) { let emailAddressField = emailAddressFields[i]; emailAddressField.value = subscriberData.emailAddress; } } } } function mpmPopup156e0146db79452e9fe4bba1d3c88ac1() { let popups = document.getElementById("mpform-156e0146db79452e9fe4bba1d3c88ac1").getElementsByClassName("mpm-popup"); if(popups) { for(var i = 0; i < popups.length; i++) { let popup = popups[i]; popup.classList.toggle("show"); } } } function mploadTelInput156e0146db79452e9fe4bba1d3c88ac1() { if(!window.intlTelInput) { var script = document.createElement("SCRIPT"); script.src = 'https://cdn1.ourmailsender.com/scripts/telinput/intlTelInput.min.js'; script.type = 'text/javascript'; script.onload = function () { finishedLoading156e0146db79452e9fe4bba1d3c88ac1(); }; document.getElementsByTagName("head")[0].appendChild(script); } else { finishedLoading156e0146db79452e9fe4bba1d3c88ac1(); } } var link = document.createElement("link"); link.href = "https://api.transpond.io/public/css/form.css"; link.type = "text/css"; link.rel = "stylesheet"; document.getElementsByTagName("head")[0].appendChild(link); var mTelI = document.createElement("link"); mTelI.href = "https://cdn1.ourmailsender.com/scripts/telinput/intlTelInput.min.css"; mTelI.type = "text/css"; mTelI.rel = "stylesheet"; document.getElementsByTagName("head")[0].appendChild(mTelI); mploadTelInput156e0146db79452e9fe4bba1d3c88ac1(); } if(!window.mpFormLoading){ window.mpFormLoading = true; mpmFormInit156e0146db79452e9fe4bba1d3c88ac1(); } else { function waitForOtherFormsmpFrmf3facc01b9f148fb816cb0e97f8ffa4e() { if(window.mpFormLoading == false) { console.log("Form Loaded"); mpmFormInit156e0146db79452e9fe4bba1d3c88ac1(); } else { setTimeout(waitForOtherFormsmpFrmf3facc01b9f148fb816cb0e97f8ffa4e,300); } } waitForOtherFormsmpFrmf3facc01b9f148fb816cb0e97f8ffa4e(); }