const SWIPER_CONFIGURATION = { loop: true, autoplay: true, effect: 'fade', fadeEffect: { crossFade: true }, speed: 1500, }

function titleAnimation() {
    if ($(window).width() > 1024) {
        const updateBgLines = function() {
            const img = $('.swiper-title .swiper-wrapper .swiper-slide.swiper-slide-active .moving-shape img');
            const imgSrc = img.attr('src');
            const srcEnds = imgSrc.split('-').pop();
            $('.lines-title img').attr('src', '/storage/app/media/new-homepage/bg_lines_title_3.svg');
        }
        const swiperTitle = new Swiper(".swiper-title", {...SWIPER_CONFIGURATION,
            on: {
                init: function() {
                    $('.swiper-slide-active .article-content').addClass('active');
                    $('.lines-title').css("animation", "infinite-spinning 1s 0s 1 alternate backwards");
                    $('.animationDiv').addClass('slidingVertical');
                },
                transitionStart: function() {
                    $('.lines-title').css("animation", "none");
                    $('.article-content').removeClass('active');
                    setTimeout(() => { $('.lines-title').css("animation", "infinite-spinning 1s 0s 1 alternate backwards"); }, 20);
                    updateBgLines();
                },
                transitionEnd: function(swiper) {
                    $('.swiper-slide-active .article-content').addClass('active');
                    $('.lines-title').css("animation", "infinite-spinning 1s 0s 1 alternate backwards");
                }
            }
        });
        const swiperTitleText = new Swiper('.swiper-title-text', { direction: 'vertical', slidesPerView: 1, mousewheel: true, loop: true, autoplay: true, speed: 1500 });
    }
}
window.addEventListener('resize', function(event) { titleAnimation(); });
titleAnimation();
const swiper = new Swiper('.swiper', { direction: 'horizontal', lazy: true, effect: 'fade', fadeEffect: { crossFade: true }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, });
const swiperBlog = new Swiper('#blog-slider', { slidesPerView: 3, spaceBetween: 40, slidesPerGroup: 1, centeredSlides: false, navigation: { nextEl: '.button-next-blog', prevEl: '.button-prev-blog', }, breakpoints: { 250: { slidesPerView: 1, slidesPerGroup: 1, spaceBetweenSlides: 16 }, 750: { slidesPerView: 2, slidesPerGroup: 1, spaceBetweenSlides: 16 }, 1024: { slidesPerView: 3, spaceBetweenSlides: 40 } } });
const swiperFeedback = new Swiper('#feedback-slider', { slidesPerView: 1, spaceBetween: 55, pagination: { el: '.pagination-feed', }, navigation: { nextEl: '.button-next-feed', prevEl: '.button-prev-feed', }, });

$(window).scroll(function() {
    var scroll = $(window).scrollTop();
    if (scroll >= 300) {
        $(".mainHeader").addClass("fixedHeader");
    } else {
        $(".mainHeader").removeClass("fixedHeader");
    }
});