Tab Panels JavaScript: Selection Function

function gtJSUI_selectTab(set, section) {

  var tabList = document.getElementById('gtTabList_' + set);
  if (tabList) {
    for (var x = 0; x < tabList.children.length; x++) {
      var tabHTMLLI = tabList.children[x];
      var tabHTMLA = document.getElementById('gtTabTitle_' + set + '_' + x);
      var tabPanel = document.getElementById('gtTab_' + set + '_' + x);

      if (tabHTMLLI && tabHTMLA && tabPanel) {
        tabHTMLLI.className = (x == section ? 'gtTabSelected' : '');
        tabHTMLA.setAttribute('aria-selected', (x == section ? 'true' : 'false'));
        tabPanel.style.display = (x == section ? 'block' : 'none');
      }
    }
  }

}