function setNav(colorTheme)
{
	//Get Current URL and Pagename
	var currentURL = document.location.href.split("/");
	var currentFileName = currentURL[currentURL.length - 1];

	// Get Array of navigation td cells
	var navTDCells = getElementbyClass('navNormal');
	
	var LevelArray = new Array();
	var ObjectArray = new Array();
	
	var openPos = -1;
	var openIndent = -1;
	
	// Loop the navigation cells
	for( i=0;i<navTDCells.length; i++ )
	{
		var tdCell = navTDCells[i];
		
		try
		{
		// Find td cell that contains a link of current page
		if( tdCell.firstChild.href.indexOf(currentFileName) >= 0 )
		{
			// Set indent empty or 2-4 (navNormal, navNormal2, navNormal3, ...)		
			var indent = tdCell.className.charAt( tdCell.className.length-1 );
			if( !IsNumericChar(indent) )
				indent = '';
			
			// Set TD class with color theme
			tdCell.className = colorTheme + 'NavActive' + indent;
			
			// Set Href class
			tdCell.firstChild.className = 'navActive';


			openPos = i;
			if( !IsNumericChar(indent) || indent == '')
				openIndent = 1;
			else
				openIndent = parseInt( indent );
		}
		}
		catch(e)
		{
			
		}
		
		LevelArray[i] = parseInt( tdCell.className.charAt( tdCell.className.length-1 ) );
		if( !IsNumericChar(LevelArray[i]) || LevelArray[i] == '')
			LevelArray[i] = 1;
		else
			LevelArray[i] = parseInt( LevelArray[i] );		
		
		
		ObjectArray[i] = tdCell;
	}
	closeAllNonRelatedNodes( LevelArray , ObjectArray, openPos, openIndent );
}

function closeAllNonRelatedNodes(lvlArray, objArray, openP, openLvl )
{
	var tmpLvl;
	if( openP == -1 ){ // Nothing is selected, close all byt highest level
		for( i=0;i<objArray.length; i++ )	
		{
			if( lvlArray[i] > 1 )
				hideTD(objArray[i]);
		}
	} else {

		//Close everything above
		tmpLvl = openLvl;
		for( i=1;i<openP; i++ )
		{
			if( lvlArray[openP - i] <= tmpLvl ){ // Up in tree
				tmpLvl = lvlArray[openP - i];
			}
			else // branch is expanded. Close/hide;
			{
				hideTD(objArray[openP - i]);
			}
		}

		//Close everything below marked node
		tmpLvl = openLvl + 1;
		for( i=openP + 1;i<lvlArray.length;i++ )
		{
			if( lvlArray[ i ] <= tmpLvl ) {// Up in tree
				tmpLvl = lvlArray[i];
			}		
			else // branch is expanded. Close/hide;
			{
				hideTD(objArray[ i ]);
			}
		}
	}
}

// Hides the nodes
function hideTD( obj )
{
	obj.style.display = 'none';
//	obj.innerHTML = '######'; //used for debug
}


// Returns array with TD's that has *classname* as class attribute
function getElementbyClass(classname){
	var partscollect;
	var ce = new Array();
	var inc=0
	var alltags=document.all? document.all : document.getElementsByTagName("TD")

	for (i=0; i<alltags.length; i++){
        if (alltags[i].className.indexOf(classname) >= 0 )
				ce.push(alltags[i]);
	}
	return ce;
} 

// Returns true if string is a numeric value
function IsNumericString(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
// Returns true if char is a numeric value   
function IsNumericChar(cChar)

{
   var ValidChars = "0123456789.";
   if( ValidChars.indexOf(cChar) == -1 )
   	return false;
	
	return true;
}   
