/*			function focusChange(focusElement)
			function getElementsByClassName(node, classname) 
*	Instructions:
*		1)Everything should be wrapped in a container with an id attribute, which is passed as the variable tabSetId.
*		2)For the tabs, create a set of <a> tags, each referencing an internal link (<a href="foo">)
*			-- Wrap all the 'tabs' in a container with class="toc" (you may use <tr>, <ul>, whatever is appropriate)
*		3)Create 'topics' (destinations for the 'tabs') by assigning each set of info an appropriate id (<div id="foo">)
*		4)Style everything appropriately for non-JS use (optional, but recommended)
*		5)Style everything appropriately for JS functionality using the following:
*			a) the main container (container#tabSetId) will have a class of 'jsActive'
*			b) the 'topics' will have a class of 'topic'
*			c) the active tab and active topic will have a class of 'focusActive'
*		6)Call the function at window.onload, or in some other appropriate manner.
*
*************	NOTES END *********************************************************************************************/

function focusChange(focusElement) {
	focusElement.className += " focusActive";
	return(focusElement);
}

function getElementsByClassName(node, classname) {
    var a = [];
    var re = new RegExp('(^| )'+classname+'( |$)' );
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function tabSwitch(tabSetId) {
	
	if(!window.Globals){
		window.Globals = new Array;
	}
	
	var tabList = document.getElementById(tabSetId);

	if (tabList.getElementsByTagName("A").length > 0 ) {	
		window.Globals[tabSetId] = new Array();
		
		tabList.className += " jsActive";
		
		tabList = getElementsByClassName(tabList, "toc");
		tabList = tabList[0].getElementsByTagName("A");
		
		tabFocusChange(tabList[0], tabSetId);
		
		for (i = 0; i < tabList.length; i++) {
			document.getElementById(tabList[i].href.substring(tabList[i].href.lastIndexOf('#') + 1)).className += ' topic';
			tabList[i].onclick = function () {
				if (this.parentNode == window.Globals[tabSetId]["link"]) {
					return(false);
				} else {
						window.Globals[tabSetId]["link"].className = window.Globals[tabSetId]["link"].className.replace(/focusActive/g, " ");
						window.Globals[tabSetId]["id"].className = window.Globals[tabSetId]["id"].className.replace(/focusActive/g, " ");
						return(tabFocusChange(this, tabSetId));
				}
			}
		}
	}
}

function tabFocusChange (tabLink, tabSetId) {
	window.Globals[tabSetId]["link"] = focusChange(tabLink.parentNode);		//References function focusChange(focusElement) from /jseone/eone.js
	
	var tabDestination = tabLink.getAttribute("HREF");
	tabDestination = tabDestination.substring(tabDestination.lastIndexOf('#') + 1);
	window.Globals[tabSetId]["id"] = focusChange(document.getElementById(tabDestination));		//References function focusChange(focusElement) from /jseone/eone.js

	return(false);
}