 jQuery(document).ready(function($) {
$('.count').counterUp({
    delay: 10,
    time: 3000
  })
    // Initialize Slick Slider

    if (jQuery('#featured-slider .section-content').length) {
      jQuery('#featured-slider .section-content').slick({
            responsive: [
                {
                    breakpoint: 1200,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                    }
                },
                {
                    breakpoint: 992,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                    }
                },
                {
                    breakpoint: 767,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                    }
                }
            ]
        });
    }
    // Match Height
    if ($('.blog-posts-wrapper .post-item').length) {
        $('.blog-posts-wrapper .post-item').matchHeight();
    }

    // Initialize color picker
    if ($('.my-color-field').length) {
        $('.my-color-field').wpColorPicker();
    }
});


const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // Example email regex

function searchEmail() {
  const email = document.getElementById("email").value;
  const error = document.getElementById("error");
  const success = document.getElementById("success"); 

  if (emailRegex.test(email)) {
    success.textContent = "Thank you for Subscription!";
    success.style.display = "block"; 
    success.style.opacity = 1; 

    setTimeout(function() {
      success.style.opacity = 0;
      setTimeout(function() {
        success.style.display = "none";
      }, 300);
    }, 3000);
  } else {
    error.textContent = "Invalid email";
    error.style.display = "block";
    error.style.opacity = 1;

    setTimeout(function() {
      error.style.opacity = 0;
      setTimeout(function() {
        error.style.display = "none";
      }, 300);
    }, 3000);
  }
}



jQuery(document).ready(function($) {
    // Open search form
    $('#formButton').on('click', function () {
        $('#form1').fadeIn();
    });

    // Close search form
    $('#closeForm').on('click', function () {
        $('#form1').fadeOut();
    });
});



// About
document.addEventListener('DOMContentLoaded', function () {
    const videoPopBtn = document.getElementById('video-pop');
    const popup = document.getElementById('popup');
    const closeBtn = document.getElementById('closePopup');

    if (videoPopBtn && popup && closeBtn) {
        videoPopBtn.addEventListener('click', function () {
            popup.classList.add('show');
        });

        closeBtn.addEventListener('click', function () {
            popup.classList.remove('show');
            const iframe = popup.querySelector('iframe');
            if (iframe) {
                // Stop the video
                iframe.src = iframe.src;
            }
        });
    }
});