function stickyHeader() {
  if ($(".header").length) {
    var strickyScrollPos = 100;
    if ($(window).scrollTop() > strickyScrollPos) {
      $(".header").addClass("stricky-fixed");
    } else if ($(this).scrollTop() <= strickyScrollPos) {
      $(".header").removeClass("stricky-fixed");
    }
  }
}

jQuery(window).on("scroll", function () {
  (function ($) {
    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) {
      $(".navigation .menu").stop(true).slideUp();
      $(".navigation .navbar button").removeClass("open");
    }
  });
}

var allSlider = $("#allSlider");
allSlider.owlCarousel({
    loop: false,
    margin: 20,
    navSpeed: 500,
    nav: false,
    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>'],
    autoplay: true,
    dots: true,
    items: 3,
    responsiveClass: true,
    responsive: {
        0: {
            items: 2
        },
        600: {
            items: 2,
        },
        768: {
            items: 4
        },
        1024: {
            items:8
        },
        1100: {
            items: 8
        }
    }
});



  $(".item-bx").mouseenter(function(){
    $(".item-bx").removeClass("active");
  $(this).addClass("active");
});

var moreProducts = $("#moreProducts");
moreProducts.owlCarousel({
    loop: false,
    margin: 20,
    navSpeed: 500,
    nav: true,
    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>'],
    autoplay: false,
    dots: false,
    items: 3,
    responsiveClass: true,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 1,
        },
        768: {
            items: 2
        },
        1024: {
            items:3
        },
        1100: {
            items: 3
        }
    }
});

var moreProducts = $("#moreProducts2");
moreProducts.owlCarousel({
    loop: false,
    margin: 20,
    navSpeed: 500,
    nav: true,
    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>'],
    autoplay: false,
    dots: false,
    items: 4,
    responsiveClass: true,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 1,
        },
        768: {
            items: 2
        },
        1024: {
            items:3
        },
        1100: {
            items: 4
        }
    }
});

var moreProducts = $("#testimonials");
moreProducts.owlCarousel({
    loop: false,
    margin: 20,
    navSpeed: 500,
    nav: true,
    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/></svg>'],
    autoplay: false,
    dots: false,
    items: 3,
    responsiveClass: true,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 1,
        },
        768: {
            items: 2
        },
        1024: {
            items:3
        },
        1100: {
            items: 3
        }
    }
});

// Configure/customize these variables.
var showChar = 160;  // How many characters are shown by default
var ellipsestext = "...";
var moretext = "Show More";
var lesstext = "Show Less";

$('.tm-slide-p').each(function () {

  var content = $(this).html();
  if (content.length > showChar) {
    var c = content.substr(0, showChar);
    var h = content.substr(showChar, content.length - showChar);
    var html = c + '<span class="moreellipses">' + ellipsestext + '&nbsp;</span><span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<a href="" class="morelink">' + moretext + '</a></span>';
    $(this).html(html);
  }

});

$(".morelink").click(function () {
  if ($(this).hasClass("less")) {
    $(this).removeClass("less");
    $(this).html(moretext);
  } else {
    $(this).addClass("less");
    $(this).html(lesstext);
  }
  $(this).parent().prev().toggle();
  $(this).prev().toggle();
  return false;
});

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

$(window).on('scroll', function () {
  if ($(this).scrollTop() > 100) {
    $("#scrollUp").fadeIn();
  } else {
    $("#scrollUp").fadeOut();
  }
});
$("#scrollUp").on('click', function () {
  $("html, body").animate({
    scrollTop: 0
  }, 600);
  return false;
});