let lazyimages = [].slice.call(document.querySelectorAll("img.lazy")); if ("IntersectionObserver" in window) { let observer = new IntersectionObserver((entries, observer) => { entries.forEach(function(entry) { if (entry.isIntersecting) { let lazyimage = entry.target; lazyimage.src = lazyimage.dataset.src; lazyimage.srcset = lazyimage.dataset.srcset; lazyimage.classList.remove("lazy"); observer.unobserve(lazyimage); } }); }); lazyimages.forEach((lazyimage) => { observer.observe(lazyimage); }); } async function trialsignup(formId) { try { const form = document.getElementById(formId); const hiddenInput = document.querySelector('input[name="luid"]'); const formData = { name: form.os2.value + ' ' +form.os3.value, email: form.os0.value, password:form.os1.value, phone:form.os4.value, luid:hiddenInput.value }; const response = await fetch("/ajax.php?view=trialsignup&ajax=create", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(formData), }); if (!response.ok) { throw new Error("Network response was not ok"); } const { url } = await response.json(); window.location.href = url; } catch (error) { console.error("Error in createFreeTrial:", error); throw error; } } // Set the payment method and submit the form function setPaymentMethod(method,formId) { const paymentForm = document.getElementById(formId); console.log(formId); if (method === "paypal") { paymentForm.action = "https://www.paypal.com/cgi-bin/webscr"; } if (paymentForm.checkValidity()) { paymentForm.submit(); // Only submit if the form is valid } else { paymentForm.reportValidity(); // Show validation errors } } function showLoader(isLoading) { if (!isLoading) { document.getElementById("full-page-loader").style.display = "none"; } else { document.getElementById("full-page-loader").style.display = "flex"; } }