function christmas_holiday_menu_open_nav() {
	window.christmas_holiday_responsiveMenu=true;
	jQuery(".sidenav").addClass('show');
}
function christmas_holiday_menu_close_nav() {
	window.christmas_holiday_responsiveMenu=false;
 	jQuery(".sidenav").removeClass('show');
}

jQuery(function($){
 	"use strict";
 	jQuery('.main-menu > ul').superfish({
		delay: 500,
		animation: {opacity:'show',height:'show'},  
		speed: 'fast'
 	});
	$(window).scroll(function(){
		var sticky = $('.header-sticky'),
			scroll = $(window).scrollTop();

		if (scroll >= 100) sticky.addClass('header-fixed');
		else sticky.removeClass('header-fixed');
	});
});

/*sticky sidebar*/
window.addEventListener('scroll', function() {
  var sticky = document.querySelector('.sidebar-sticky');
  if (!sticky) return;

  var scrollTop = window.scrollY || document.documentElement.scrollTop;
  var windowHeight = window.innerHeight;
  var documentHeight = document.documentElement.scrollHeight;

  var isBottom = scrollTop + windowHeight >= documentHeight-100;

  if (scrollTop >= 100 && !isBottom) {
    sticky.classList.add('sidebar-fixed');
  } else {
    sticky.classList.remove('sidebar-fixed');
  }
});

/*sticky copyright*/
window.addEventListener('scroll', function() {
  var sticky = document.querySelector('.copyright-sticky');
  if (!sticky) return;

  var scrollTop = window.scrollY || document.documentElement.scrollTop;
  var windowHeight = window.innerHeight;
  var documentHeight = document.documentElement.scrollHeight;

  var isBottom = scrollTop + windowHeight >= documentHeight-100;

  if (scrollTop >= 100 && !isBottom) {
    sticky.classList.add('copyright-fixed');
  } else {
    sticky.classList.remove('copyright-fixed');
  }
});

jQuery(document).ready(function () {
	window.christmas_holiday_currentfocus=null;
  	christmas_holiday_checkfocusdElement();
	var christmas_holiday_body = document.querySelector('body');
	christmas_holiday_body.addEventListener('keyup', christmas_holiday_check_tab_press);
	var christmas_holiday_gotoHome = false;
	var christmas_holiday_gotoClose = false;
	window.christmas_holiday_responsiveMenu=false;
 	function christmas_holiday_checkfocusdElement(){
	 	if(window.christmas_holiday_currentfocus=document.activeElement.className){
		 	window.christmas_holiday_currentfocus=document.activeElement.className;
	 	}
 	}
 	function christmas_holiday_check_tab_press(e) {
		"use strict";
		// pick passed event or global event object if passed one is empty
		e = e || event;
		var activeElement;

		if(window.innerWidth < 999){
		if (e.keyCode == 9) {
			if(window.christmas_holiday_responsiveMenu){
			if (!e.shiftKey) {
				if(christmas_holiday_gotoHome) {
					jQuery( ".main-menu ul:first li:first a:first-child" ).focus();
				}
			}
			if (jQuery("a.closebtn.mobile-menu").is(":focus")) {
				christmas_holiday_gotoHome = true;
			} else {
				christmas_holiday_gotoHome = false;
			}

		}else{

			if(window.christmas_holiday_currentfocus=="responsivetoggle"){
				jQuery( "" ).focus();
			}}}
		}
		if (e.shiftKey && e.keyCode == 9) {
		if(window.innerWidth < 999){
			if(window.christmas_holiday_currentfocus=="header-search"){
				jQuery(".responsivetoggle").focus();
			}else{
				if(window.christmas_holiday_responsiveMenu){
				if(christmas_holiday_gotoClose){
					jQuery("a.closebtn.mobile-menu").focus();
				}
				if (jQuery( ".main-menu ul:first li:first a:first-child" ).is(":focus")) {
					christmas_holiday_gotoClose = true;
				} else {
					christmas_holiday_gotoClose = false;
				}
			
			}else{

			if(window.christmas_holiday_responsiveMenu){
			}}}}
		}
	 	christmas_holiday_checkfocusdElement();
	}
});

jQuery('document').ready(function($){
  setTimeout(function () {
		jQuery("#preloader").fadeOut("slow");
  },1000);
});

jQuery(document).ready(function () {
	jQuery(window).scroll(function () {
    if (jQuery(this).scrollTop() > 100) {
      jQuery('.scrollup i').fadeIn();
    } else {
      jQuery('.scrollup i').fadeOut();
    }
	});
	jQuery('.scrollup i').click(function () {
    jQuery("html, body").animate({
      scrollTop: 0
    }, 600);
    return false;
	});
});

jQuery(document).ready(function(){
	jQuery(".product-cat").hide();
    jQuery("button.product-btn").click(function(){
        jQuery(".product-cat").toggle();
    });

    var christmas_holiday_mydate =jQuery('.date').val();
  	jQuery(".countdown").each(function(){
      	christmas_holiday_countdown(jQuery(this),christmas_holiday_mydate);
  	});
});

function christmas_holiday_countdown($timer,christmas_holiday_mydate){
    // Set the date we're counting down to
    var christmas_holiday_countDownDate = new Date(christmas_holiday_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 = christmas_holiday_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'><span class='count'>" + days + "</span><br><span class='text'>Days</span>" + "</div>" + "   " +"<div class='numbers'><span class='count'>" + hours + "</span><br><span class='text'>Hrs</span>" + "</div>" + "   " + "<div class='numbers'><span class='count'>" + minutes + "</span><br><span class='text'>Mins</span>" + "</div>" + "   " + "<div class='numbers'><span class='count'>" + seconds + "</span><br><span class='text'>Sec</spn" + "</div>");
        
        // If the count down is over, write some text 
        if (distance < 0) {
            clearInterval(x);
            $timer.html("SALE EXPIRED");
        }
    }, 1000);
}
/* Progress Bar */
document.addEventListener("DOMContentLoaded", function () {
    const christmas_holiday_progressBar =
        document.getElementById("christmas_holiday_elemento_progress_bar");
    if (!christmas_holiday_progressBar) return;
    window.addEventListener("scroll", function () {
        const christmas_holiday_scrollTop =
            document.documentElement.scrollTop || document.body.scrollTop;
        const christmas_holiday_height =
            document.documentElement.scrollHeight -
            document.documentElement.clientHeight;
        const christmas_holiday_scrolled =
            (christmas_holiday_scrollTop / christmas_holiday_height) * 100;
        christmas_holiday_progressBar.style.width =
            christmas_holiday_scrolled + "%";
    });
});