jQuery(function($) {
  $(".header-email-handler").on("click", function() {
    getEmail(function(response) {
      $(".header-email-handler").html(response);
    });
  });

  $("#footer-email").on("click", function() {
    getEmail(function(response) {
      $("#footer-email").html(response);
    });
  });

  $("#contact-email").on("click", function() {
    getEmail(function(response) {
      $("#contact-email").html(response);
    });
  });

  $(".big-form-email").on("click", function() {
    getEmail(function(response) {
      $(".big-form-email").html(response);
    });
  });

  function getEmail(callback) {
    $.ajax({
      url: "/secret-email.php",
      type: "GET",
      dataType: "json",
      success: function(response) {
        callback(response)
      },
      error: function(xhr, status, error) {
          console.error(error);
      }
    });
  }
})