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);
      }
    });
  }
})

jQuery(function($) {
  function checkScroll() {
    if ($(window).scrollTop() >= 100) {
      $('header#masthead').addClass('fixed');
    } else {
      $('header#masthead').removeClass('fixed');
    }
  }

  $(window).scroll(checkScroll);

  checkScroll();
});

jQuery(document).ready(function ($) {
  $('.elementor-tab-title').on('click', function (e) {
      e.preventDefault();

      const $clickedTitle = $(this);
      const tabId = $clickedTitle.data('tab');

      const $content = $('.elementor-tab-content[data-tab="' + tabId + '"]');

      $('.elementor-tab-content')
          .not($content)
          .slideUp(300)
          .prev('.elementor-tab-title')
          .attr('aria-expanded', 'false')
          .find('.elementor-accordion-icon-opened').hide()
          .siblings('.elementor-accordion-icon-closed').show();

      if ($clickedTitle.attr('aria-expanded') === 'true') {
          $clickedTitle.attr('aria-expanded', 'false');
          $content.slideUp(300);
          $clickedTitle.find('.elementor-accordion-icon-opened').hide();
          $clickedTitle.find('.elementor-accordion-icon-closed').show();
      } else {
          $clickedTitle.attr('aria-expanded', 'true');
          $content.slideDown(300);
          $clickedTitle.find('.elementor-accordion-icon-closed').hide();
          $clickedTitle.find('.elementor-accordion-icon-opened').show();
      }
  });
});