var myPath = document.URL.split('/');
var myFilename = myPath.pop();

function menuInit(){	

	$$('ul.dropdownnav li.nav').each(function(f){ 
		Event.observe(f.id, 'mouseover', function() {
     		$$('#'+f.id+' ul.drop').each(function(g){ g.show(); })
		});
		Event.observe(f.id, 'mouseout', function() {
     		$$('#'+f.id+' ul.drop').each(function(g){ g.hide(); })
		});
	})
	
}

function compareLinks(f){
	linkPath = f.getAttribute('href').split('/');
	linkFilename = linkPath.pop();
	if (linkFilename == ''){
		linkFilename = linkPath[linkPath.length-1];
	}
	
	if (linkFilename == myFilename) {
		f.addClassName('active');
		return true;
	}
	return false;
}

function setActiveState(){
	if (myFilename == ''){
		myFilename = myPath[myPath.length-1];
	}
	
	$$(".dropdownnav li.nav a.section").each(function(f){
		compareLinks(f);
	})
	
	$$('#sidepanel .nav li a').each(function(f){
		compareLinks(f);
	})
}

function start() {	
 	setActiveState();
 	menuInit();
}

Event.observe(window, 'load', start)