(($) => {
  // * GOLD CALCULATOR *
  // CLOSE FUNCTION
  function closePopup() {
    const goldPopup = $(".book-gold-popup");
    $("body").removeClass("popup");
    $(".shadow").fadeOut();
    goldPopup.fadeOut();
  }
  // TRIGGER OPEN
  $(".lingotto-teaser").each(function calculatePrice() {
    const $this = $(this);
    const _id = $this.attr("id");
    const popup = $(`.book-gold-popup[id="gold-popup-${_id}"]`);
    $this.find("a").on("click", (e) => {
      e.preventDefault();
      $("body").addClass("popup");
      $(".shadow").fadeIn();
      popup.fadeIn();
    });
  });
  // TRIGGER CLOSE
  $(".shadow, .close-overlay").on("click", closePopup);
})(jQuery);
