
jQuery(document).ready(function(){
// ------------------------------------------------------------------------
    // slimNav
    jQuery('#navigation nav').slimNav_sk78();
    jQuery('#nav-icon0').click(function() {
        jQuery(this).toggleClass('open');
    });
// ------------------------------------------------------------------------



// ------------------------------------------------------------------------
    // nav menu add class
    jQuery("ul.header-menu li").click(function(event){
      jQuery("ul.header-menu li").removeClass("submenu-open");
      jQuery(this).addClass("submenu-open");
      event.stopPropagation();
    });
    jQuery("body").click(function(){
        jQuery("ul.header-menu li").removeClass("submenu-open");
    })
// ------------------------------------------------------------------------



// ------------------------------------------------------------------------
    // platform-overview-sec4 accordion
    jQuery(".accordian li h5").click(function(){
        jQuery(this).parent().siblings().removeClass("active").find(".content").slideUp();
        jQuery(this).parent().toggleClass("active").find(".content").slideToggle();
    });
// ------------------------------------------------------------------------
});








// home-sec3 marquee
document.addEventListener("DOMContentLoaded", () => {
	const marquee = document.querySelector(".marquee-inner");
	const speed = 1.5; // Scrolling Speed
	let scrollAmount = 0;
	let isHovered = false;

	// Duplicates the content
	const marqueeContent = marquee.innerHTML;
	marquee.innerHTML += marqueeContent;

	const startScrolling = () => {
		if (!isHovered) {
			scrollAmount -= speed;
			if (Math.abs(scrollAmount) >= marquee.scrollWidth / 2) {
				scrollAmount = 0;
			}
			marquee.style.transform = `translateX(${scrollAmount}px)`;
		}
		requestAnimationFrame(startScrolling);
	};

	marquee.addEventListener("mouseover", () => {
		isHovered = true;
	});

	marquee.addEventListener("mouseout", () => {
		isHovered = false;
	});

	startScrolling();
});

// ------------------------------------------------------------------------
 


// desktop-tab mobile-accordian
function tabControl() {
  var tabs = jQuery('.tabbed-content').find('.tabs');

  if (tabs.is(':visible')) {
    // Desktop: Tabs Behavior
    tabs.find('a').on('click', function(event) {
      event.preventDefault();
      var target = jQuery(this).attr('href'),
          tabs = jQuery(this).parents('.tabs'),
          buttons = tabs.find('a'),
          item = tabs.parents('.tabbed-content').find('.item');
      
      buttons.removeClass('active');
      item.removeClass('active');
      jQuery(this).addClass('active');
      jQuery(target).addClass('active');
    });
  } else {
    // Mobile: Accordion Behavior with Toggle
    jQuery('.item').on('click', function() {
      var container = jQuery(this).parents('.tabbed-content'),
          currId = jQuery(this).attr('id'),
          items = container.find('.item');
      
      if (jQuery(this).hasClass('active')) {
        // If the clicked item is already active, close it
        jQuery(this).removeClass('active');
        container.find('.tabs a[href$="#'+ currId +'"]').removeClass('active');
      } else {
        // Otherwise, open the clicked item and close others
        items.removeClass('active');
        container.find('.tabs a').removeClass('active');
        jQuery(this).addClass('active');
        container.find('.tabs a[href$="#'+ currId +'"]').addClass('active');
      }
    });
  }
}

// Initial tabControl call and on resize
tabControl();
var resizeTimer;
jQuery(window).on('resize', function(e) {
  clearTimeout(resizeTimer);
  resizeTimer = setTimeout(function() {
    tabControl();
  }, 250);
});
