// show the panel that the selected tab controls and set aria-hidden to false
this.$panel.find('#' + $tab.attr('aria-controls')).show().attr('aria-hidden', 'false');

} // end init()

//
// Function switchTabs() is a member function to give focus to a new tab or accordian header.
// If it's a tab panel, the currently displayed panel is hidden and the panel associated with the new tab
// is displayed.
//
// @param ($curTab obj) $curTab is the jQuery object of the currently selected tab
//
// @param ($newTab obj) $newTab is the jQuery object of new tab to switch to
//
// @return N/A
//
tabpanel.prototype.switchTabs = function($curTab, $newTab) {

// Remove the highlighting from the current tab
$curTab.removeClass('selected focus');

// remove tab from the tab order and update its aria-selected attribute
$curTab.attr('tabindex', '-1').attr('aria-selected', 'false');

// update the aria attributes

// Highlight the new tab and update its aria-selected attribute
$newTab.addClass('selected').attr('aria-selected', 'true');

// If this is a tab panel, swap displayed tabs
if (this.accordian == false) {
// hide the current tab panel and set aria-hidden to true
this.$panel.find('#' + $curTab.attr('aria-controls')).hide().attr('aria-hidden', 'true');

// show the new tab panel and set aria-hidden to false
this.$panel.find('#' + $newTab.attr('aria-controls')).show().attr('aria-hidden', 'false');
}

// Make new tab navigable
$newTab.attr('tabindex', '0');

// give the new tab focus
$newTab.focus();

} // end switchTabs()

//
// Function togglePanel() is a member function to display or hide the panel associated with an accordian header
//
// @param ($tab obj) $tab is the jQuery object of the currently selected tab
//
// @return N/A
//
tabpanel.prototype.togglePanel = function($tab) {

// focusable is a small jQuery extension to add a :focusable selector. It is used to
// get a list of all focusable elements in a panel. Credit to ajpiano on the jQuery forums.
//
$.extend($.expr[':'], {
focusable: function(element) {
var nodeName = element.nodeName.toLowerCase();
var tabIndex = $(element).attr('tabindex');

// the element and all of its ancestors must be visible
if (($(element)[nodeName == 'area' ? 'parents' : 'closest'](':hidden').length) == true) {
return false;
}

// If tabindex is defined, its value must be greater than 0
if (!isNaN(tabIndex) && tabIndex < 0) {
return false;
}

// if the element is a standard form control, it must not be disabled
if (/input|select|textarea|button|object/.test(nodeName) == true) {

return !element.disabled;
}

// if the element is a link, href must be defined
if ((nodeName == 'a' || nodeName == 'area') == true) {

return (element.href.length > 0);
}

// this is some other page element that is not normally focusable.
return false;
}
});