function embedGrowform() { var embedType = "iFrame"; var iFrameHeight = embedType == "modal" ? "100%" : "350px"; var iframeScrollingProperty = embedType == "modal" ? " " : " scrolling='no' "; var growformEmbedId = "embed-" + Math.floor(Math.random() * 100000).toString(); let u = 'https://embed.growform.co/go/[acf field='field_64b697a1487cf']/templateDemoFormEmbedMethod/iFrame/' + growformEmbedId; if(window.location.search) { u = u + window.location.search } document.write(""); window.growform = window.growform || {}; if (typeof window.growform.setHiddenField !== "function") { window.growform.setHiddenField = function(fieldName, value) { var growformIframes = document.getElementsByClassName('growform_form'); for (var i = 0; i < growformIframes.length; i++) { growformIframes[i].contentWindow.postMessage({ action: "growform_set_hidden_field", fieldName: fieldName, value: value }, "*"); } } } window.addEventListener("message", growform_receiveMessage, false); function growform_receiveMessage(event) { if(!event || !event.data || !event.data.action) { return; } if(event.data.growform_embed_id !== growformEmbedId) { return; } if (event.data.action == "growform_resize_height") { growform_resizeHeight(event.data.height, event.data.growform_embed_id); } if (event.data.action == "growform_submit_form") { growform_fireSubmission(event.data.customScript, event.data.growform_embed_id); } if (event.data.action == "growform_add_parent_gtm_container") { growform_addParentGTMContainer(event.data.containerId, event.data.analyticsSettings, event.data.growform_embed_id); } if(event.data.action == "growform_scroll_to_top") { growform_scrollToTop(event, event.data.growform_embed_id); } if (event.data.action == "growform_form_loaded") { var newEvent = new Event('growform_loaded'); window.dispatchEvent(newEvent); } } function growform_resizeHeight(height, growform_embed_id) { var height = parseInt(height); var targetClass = "growform_form_" + growform_embed_id; height = Math.round(height) + 16; height = height + "px"; document.getElementsByClassName(targetClass)[0].style.height = height; } function growform_scrollToTop(event, growform_embed_id) { var targetClass = "growform_form_" + growform_embed_id; var formRect = document.getElementsByClassName(targetClass)[0].getBoundingClientRect(); var relativeFormYPosition = formRect.top; var absoluteFormYPosition = relativeFormYPosition + window.scrollY; var windowHeight = window.innerHeight || document.documentElement.clientHeight; if(relativeFormYPosition < 0 || relativeFormYPosition > windowHeight) { var offset = event.data.offset ? event.data.offset : 0; var scrollToX = absoluteFormYPosition + offset; window.setTimeout(function() { window.scrollTo({ top: scrollToX, behavior: "smooth" }); }, 100); }}; function growform_addParentGTMContainer(containerId, analyticsSettings, growform_embed_id) { eval( (function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f); })(window, document, "script", "dataLayer", containerId) ); window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: "growformAnalyticsSettings", growformAnalyticsSettings: analyticsSettings, growformEmbedId: growform_embed_id })}; function growform_fireSubmission(customScript, growform_embed_id) { var elementId = "growform_CustomScriptPageDiv_" + growform_embed_id; var existingScript = document.getElementById(elementId); if (!existingScript) { var growformCustomScriptPageDiv = document.createElement(elementId); document.body.appendChild(growformCustomScriptPageDiv); growformCustomScriptPageDiv.innerHTML = customScript; var scripts = growformCustomScriptPageDiv.getElementsByTagName("script"); for (var i = 0; i < scripts.length; i++) { eval(scripts[i].innerText); } }} } embedGrowform();