$('.benefit-slider').slick({
    infinite: false,
    speed: 300,
    dots: false,
    slidesToShow: 3,
    slidesToScroll: 1,
    arrows: true,
    responsive: [
        {
            breakpoint: 1024,
            settings: {
                slidesToShow: 3,
                slidesToScroll: 3,
                infinite: true,
            }
        },
        {
            breakpoint: 900,
            settings: {
                slidesToShow: 1,
                slidesToScroll: 1
            }
        }
    ]
});


var hashTagActive = "";
$(".topMenu a").on("click touchstart" , function (event) {
    if(hashTagActive != this.hash) {
        event.preventDefault();
        var dest = 0;
        if ($(this.hash).offset().top > $(document).height() - $(window).height()) {
            dest = $(document).height() - $(window).height();
        } else {
            dest = $(this.hash).offset().top;
        }
        $('html,body').animate({
            scrollTop: dest
        }, 800, 'swing');
        hashTagActive = this.hash;
    }
});



$(document).ready(
    function() {
        $(".tabheader").each(
            function() {
                var header = $(this);
                header.find("ul li").click(
                    function() {
                        $(this).find("a").addClass('focus').closest("li").siblings().find("a").removeClass('focus');
                        header.next(".tabcontent").find("ul").eq($(this).index()).show().siblings().hide();
                    }
                )
            }
        )
    }
);


document.getElementById('shareIcon').onclick = function(){
    document.getElementsByClassName('shareAccordion')[0].classList.toggle("active");
    document.getElementsByClassName('footerLink')[0].classList.toggle("active");
};

$(".top p").text(function () {
    return $(this).text().replace("*", "<div>").replace("*", "</div>");
});


window.addEventListener('scroll', function() {
    const stickyHeader = document.querySelector('.stickyHeader');
    const subTitle = document.querySelector('.subTitle');
    
    const subTitleVisible = (subTitle.getBoundingClientRect().bottom + window.pageYOffset) >= window.pageYOffset;
  
    if (!subTitleVisible) {
      stickyHeader.classList.add('active');
    } else {
      stickyHeader.classList.remove('active');
    }
  });
  


// $('.top p').each(function() {
//     const text = $(this).text();
//     $(this).text(text.replace('*', '<div>'));
// });

