/**
 * Transport Carrier Theme - Main JavaScript
 * Handles theme interactive functionality
 */

// Faq
document.addEventListener("DOMContentLoaded", function () {
  const transport_carrier_game_details = document.querySelectorAll(".faq-btm-title");

  transport_carrier_game_details.forEach((targetDetail) => {
    targetDetail.addEventListener("toggle", () => {
      if (targetDetail.open) {
        transport_carrier_game_details.forEach((transport_carrier_game_detail) => {
          if (transport_carrier_game_detail !== targetDetail) {
            transport_carrier_game_detail.removeAttribute("open");
          }
        });
      }
    });
  });
});

jQuery(document).ready(function ($) {

  var $transport_carrier_owl = $('.banner-main-section.owl-carousel');

  $transport_carrier_owl.owlCarousel({
      margin: 20,
      nav: true,
      navText: [
          '<i class="fas fa-arrow-left" aria-hidden="true"></i>',
          '<i class="fas fa-arrow-right" aria-hidden="true"></i>'
      ],
      autoplay: true,
      lazyLoad: true,
      autoplayTimeout: 3000,
      loop: true,
      dots: false,
      autoplayHoverPause: true,
      mouseDrag: true,
      responsive: {
          0: { items: 1 },
          600: { items: 1 },
          1000: { items: 1 }
      }
  });


  // Service / Category Slider
  var $serviceCarousel = $('.cat-position.owl-carousel');

  // Wrap title, content and btn in an overlay div before init
  $serviceCarousel.find('.service-box').each(function () {
      var $box = $(this);
      var $title   = $box.find('.service-title');
      var $content = $box.find('.service-content');
      var $btn     = $box.find('.service-btn');
      if ($title.length || $content.length || $btn.length) {
          $title.add($content).add($btn).wrapAll('<div class="service-overlay"></div>');
      }
  });

  $serviceCarousel.owlCarousel({
      nav: false,
      margin: 0,
      autoplay: true,
      margin: 20,
      lazyLoad: true,
      autoplayTimeout: 2000,
      loop: true,
      dots: false,
      responsive: {
        0: { items: 1 },
        768: { items: 2 },
        992: { items: 3 },
        1200: { items: 4 }
      },
      autoplayHoverPause: true,
      mouseDrag: true
  });
});