$(function() {
	$('#navigation .head').click( function() { return false; });
	$('#navigation .section > .container').css('opacity', 0.9);	
	
	var current = $('#navigation a').not('.head').filter(function() { return location.href.indexOf(this.href) != -1; });
	
	if (current.size()) {
		current.addClass('current');
		current.parents('div.section, div.subSection, div.container').addClass('selected');
		current.parents('div.section').children('.head').addClass('current');
	}
	
	var open_timers = new Array();
	var close_timers = new Array();
	
	function open(e) {
		$(e).addClass('over');		
		$('> .container', e).slideDown(300);
	}	
		
	function close(e) {
		$('> .container', e).slideUp(300, function() {
			$(e).removeClass('over');	
		});	
	}		
	
	$('#navigation .section').hover(
		function() {
			var e = this;
			clearTimeout(close_timers[$(e).attr('id')]);
			open_timers[$(e).attr('id')] = setTimeout(function() { open(e); }, 200);			
		},
		function() {
			var e = this;
			clearTimeout(open_timers[$(e).attr('id')]);
			close_timers[$(e).attr('id')] = setTimeout(function() { close(e); }, 100);
		}
	);
});