// select tab content and link state
function toggleTopicTab(tabNum)
{
	var i = 1;
	while (document.getElementById("tab" + i) != null)
	{
		// tab state
		document.getElementById("tab" + i).className = (i == tabNum) ? "selected" : "";
		// show/hide panel
		document.getElementById("tabContent" + i).style.display = (i == tabNum) ? "block" : "none";
		i++;
	}
}

// select chapter content (link state is done inline)
function toggleChapter(tabNum, chapterNum)
{
	var i = 1;
	if (tabNum == -1)
	{
		// no tabs
		while (document.getElementById("chapter" + i) != null)
		{
			// show/hide chapter panel
			document.getElementById("chapter" + i).style.display = (i == chapterNum) ? "block" : "none";
			i++;
		}
	}
	else
	{
		// has tabs
		while (document.getElementById("tab" + tabNum + "Chapter" + i) != null)
		{
			// show/hide chapter panel
			document.getElementById("tab" + tabNum + "Chapter" + i).style.display = (i == chapterNum) ? "block" : "none";
			i++;
		}
	}
}