var menuId ;

/**
	Fetches the current filename, uses it as id and sets the element with this id to active
*/
function doNavigation() {
	menuId = getFilename() ;
	setMenuActive(menuId) ;
}

/**
	Get the filename for the current site
	when no filename is given, "index" is assumed
	
	Example: www.google.at/search123.php would be "search123"
*/
function getFilename() {
	fullPath = document.location.pathname ;
	lastPosSlash = fullPath.lastIndexOf('/') ;
	fullFilename = fullPath.substr(lastPosSlash+1) ;
	if (fullFilename == '') {
		menuId = 'index' ;
	} else {
		nextPosDot = fullFilename.indexOf('.') ;
		baseName = fullFilename.substr(0,nextPosDot) ;
		menuId = baseName ;
	}
	return menuId ;
}

/**
	Get tht DOM Object of the menu elemetn and set the class to the active class
	Look if there is a parent menu element and set to active too
*/
function setMenuActive(menuId) {
	if (document && document.getElementById) {
		menuObj = document.getElementById(menuId) ;
		if (menuObj) {
			menuObj.className = menuObj.className+'-act' ;
		}
		// Now look for the parent menu Object
		if (menuObj.getAttribute) {
			mmenuId = menuObj.getAttribute("mmenu") ;
			if (mmenuId) {
				mainMenuObj = document.getElementById(mmenuId) ;
				if (mainMenuObj) {
					mainMenuObj.className = mainMenuObj.className+"-act" ;
				}
			}
		}
	}
}

