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);


  $('.counter-count').each(function () {
    $(this).prop('Counter',0).animate({
        Counter: $(this).text()
    }, {
        duration: 5000,
        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,
    navText: ["<i class='fa-solid fa-arrow-left'></i>","<i class='fa-solid fa-arrow-right'></i>"],
    responsive:{
        0:{
            items:1,
           
        },
        767:{
            items:1,
           
        },
        991:{
            items:1,
            
        },
    
        992:{
            items:2,
            
        },
    
        1200:{
            items:2,
            
        },
        
        1366:{
            items:3,
           
        },
        1920:{
            items:3,
            
        }
    }
    
})






  

  
  

// --------------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;
    });
    
});



document.addEventListener("DOMContentLoaded", () => {
 function counter(id, start, end, duration) {
  let obj = document.getElementById(id),
   current = start,
   range = end - start,
   increment = end > start ? 1 : -1,
   step = Math.abs(Math.floor(duration / range)),
   timer = setInterval(() => {
    current += increment;
    obj.textContent = current;
    if (current == end) {
     clearInterval(timer);
    }
   }, step);
 }
 counter("count1", 0, 45, 3000);
 counter("count2", 100, 50, 2500);
 
});



document.addEventListener("DOMContentLoaded", () => {
 function counter(id, start, end, duration) {
  let obj = document.getElementById(id),
   current = start,
   range = end - start,
   increment = end > start ? 1 : -1,
   step = Math.abs(Math.floor(duration / range)),
   timer = setInterval(() => {
    current += increment;
    obj.textContent = current;
    if (current == end) {
     clearInterval(timer);
    }
   }, step);
 }
counter("count3", 0, 16, 3000);
 counter("count4", 100, 18, 2500);
 counter("count5", 0, 10, 3000);
 counter("count6", 100, 50, 2500);
 
});
