/* http://www.enctoday.com/common/tools/load.php?js=common_tabBox */
function showTab( tab, tabContentID )
{
	// figure out the id of the tab box being worked with
	// and the number of the tab that was clicked on
	var tboxID = getTabBoxID(tab);
	var tabNum = getTabNum(tab);
	
	// get the tab box and read the values on it
	var tabBox = getEl(tboxID);
	var lastTabNum = tabBox.getAttribute('lastTab');
	var baseName = tabBox.getAttribute('baseName');
	var tabSelected = baseName + "Selected";
	
	// get the last tab and it's content container
	var lastTab = getEl(tboxID+"_"+lastTabNum+"_tab");
	var lastTabContent = getEl(tboxID+"_"+lastTabNum+"_content");
	
	// get the current tab and it's content container.
	var currTab = getEl(tboxID+"_"+tabNum+"_tab");
	var currTabContent = getEl(tboxID+"_"+tabNum+"_content");
	
	// unselect the last tab and hide it's content container
	lastTab.className = lastTab.className.replace(tabSelected, "");
	lastTabContent.style.display = 'none';
	
	// select the current tab and show it's content container
	currTab.className = currTab.className + " " + tabSelected;
	currTabContent.style.display = '';
	
	// set the last tab to the current tab
	tabBox.setAttribute('lastTab', tabNum);
}

function getTabBoxID(tab)
{
	var tabID = tab.id;
	var first = tabID.indexOf("_");
	var second = tabID.indexOf("_", (first+1));
	return tabID.substr(0, first);
}

function getTabNum(tab)
{
	var tabID = tab.id;
	var first = tabID.indexOf("_");
	var second = tabID.indexOf("_", (first+1));
	return tabID.substr((first+1), (second-first-1));
}

function highlightTab(tab, highlight)
{
	var tboxID = getTabBoxID(tab);
	var tabBox = getEl(tboxID);
	var baseName = tabBox.getAttribute('baseName');
	var style = baseName+"Highlighted";
	
	if (highlight == true)
		tab.className += " "+style;
	else
		tab.className = tab.className.replace(style, "");
}

function getEl( id )
{
	return document.getElementById(id);
}