$(function(){
    let c = document.getElementById('warp').scrollWidth
    
    if (c > 850) {
        $(".carousel-el").flickity({
            // contain: true,
            pageDots: false,
            cellAlign: 'left',
            // wrapAround:true,
            groupCells: 4,
        });
    } else {
        $(".carousel-el").flickity({
            // contain: true,
            pageDots: false,
            cellAlign: 'left',
            // wrapAround:true,
            groupCells: 2,
        });
    }
    if (c > 850) {
        $(".carousel-el-tel6").flickity({
              // contain: true,
              pageDots: false,
              cellAlign: 'left',
              wrapAround:false,
              groupCells: 6,
        });
    } else {
        $(".carousel-el-tel6").flickity({
            // contain: true,
            pageDots: false,
            cellAlign: 'left',
            wrapAround:false,
            groupCells: 2,
        });
    }
    window.addEventListener('resize', function () {
        let c = document.getElementById('warp').scrollWidth

        if (c > 850) {
            $(".carousel-el").flickity({
                // contain: true,
                pageDots: false,
                cellAlign: 'left',
                // wrapAround:false,
                groupCells: 4,
            });
        } else {
            $(".carousel-el").flickity({
                // contain: true,
                pageDots: false,
                cellAlign: 'left',
                wrapAround:false,
                groupCells: 2,
            });
        }
    });


    window.addEventListener('scroll', function () {
        var scrollPosition = window.scrollY || window.pageYOffset;
        function isElementInViewport(el) {
            var rect = el.getBoundingClientRect();
            return (
                rect.top >= 0 &&
                rect.left >= 0 &&
                rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
                rect.right <= (window.innerWidth || document.documentElement.clientWidth)
            );
        }  
    
        var element = document.getElementById("yourElementId");
        var q=document.getElementById('model_show')
        if (isElementInViewport(element)) {
            q.classList.remove("small_show_box");
        } else {
            q.classList.add("small_show_box");
           
        }
    }); 
})