// ******************************
// Extract the last peace of a path name, which is separated by a forward slash
// ******************************
function ExtractFileName( path )
{
	if( path == null )
		return "";
		
	var li = path.lastIndexOf( "/" ); 
	if( li < 0 )
		return path; 		// no forward slash: return full name
	
	return path.substr( li + 1 );	// return string after last slash
}

// ******************************
// Mark the links, which lead to the current page
// Easy for the left menu...
// For the top menu: mark the link which leads to the first
// entry in the left menu (if there is one)
// The class 'current' is used for both top and left menu
// in order to mark the current page. 
// ******************************

function MarkCurrentPage() 
{ 
	 if (!document.getElementsByTagName) 
		return;  

	var lmFirstEntry = "";		// first left menu element

	var tmEntries = new Array();	// array of top menu elements
	var tmCount = 0;

	var anchors = document.getElementsByTagName("a"); 

	 for (var i=0; i<anchors.length; i++) 
	 {  
		var anchor = anchors[i]; 
	
		if( anchor.className == "LeftMenu" )
		{
			if( lmFirstEntry == "" )
				lmFirstEntry = anchor.getAttribute("href");
				
			// alert( "location.pathname = " + location.pathname + "\nhref = " + anchor.getAttribute("href")  +"\n" + ExtractFileName( location.pathname )  + "\n" + ExtractFileName( anchor.getAttribute("href")) );

			if ( ExtractFileName( location.pathname ) == ExtractFileName( anchor.getAttribute("href")  )) 
			{
				anchor.className = "currentLM"; 
			} 
		}

		else if( anchor.className == "TopMenu" )
		{
			tmEntries[ tmCount++] = anchor;
			if ( ExtractFileName( location.pathname ) == ExtractFileName( anchor.getAttribute("href")  )) 
			{
				anchor.className = "currentTM"; 
			} 
		}

	 }  
	 
	 for( var i = 0; i < (tmEntries.length) && (lmFirstEntry != ""); i++ )
	 {
		if( tmEntries[ i ].getAttribute( "href" ) == lmFirstEntry )
		{
			tmEntries[ i ].className = "currentTM";
			return;
		}
	 }

}  


