function stickyHeader() {
    if ($("header").length) {
        var Header = 100;
        if ($(window).scrollTop() > Header) {
            $("header").addClass("stricky_fixed")
        } else {
            if ($(this).scrollTop() <= Header) {
                $("header").removeClass("stricky_fixed")
            }
        }
    }
}
jQuery(window).on("scroll", function () {
    (function (Header) {
        stickyHeader()
    })(jQuery)
});

if ($(".navigation").length) {
    $(".navigation .navbar button").on("click", function () {
            $(".navigation .menu").slideToggle();
            $(this).toggleClass('open');
            return false
        });
    $(".navigation .cs-submenu").children("a").append(function () {
            return '<button class="dropdown-expander"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg></button>'
        });
   
}
if (document.documentElement.clientWidth < 1023) {    
    $(".navigation .menu .dropdown-expander").on("click", function () {
            $(this).parent().parent().children(".cs-dropdown").slideToggle();
            console.log($(this).parents("li"));
            console.log($(this).parents().children(".dropdown-expander").toggleClass("rotated"));
            return false
        })
    $(document).click(function (e) {
        if (!$(e.target).closest('.navigation .navbar button').length) {
            $('.menu').stop(true).slideUp();
            $(".navigation .navbar button").removeClass('open');
            
        }
    }); 

}

 function openSearch() {
    document.getElementById("myOverlay").style.display = "block";
}
function closeSearch() {
    document.getElementById("myOverlay").style.display = "none"; 
}

$("#HMslider, #MBslider").slick({
    dots: true,
    infinite: true,
    autoplay: true,
    speed:300,
    arrows: false,
    slidesToShow: 1,
    slidesToScroll: 1,
    responsive: [{
        breakpoint: 1024,
        settings: {
            slidesToShow: 1,
            slidesToScroll: 1,
            infinite: true,
            dots: true
        }
    }, {
        breakpoint: 600,
        settings: {
            slidesToShow: 1,
            slidesToScroll: 1
        }
    }, {
        breakpoint: 480,
        settings: {
            slidesToShow: 1,
            slidesToScroll: 1
        }
    }]
});



$("#NoiseDiariesslider").slick({
    dots: true,
    infinite: true,
    autoplay: true,
    speed:300,
    arrows: false,
    slidesToShow: 4,
    slidesToScroll: 1,
    responsive: [{
        breakpoint: 1024,
        settings: {
            slidesToShow: 2,
            slidesToScroll: 1,
            infinite: true,
            dots: true
        }
    }, {
        breakpoint: 600,
        settings: {
            slidesToShow: 2,
            slidesToScroll: 1
        }
    }, {
        breakpoint: 480,
        settings: {
            slidesToShow: 1,
            slidesToScroll: 1
        }
    }]
});

$(".home_service").slick({
    dots: false,
    infinite: true,
    arrows: true,
    autoplay: true,
    slidesToShow: 4,
    slidesToScroll: 4,
    responsive: [{
        breakpoint: 1024,
        settings: {
            slidesToShow: 4,
            slidesToScroll: 4,
            infinite: true,
            dots: true
        }
    }, {
        breakpoint: 980,
        settings: {
            slidesToShow: 2,
            slidesToScroll: 2
        }
    }, {
        breakpoint: 650,
        settings: {
            slidesToShow: 1,
            slidesToScroll: 1
        }
    }]
});



$(".wps_products").slick({
    dots: false,
    infinite: true,
    arrows: true,
    autoplay: true,
    slidesToShow: 4,
    slidesToScroll: 4,
    responsive: [{
        breakpoint: 1024,
        settings: {
            slidesToShow: 4,
            slidesToScroll: 4,
            infinite: true,
            dots: true
        }
    }, {
        breakpoint: 980,
        settings: {
            slidesToShow: 2,
            slidesToScroll: 2
        }
    }, {
        breakpoint: 650,
        settings: {
            slidesToShow: 1,
            slidesToScroll: 1
        }
    }]
});

new WOW().init();
var win = $(window);
win.on('scroll', function () {
  var scroll = win.scrollTop();
  // scrollTop init
  var totop = $('#scrollUp');
  win.on('scroll', function () {
    if (win.scrollTop() > 150) {
        totop.fadeIn();
    } else {
        totop.fadeOut();
    }
});
  totop.on('click', function () {
    $("html,body").animate({
        scrollTop: 0
    }, 0)
});
});
$(".accordion")
.find(".accordion-title")
.on("click", function () {
  $(this).toggleClass("active");
  $(this).next().slideToggle("fast");
  $(".accordion-content").not($(this).next()).slideUp("fast");
  $(".accordion-title").not($(this)).removeClass("active");
});



$('.add-form').on('click', function(){
    $('.form-style-content').addClass('show');
    $(this).addClass('hide');
});
//$('#myVideo').hoverPlay();
//   var video = $("#myVideo");
//
//   $(video).on('canplay', function () {
//       $(video).mouseenter(function () {
//           $(this).get(0).play();
//       }).mouseleave(function () {
//           $(this).get(0).pause();
//       })
//   });

