function skin_care_products_openNav() {
  jQuery(".sidenav").addClass('show');
}
function skin_care_products_closeNav() {
  jQuery(".sidenav").removeClass('show');
}

( function( window, document ) {
  function skin_care_products_keepFocusInMenu() {
    document.addEventListener( 'keydown', function( e ) {
      const skin_care_products_nav = document.querySelector( '.sidenav' );

      if ( ! skin_care_products_nav || ! skin_care_products_nav.classList.contains( 'show' ) ) {
        return;
      }
      const elements = [...skin_care_products_nav.querySelectorAll( 'input, a, button' )],
        skin_care_products_lastEl = elements[ elements.length - 1 ],
        skin_care_products_firstEl = elements[0],
        skin_care_products_activeEl = document.activeElement,
        tabKey = e.keyCode === 9,
        shiftKey = e.shiftKey;

      if ( ! shiftKey && tabKey && skin_care_products_lastEl === skin_care_products_activeEl ) {
        e.preventDefault();
        skin_care_products_firstEl.focus();
      }

      if ( shiftKey && tabKey && skin_care_products_firstEl === skin_care_products_activeEl ) {
        e.preventDefault();
        skin_care_products_lastEl.focus();
      }
    } );
  }
  skin_care_products_keepFocusInMenu();
} )( window, document );

var skin_care_products_btn = jQuery('#button');

jQuery(window).scroll(function() {
  if (jQuery(window).scrollTop() > 300) {
    skin_care_products_btn.addClass('show');
  } else {
    skin_care_products_btn.removeClass('show');
  }
});

skin_care_products_btn.on('click', function(e) {
  e.preventDefault();
  jQuery('html, body').animate({scrollTop:0}, '300');
});

jQuery(document).ready(function() {
    var owl = jQuery('#top-slider .owl-carousel');
    owl.owlCarousel({
    margin: 0,
    nav:false,
    autoplay : true,
    lazyLoad: true,
    autoplayTimeout: 5000,
    loop: false,
    dots: false,
    navText : ['<i class="fas fa-arrow-left" aria-hidden="true"></i>','<i class="fas fa-arrow-right" aria-hidden="true"></i>'],
    responsive: {
      0: {
        items: 1
      },
      576: {
        items: 1
      },
      768: {
        items: 1
      },
      1000: {
        items: 1
      },
      1200: {
        items: 1
      }
    },
    autoplayHoverPause : false,
    mouseDrag: true
  });
  var owl = jQuery('.featured .owl-carousel');
    owl.owlCarousel({
    margin: 30,
    nav:true,
    autoplay : true,
    lazyLoad: true,
    autoplayTimeout: 5000,
    loop: true,
    dots: false,
    navText : ['<i class="fas fa-arrow-left" aria-hidden="true"></i>','<i class="fas fa-arrow-right" aria-hidden="true"></i>'],
    responsive: {
      0: {
        items: 1
      },
      576: {
        items: 1
      },
      768: {
        items: 1
      },
      1000: {
        items: 2
      },
      1200: {
        items: 2
      }
    },
    autoplayHoverPause : false,
    mouseDrag: true,
  });
})

window.addEventListener('load', (event) => {
  jQuery(".loading").delay(2000).fadeOut("slow");
  jQuery(".loading2").delay(2000).fadeOut("slow");
});

jQuery('.header-search-wrapper .search-main').click(function(){
  jQuery('.search-form-main').toggleClass('active-search');
  jQuery('.search-form-main .search-field').focus();
});

function dealscountdown($timer,mydate){
    // Set the date we're counting down to
    var countDownDate = new Date(mydate).getTime();
    // Update the count down every 1 second
    var x = setInterval(function() {
        // Get todays date and time
        var now = new Date().getTime();
        // Find the distance between now an the count down date
        var distance = countDownDate - now;
        // Time calculations for days, hours, minutes and seconds
        var days = Math.floor(distance / (1000 * 60 * 60 * 24));
        var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
        var seconds = Math.floor((distance % (1000 * 60)) / 1000);
        // Output the result in an element with id="timer"
       $timer.html(
          "<div class='numbers'>" + days + "<br><span class='nofont'>Days</span> </div>  :" +
          "<div class='numbers'>" + hours + "<br><span class='nofont'>Hours</span> </div> :" +
          "<div class='numbers'>" + minutes + "<br><span class='nofont'>Mins</span> </div> :" +
          "<div class='numbers'>" + seconds + "<br><span class='nofont'>Secs</span></div> "
      );

        
        // If the count down is over, write some text 
        if (distance < 0) {
            clearInterval(x);
            $timer.html("Timer Up -EVENT EXPIRED");
        }
    }, 1000);
}

jQuery('document').ready(function(){
  jQuery('.count').each(function () {
      jQuery(this).prop('Counter',0).animate({
          Counter: jQuery(this).text()
      }, {
          duration: 8000,
          easing: 'swing',
          step: function (now) {
             jQuery(this).text(Math.ceil(now));
          }
      });
  });   
  var mydate =jQuery('.date').val();
  jQuery(".countdown").each(function(){
      dealscountdown(jQuery(this),mydate);
  });
});

jQuery(window).scroll(function() {
  var data_sticky = jQuery('.main-header').attr('data-sticky');

  if (data_sticky == "true") {
    if (jQuery(this).scrollTop() > 1){
      jQuery('.main-header').addClass("stick_header");
    } else {
      jQuery('.main-header').removeClass("stick_header");
    }
  }
});