function openCustomer(evt, customerName) {

    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
      tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(customerName).style.display = "block";
    evt.currentTarget.className += " active";
  }
  
  function openPanel(evt, panel) {

    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
      tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(panel).style.display = "block";

    // window.location.hash = '#food';
    var hash = window.location.hash;
    var href = evt.currentTarget.getAttribute('href');
    if (href !== null && href !== undefined && hash.length > 0 && !href.includes('/')) {
      if (href.length > 0) {
        window.location.hash = href;
      } else {
        window.location.hash = '';
      }
    }


    if (panel == 'consumer') {
      document.getElementById('consumerTab').className += " active";
    } else if (panel == 'business') {
      document.getElementById('businessTab').className += " active";
    }
    
    //evt.currentTarget.className += " active";
  }

  function openUses(evt, usesName) {

    var i, tabcontent2, tablinks2;
    tabcontent2 = document.getElementsByClassName("tabcontent2");
    for (i = 0; i < tabcontent2.length; i++) {
      tabcontent2[i].style.display = "none";
    }
    tablinks2 = document.getElementsByClassName("tablinks2");
    for (i = 0; i < tablinks2.length; i++) {
      tablinks2[i].className = tablinks2[i].className.replace(" active", "");
    }
    document.getElementById(usesName).style.display = "block";
    evt.currentTarget.className += " active";

  }
  
  function openBusinessuses(evt, businessusesName) {
    var i, tabcontent3, tablinks3;
    tabcontent3 = document.getElementsByClassName("tabcontent3");
    for (i = 0; i < tabcontent3.length; i++) {
      tabcontent3[i].style.display = "none";
    }
    tablinks3 = document.getElementsByClassName("tablinks3");
    for (i = 0; i < tablinks3.length; i++) {
      tablinks3[i].className = tablinks3[i].className.replace(" active", "");
    }
    document.getElementById(businessusesName).style.display = "block";
    evt.currentTarget.className += " active";
  }


  function openDefaultTabs () {
    
    if (window.location.href.indexOf('#business') > -1) {
        // Get the element with id="businessTab" and click on it
        document.getElementById("businessTab").click();
		
    } else {
        // Get the element with id="consumerTab" and click on it
        document.getElementById("consumerTab").click();
    }
  
    // Open the Default Sub Tabs
    //document.getElementById("consumerSubTabDefault").click();
    //document.getElementById("businessSubTabDefault").click();

  }


//  
openDefaultTabs();

document.addEventListener("DOMContentLoaded", function () {
  // Check if there's a hash in the URL
  if (window.location.hash && (window.location.hash === "#business" || window.location.hash === "#consumer")) {
    // Prevent the browser's default scrolling to the anchor
    history.scrollRestoration = "manual"; // Disable automatic scroll restoration
    window.scrollTo(0, 0); // Reset scroll position immediately

    var tabsElement = document.querySelector('.tabs');
    if (tabsElement) {
      var elementPosition = tabsElement.getBoundingClientRect().top + window.pageYOffset;
      var offsetPosition = elementPosition; // Adjust for 100px fixed header
      setTimeout(function () {
        tabsElement.scrollIntoView({ behavior: "smooth", block: "start" });
      }, 10);
    }
  }
});