const navbar = document.querySelector('#stikyNav');
//let top = navbar.offsetTop;
function stickynavbar() {
  if (window.scrollY >= 200) {    
    navbar.classList.add('sticky');
  } else {
    navbar.classList.remove('sticky');    
  }
}
  window.addEventListener('scroll', stickynavbar);


  $('.count').each(function () {
    $(this).prop('Counter',0).animate({
        Counter: $(this).text()
    }, {
        duration: 3000,
        easing: 'swing',
        step: function (now) {
            $(this).text(Math.ceil(now));
        }
    });
});




$(document).ready(function(){
    
    $('#clickTop').hide();
    
    //Check to see if the window is top if not then display button
    
    $(window).scroll(function(){
        if ($(this).scrollTop() > 300) {
            $('#clickTop').fadeIn();
        } else {
            $('#clickTop').fadeOut();
        }
    });
    
    //Click event to scroll to top
    
    $('#clickTop').click(function(){
        $('html, body').animate({scrollTop : 0},500);
        return false;
    });
    
});



// --------------loader---------------------

// $(window).load(function(){
//     $(".loader").delay('1000').fadeOut('600');
// })




$('#owl-carousel').owlCarousel({
  loop: true,
  margin: 30,
  dots: false,
  nav: true,
  items: 3,
  autoplay:true,
  navText: ["<i class='fa-solid fa-caret-left'></i>","<i class='fa-solid fa-caret-right'></i>"],
})


$('#owl-carousel_history').owlCarousel({
  loop: true,
  margin: 30,
  dots: true,
  nav: false,
  items: 4,

  responsive:{
            0:{
                items:2,
               
            },
            767:{
                items:2,
               
            },
            991:{
                items:2,
                
            },
    
            992:{
                items:3,
                
            },
    
            1200:{
                items:3,
                
            },
            
            1366:{
                items:4,
               
            },
            1920:{
                items:4,
                
            }
        }
})



$('#owl-carousel_client').owlCarousel({
  loop: true,
  margin: 30,
  dots: false,
  nav: false,
  items: 5,
  autoplay: true,
// autoplayHoverPause:true,
// slideTransition: 'linear',
// autoplayTimeout: 2000,
// autoplaySpeed: 50000,
// loop: true,
  responsive:{
    0:{
        items:2,
       
    },
    767:{
        items:4,
       
    },
    991:{
        items:4,
        
    },

    992:{
        items:5,
        
    },

    1200:{
        items:5,
        
    },
    
    1366:{
        items:5,
       
    },
    1920:{
        items:5,
        
    }
}
  
})
  

// --------------click to top---------------------



$(document).ready(function(){
    
    $('#clickTop').hide();
    
    //Check to see if the window is top if not then display button
    
    $(window).scroll(function(){
        if ($(this).scrollTop() > 300) {
            $('#clickTop').fadeIn();
        } else {
            $('#clickTop').fadeOut();
        }
    });
    
    //Click event to scroll to top
    
    $('#clickTop').click(function(){
        $('html, body').animate({scrollTop : 0},500);
        return false;
    });
    
});


var button = document.getElementById("filter-button");
var container = document.getElementById("filter-container");
var input = document.querySelectorAll("input");

button.onclick = function (e) {
  e.stopPropagation();
  if (container.classList.contains("filters--active")) {
    container.classList.remove("filters--active");
  } else {
    container.classList.add("filters--active");
  }
};

container.onclick = function (e) {
  e.stopPropagation();
};

window.onclick = function () {
  container.classList.remove("filters--active");
};

console.log(input);

for (var i = 0; i < input.length; i++) {
  var currentInput = input[i];

  currentInput.onclick = function () {
    var isChecked = false;
    for (var j = 0; j < input.length; j++) {
      if (input[j].checked) {
        isChecked = true;
        break;
      }
    }

    if (isChecked) {
      button.classList.add("button--highlight");
    } else {
      button.classList.remove("button--highlight");
    }
  };
}



