﻿$(document).ready(function () {
    $(document).ready(function () {
        $('.bxslider').bxSlider(
            {

                mode: 'fade',
                auto: false,
                controls: true,
                pager: false,
                speed: 2500,
                pause: 5000

            });
    });


});



$('.owl1').owlCarousel({
    loop: false,
    margin: 15,

    video: true,
    nav: true,
    lazyLoad: true,
    responsiveClass: true,
    autoHeight: true,
    autoplayTimeout: 7000,
    smartSpeed: 800,
    responsive: {
        0: {
            items: 2
        },
        480: {
            items: 2
        },
        560: {
            items: 2
        },
        790: {
            items: 4
        },
        990: {
            items: 4
        },
        1100: {
            items: 5
        },
        1500: {
            items: 5
        }
    }
})
$('.owl2').owlCarousel({
    loop: false,
    margin: 15,

    video: true,
    nav: true,
    lazyLoad: true,
    responsiveClass: true,
    autoHeight: true,
    autoplayTimeout: 5000,
    autoplay: true,
    smartSpeed: 800,
    responsive: {
        0: {
            items: 3
        },
        480: {
            items: 3
        },
        560: {
            items: 3
        },
        790: {
            items: 4
        },
        990: {
            items: 4
        },
        1100: {
            items: 5
        },
        1500: {
            items: 5
        }
    }
})
$('.owl3').owlCarousel({
    loop: false,
    margin: 15,

    video: true,
    nav: true,
    lazyLoad: true,
    responsiveClass: true,
    autoHeight: true,
    autoplayTimeout: 7000,
    smartSpeed: 800,
    responsive: {
        0: {
            items: 1
        },
        480: {
            items: 1
        },
        560: {
            items: 2
        },
        790: {
            items: 3
        },
        990: {
            items: 3
        },
        1100: {
            items: 3
        },
        1500: {
            items: 3
        }
    }
})

function SetHeight(kind) {
    if (kind == "allgroup") {
        var maxHeight = 0;

        jQuery(".ms_box_group").each(function () {
            var thisH = jQuery(this).height();
            if (thisH > maxHeight) { maxHeight = thisH; }
        });

        jQuery(".ms_box_group").height(maxHeight);
    }
    else if (kind == "allgroup") {
        var maxHeight2 = 0;

        jQuery(".ms_box_product").each(function () {
            var thisH = jQuery(this).height();
            if (thisH > maxHeight) { maxHeight2 = thisH; }
        });

        jQuery(".ms_box_product").height(maxHeight2);
    }
}
jQuery(window).load(function () {
    //  SetHeight("allgroup");
    // SetHeight("allproduct");
});

jQuery(window).resize(function () {
    // SetHeight("allproduct");
    //  SetHeight("allgroup");
});

document.addEventListener("DOMContentLoaded", function () {
    var lazyloadImages = document.querySelectorAll("img.lazy");
    var lazyloadThrottleTimeout;

    function lazyload() {
        if (lazyloadThrottleTimeout) {
            clearTimeout(lazyloadThrottleTimeout);
        }

        lazyloadThrottleTimeout = setTimeout(function () {
            var scrollTop = window.pageYOffset;
            lazyloadImages.forEach(function (img) {
                if (img.offsetTop < (window.innerHeight + scrollTop)) {
                    img.src = img.dataset.src;
                    img.classList.remove('lazy');
                }
            });
            if (lazyloadImages.length == 0) {
                document.removeEventListener("scroll", lazyload);
                window.removeEventListener("resize", lazyload);
                window.removeEventListener("orientationChange", lazyload);
            }
        }, 20);
    }

    document.addEventListener("scroll", lazyload);
    window.addEventListener("resize", lazyload);
    window.addEventListener("orientationChange", lazyload);
});