// Scroll to Top
window.onscroll = function() {
  const it_software_technology_button = document.querySelector('.scroll-top-box');
  if (it_software_technology_button) {
    if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
      it_software_technology_button.style.display = "block";
    } else {
      it_software_technology_button.style.display = "none";
    }
  }
};

const scrollTopLink = document.querySelector('.scroll-top-box a');
if (scrollTopLink) {
  scrollTopLink.onclick = function(event) {
    event.preventDefault();
    window.scrollTo({ top: 0, behavior: 'smooth' });
  };
}

// slider
jQuery(document).ready(function($) {
    var owl = $('.main-banner-sec .owl-carousel');
    owl.owlCarousel({
        margin: 0,
        rtl: $('html').attr('dir') === 'rtl',
        nav: false, 
        autoplay: false,
        loop: true,
        dots: false,
        responsive: {
            0: { items: 1 },
            600: { items: 1 },
            1000: { items: 1 }
        }
    });

    function it_software_technology_updatePagination(index) {
        $('.pagination-item').removeClass('active');
        $('.pagination-item[data-slide="' + index + '"]').addClass('active');
    }

    owl.on('changed.owl.carousel', function(event) {
        var currentIndex = event.item.index - event.relatedTarget._clones.length / 2;
        var totalItems = event.item.count;
        var activeIndex = (currentIndex % totalItems + totalItems) % totalItems;
        it_software_technology_updatePagination(activeIndex);
    });

    $('.pagination-item').on('click', function() {
        var slideIndex = $(this).data('slide');
        owl.trigger('to.owl.carousel', [slideIndex, 300]);
    });
});


// latest blog
jQuery(document).ready(function() {
  jQuery('.blog-section .owl-carousel').owlCarousel({
    loop: true,
    margin: 30,
    nav: false,
    dots: false,
    rtl: false,
    responsive: {
    0: { 
      items: 1 
    },
    600: { 
      items: 2 
    },
    1024: { 
      items: 3
    },
    1200: { 
      items: 3
    }
  },
    autoplay: false,
  });
});