(function() {
var debug = 0;
var variation_name = "";
if (window.location.href.indexOf('qa-debug=true') > -1) {
debug = 1;
}
try {
function waitForElement(selector, trigger, delayInterval, delayTimeout) {
var interval = setInterval(function() {
if (
document &&
document.querySelector(selector) &&
document.querySelectorAll(selector).length > 0
) {
clearInterval(interval);
trigger();
}
}, delayInterval);
setTimeout(function() {
clearInterval(interval);
}, delayTimeout);
}
var NewForm = '<div class="eg-new-hero-continer"><div class="eg-form-continer"></div></div>';
function EgForm() {
if (!document.querySelector('.eg-new-hero-continer .s-hero__in')) {
var HeroContent = document.querySelector('.s-hero__in');
document.querySelector('.eg-new-hero-continer').insertAdjacentElement('afterbegin', HeroContent);
}
if (!document.querySelector(" .eg-form-continer .s-startup__form-wrap")) {
var OldForm = document.querySelector(".s-startup__form-wrap");
document.querySelector('.eg-form-continer').insertAdjacentElement('afterbegin', OldForm);
}
}
function WhyLunchpad() {
// if(!document.querySelector(".eg-new-hero-continer .s-hero__btn-wrap")){
var WhyLunchpadCTA = document.querySelector(".s-hero__btn-wrap");
document.querySelector(' .s-hero__in >.s-hero__text').insertAdjacentElement('afterend', WhyLunchpadCTA);
// }
}
function init() {
if (debug) {
console.log('Inside init Function');
}
if (!document.querySelector('.eg-new-hero-continer')) {
document.querySelector('.s-hero__logo-block-wrap').insertAdjacentHTML('beforebegin', NewForm);
}
waitForElement(".eg-new-hero-continer ", EgForm, 50, 15000);
waitForElement(".eg-new-hero-continer .s-hero__text", WhyLunchpad, 50, 15000);
}
function FormRelocation() {
// var EGForm = document.querySelector(".l-section.s-startup .s-success-stories ").offsetHeight;
var EGForm =window.pageYOffset + document.querySelector(".l-section.s-startup .s-success-stories ").getBoundingClientRect().top;
window.addEventListener("scroll", function() {
if (window.scrollY <= EGForm) {
if (!document.querySelector(" .eg-form-continer .s-startup__form-wrap")) {
var OldForm = document.querySelector(".s-startup__form-wrap");
document.querySelector('.eg-form-continer').insertAdjacentElement('afterbegin', OldForm);
}
} else if (window.scrollY > EGForm) {
if (!document.querySelector(" .s-startup__form-row .s-startup__form-wrap")) {
var OldForm = document.querySelector(".s-startup__form-wrap");
document.querySelector('.s-startup__form-row ').insertAdjacentElement('afterbegin', OldForm);
}
}
})
}
waitForElement(".s-hero__logo-block-wrap", init, 50, 15000);
waitForElement(".s-startup__form-row .s-startup__form-wrap", FormRelocation, 50, 25000);
} catch (e) {
if (debug) console.log(e, "error in Test" + variation_name);
}
})();