function DisplaySection( sectionName )
{
	menu = document.getElementById( sectionName )
	menu.style.visibility = "visible"
	menu.style.display = "block"
}

function HideSection( sectionName )
{
	menu = document.getElementById( sectionName )
	menu.style.visibility = "hidden"
	menu.style.display = "none"
}

function flipSection( sectionName )
{
	if( document.getElementById( sectionName ).style.visibility == "hidden" ) {
		DisplaySection( sectionName )
	} else {
		HideSection( sectionName )
	}
} 

// getElementsByClass by Dustin Diaz
// from http://www.dustindiaz.com/top-ten-javascript/
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	

	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


// show all divs of class sectionClassName
function showAllSections( sectionClassName ) 
{
	// hide all page sections
	var sections = getElementsByClass( sectionClassName, document.getElementById( "content" ), "div" );
	for ( var i=sections.length-1; i>=0; --i ){
 		sections[i].style.visibility = "visible"
 		sections[i].style.display = "block"
	}
}


// hide all divs of class sectionClassName
function hideAllSections( sectionClassName )
{
	// hide all page sections
	var sections = getElementsByClass( sectionClassName, document.getElementById( "content" ), "div" );
	for ( var i=sections.length-1; i>=0; --i ){
 		sections[i].style.visibility = "hidden"
 		sections[i].style.display = "none"
	}
}

// hide all divs of class sectionClassName and then reveal the one with ID of sectionName
function showSection( sectionName, sectionClassName )
{
	hideAllSections( sectionClassName )
	DisplaySection( sectionName )
} 


