
registerInitFunc(init);


function init()
{
    var currentClass='current';			//denotes the current active sub element and prevents collapsing
	var modNav=document.getElementById('moduleNav');	//denotes the module navigation element 
	
// if DOM is not available stop right here.
	if(!document.getElementById && !document.createTextNode){alert("oops");return;}

// if there are module Btns present then set their onClick events to show the respective module and hide the rest
	if(modNav)
	{
		addOnClickEvents(modNav);		
	}
	
}


//	Show the parsed module and hide all the others
function addOnClickEvents(modNav)
{
	btns=modNav.getElementsByTagName('a');
	
	for(i=0; i<btns.length; i++)
	{
		if(btns[i].getAttribute('name') == 'moduleBtn')
		{
			btns[i].setAttribute('href', 'javascript:showModule("'+btns[i].id+'")');
			//btns[i].setAttribute('href', 'javascript:showModule("m3")');
			//btns[i].setAttribute('onClick', 'javascript(alert("hello"))');
			//setBtnStates(btns[i].id);
		}
	}
}


//	Show the parsed module and hide all the others
function showModule(modID)
{
	var mods=document.getElementById('hideableModules');	//denotes the hideableModules element
	var modNav=document.getElementById('moduleNav');	//denotes the module navigation element 
	
	divs=mods.getElementsByTagName('div');
	
	for(i=0; i<divs.length; i++)
	{
		if(divs[i].getAttribute('name') == 'moduleBlock')
		{
			if(divs[i].id == modID)
			{
				divs[i].className='visible';
			}else
			{
				divs[i].className='hidden';
			}
		}
	}
	
	// Set the current button style
	btns=modNav.getElementsByTagName('a');
	
	for(j=0; j<btns.length; j++)
	{
		
		if(btns[j].getAttribute('name') == 'moduleBtn')
		{
			if(btns[j].id == modID)
			{
				btns[j].className='current';
			}else
			{
				btns[j].className='';
			}
		}
	}
}




