function initialiseModuleNav() {
	if(document.getElementById('module_nav')) {
		var navItem = new Array();
		navItem = document.getElementById('module_nav').getElementsByTagName('li');
		//var tabs = new Array('tab_subscribe', 'tab_inthemag', 'tab_newsletter'); // Valid names of tabs / DIVs we're going to use
		var tabs = new Array('tab_inthemag'); // Valid names of tabs / DIVs we're going to use
		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;
				}
			}
		}
	}
}

// Changes the class of the nav to change the appearance
// Arguments:
//	nav		The element you wish to assign the class to
//	activeTab	The class you wish to assign to nav
function swapNavTabs(nav, activeTab) {
	nav.className = activeTab;
}

// Makes selected DIV appear and the rest disappeared
// Arguments:
//	divs		IDs for the DIVs we're playing with
//	selected	ID for the DIV we want to show
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';
}

// Add Load Event Function
// borrowed from Simon Willison: http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

addLoadEvent(initialiseModuleNav);
