/*
	initialiseModuleNav
	
	@param string navId The ID of the nav
	@param array tabs The sections of the nav
*/
function initialiseModuleNav(navId, tabs) {
	if(document.getElementById(navId)) {
		var navItem = new Array();
		navItem = document.getElementById(navId).getElementsByTagName('li');
		var anchor = new Array();
		
		// Initially display the first DIV only
		swapDivs(tabs, tabs[0]);
		
		
		// Confirm that the class of the LI matches one of the valid values defined above
		function checkValue(liClass) {
			for(var j = 0; j < tabs.length; j++) {
				if(liClass == tabs[j]) {
					return true;
				}
			}
			return false;
		};
		
		// Loop through each LI, validate its class. If valid assign an onClick to it.
		for(var i = 0; i < navItem.length; i++) {
			var validValue = false;
			validValue = checkValue(navItem[i].className);
			if(validValue == true) {
				anchor[i] = navItem[i].getElementsByTagName('a');
				anchor[i][0].onclick = function() {
					swapNavTabs(this.parentNode.parentNode, this.parentNode.className);
					swapDivs(tabs, this.parentNode.className);
					return false;
				};
			}
		}
	}
};

function swapNavTabs(nav, activeTab) {
	nav.className = activeTab;
};

function swapDivs(divs, selected) {
	var div = new Array();
	for(var i = 0; i < divs.length; i++) {
		div[i] = document.getElementById(divs[i]);
		div[i].style.display = 'none';
	}
	var visibleDiv = document.getElementById(selected);
	visibleDiv.style.display = 'block';
};