/* Footer Form*/
var waitForIt = setInterval(function () {
    if (document.querySelectorAll("#webform-submission-find-offers-block-content-10-add-form #edit-actions-submit--3").length > 0) {
      //Change value of button if user entered info into address/zip field 
      var button = document.querySelector("#webform-submission-find-offers-block-content-10-add-form #edit-actions-submit--3");
      button.addEventListener("click", function (evnt) {
        if (document.querySelector("#webform-submission-find-offers-block-content-10-add-form #edit-add1--3").value != "" && document.querySelector("#webform-submission-find-offers-block-content-10-add-form #edit-zip--3").value != "") {
          button.setAttribute("value", "Loading..");
          if(evnt.ctrlKey || evnt.shiftKey || evnt.metaKey || (evnt.button && evnt.button == 1)){
            setTimeout(function(){
              button.setAttribute("value", "Get offers");
            },10000);
          }
        }
      });

      // Reset field is user clicks the back button from buyflow
      window.onpagehide = function (event) {
        button.setAttribute("value", "Get offers");
      }
      clearInterval(waitForIt)
    }
  }, 400)

/* Mobile Form */
  var waitForIt2 = setInterval(function (event) {
    if (document.querySelectorAll("#edit-actions-submit--2").length > 0) {
      //Change value of button if user entered info into address/zip field 
      var button2 = document.getElementById("edit-actions-submit--2");
      button2.addEventListener("click", function (evnt) {
        if (document.getElementById("edit-add1--2").value != "" && document.getElementById("edit-zip--2").value != "") {
          button2.setAttribute("value", "Loading..");
          if(evnt.ctrlKey || evnt.shiftKey || evnt.metaKey || (evnt.button && evnt.button == 1)){
            setTimeout(function(){
              button2.setAttribute("value", "Get offers");
            },10000);
          }
        }
      });

      // Reset field is user clicks the back button from buyflow
      window.onpagehide = function (event) {
        button2.setAttribute("value", "Get offers");
      }
      clearInterval(waitForIt2)
    }
  }, 400)
  
  /* Header Form*/
var waitForIt = setInterval(function () {
    if (document.querySelectorAll("#webform-submission-find-offers-block-content-51-add-form #edit-actions-submit--2").length > 0) {
      //Change value of button if user entered info into address/zip field 
      var button = document.querySelector("#webform-submission-find-offers-block-content-51-add-form #edit-actions-submit--2");
      button.addEventListener("click", function (evnt) {
        if (document.querySelector("#webform-submission-find-offers-block-content-51-add-form #edit-add1--2").value != "" && document.querySelector("#webform-submission-find-offers-block-content-51-add-form #edit-zip--2").value != "") {
          button.setAttribute("value", "Loading..");
          if(evnt.ctrlKey || evnt.shiftKey || evnt.metaKey || (evnt.button && evnt.button == 1)){
            setTimeout(function(){
              button.setAttribute("value", "Get offers");
            },10000);
          }
        }
      });

      // Reset field is user clicks the back button from buyflow
      window.onpagehide = function (event) {
        button.setAttribute("value", "Get offers");
      }
      clearInterval(waitForIt)
    }
  }, 400)

var waitForIt = setInterval(function () {
    if (document.querySelectorAll("#webform-submission-find-offers-block-content-51-add-form #edit-actions-submit").length > 0) {
      //Change value of button if user entered info into address/zip field 
      var button = document.querySelector("#webform-submission-find-offers-block-content-51-add-form #edit-actions-submit");
      button.addEventListener("click", function (evnt) {
        if (document.querySelector("#webform-submission-find-offers-block-content-51-add-form #edit-add1").value != "" && document.querySelector("#webform-submission-find-offers-block-content-51-add-form #edit-zip").value != "") {
          button.setAttribute("value", "Loading..");
          if(evnt.ctrlKey || evnt.shiftKey || evnt.metaKey || (evnt.button && evnt.button == 1)){
            setTimeout(function(){
              button.setAttribute("value", "Get offers");
            },10000);
          }
        }
      });

      // Reset field is user clicks the back button from buyflow
      window.onpagehide = function (event) {
        button.setAttribute("value", "Get offers");
      }
      clearInterval(waitForIt)
    }
  }, 400)
  



