if (navigator.geolocation) {
    navigator.geolocation.watchPosition(function (position) {
        localStorage.setItem('lat', parseFloat(position.coords.latitude));
        localStorage.setItem('lng', parseFloat(position.coords.longitude));
    });
} else {
    alert('Geolocation is not supported by this browser')
}

function toasterError(error){
    // alert(error)
    toastr.options.closeButton = true;
    toastr.options.showMethod = 'slideDown';
    toastr.options.hideMethod = 'slideUp';
    toastr.options.closeMethod = 'slideUp';
    toastr.options.closeDuration = 200;
    toastr.options.showDuration = 200;
    toastr.options.preventDuplicates = true;
    toastr.options.progressBar = true;
    toastr.options.positionClass = "toast-top-right";
    toastr.options.newestOnTop = true;
    toastr.options.showEasing = 'swing';
    toastr.options.hideEasing = 'linear';
    toastr.error(error);
}
function toasterSuccess(success){
    toastr.options.closeButton = true;
    toastr.options.showMethod = 'slideDown';
    toastr.options.hideMethod = 'slideUp';
    toastr.options.closeMethod = 'slideUp';
    toastr.options.closeDuration = 200;
    toastr.options.showDuration = 200;
    toastr.options.preventDuplicates = true;
    toastr.options.progressBar = true;
    toastr.options.positionClass = "toast-top-right";
    toastr.options.newestOnTop = true;
    toastr.options.showEasing = 'swing';
    toastr.options.hideEasing = 'linear';
    toastr.success(success);
}

$(document).ready(function() {

    var wind = $(window);

    wow = new WOW({
        boxClass: 'wow',
        animateClass: 'animated',
        offset: 200,
        mobile: false,
        live: false
    });
    wow.init();


    // ------------ navbar -----------
    wind.on("scroll", function() {

        var bodyScroll = wind.scrollTop(),
            navbar = $(".nav_container")

        if (bodyScroll > 200) {

            navbar.addClass("nav_container_fixed");

        } else {

            navbar.removeClass("nav_container_fixed");
        }
    });




    // ---------- to top -----------
    $('.to-top').click(function() {
        $('html, body').animate({
            scrollTop: 0
        }, 1000);
        return false;
    });

    // -------- fav_icon ----------
    $(".fav_icon").on("click" , function(){
        $(this).toggleClass("active");
    })

    // search effect
$(".search_icon").on("click", function() {
    $(".searching").fadeIn(500);
})
$(".searching .close").on("click", function() {
    $(".searching").fadeOut(500);
})


    // -------- counter --------
        $('.counter').countUp({
            delay: 10,
            time: 2000
        });

});


// ------------ swiper sliders -----------
$(document).ready(function() {

    // ------------ head slider -----------
    var swiper = new Swiper('.head_slider .swiper-container', {
        speed: 1000,
        pagination: {
            el: 'header .swiper-pagination',
            type: 'fraction',
        },
        navigation: {
            nextEl: 'header .swiper_next',
            prevEl: 'header .swiper_prev',
        },
        mousewheel: false,
        keyboard: true,
        autoplay: {
            delay: 4000,
        },
        // loop: true,
    });

    // ------------- swiper products -------------
    var products_slider = new Swiper('.product_slider .swiper-container', {
        slidesPerView: 3,
        spaceBetween: 20,
        speed: 1000,
        pagination: false,
        navigation: {
            nextEl: '.product_slider .swiper-button-next',
            prevEl: '.product_slider .swiper-button-prev',
        },
        mousewheel: false,
        keyboard: true,
        autoplay: {
            delay: 2000,
        },
        loop: true,
        breakpoints: {
            0: {
                slidesPerView: 1,
            },
            480: {
                slidesPerView: 2,
            },
            787: {
                slidesPerView: 2,
            },
            991: {
                slidesPerView: 3,
            },
            1200: {
                slidesPerView: 3,
            }
        }
    });

    // ------------- swiper products -------------
    var products_slider = new Swiper('.partners_slider .swiper-container', {
        slidesPerView: 5,
        spaceBetween: 20,
        speed: 1000,
        pagination: {
            el: ".partners_slider .swiper-pagination",
            clickable: true,
        },
        navigation: false,
        mousewheel: false,
        keyboard: true,
        autoplay: {
            delay: 2000,
        },
        loop: true,
        breakpoints: {
            0: {
                slidesPerView: 1,
            },
            480: {
                slidesPerView: 2,
            },
            787: {
                slidesPerView: 2,
            },
            991: {
                slidesPerView: 4,
            },
            1200: {
                slidesPerView: 5,
            }
        }
    });
    
    var swiper = new Swiper('.consultation_slider .swiper-container', {
        slidesPerView: 3,
        spaceBetween: 20,
        speed: 1000,
        pagination: false,
        navigation: false,
        mousewheel: false,
        keyboard: true,
        autoplay: false,
        loop: false,
        breakpoints: {
            0: {
                slidesPerView: 1.4,
                centeredSlides: true,
                spaceBetween: 0,
            },
            480: {
                slidesPerView: 2,
                centeredSlides: true,
                spaceBetween: 0,
            },
            787: {
                slidesPerView: 2,
            },
            991: {
                slidesPerView: 2,
            },
            1200: {
                slidesPerView: 3,
            }
        }
    });
    
    var swiper = new Swiper('.documentation_slider .swiper-container', {
        slidesPerView: 2,
        spaceBetween: 20,
        speed: 1000,
        pagination: false,
        navigation: false,
        mousewheel: false,
        keyboard: true,
        autoplay: false,
        loop: false,
        breakpoints: {
            0: {
                slidesPerView: 1.4,
                centeredSlides: true,
                spaceBetween: 0,
            },
            480: {
                slidesPerView: 2,
                centeredSlides: true,
                spaceBetween: 0,
            },
            787: {
                slidesPerView: 2,
            },
            991: {
                slidesPerView: 2,
            },
            1200: {
                slidesPerView: 2,
            }
        }
    });

});

