var over = false;
var timer;
	
function hideSubnav() {
	if(over) { return; }
	$('.subnav').hide();
	$(".nav").removeClass('highlight');
}


$(document).ready(function(){
	//Init Start
	hideSubnav();
	//Init End
	
	//$('ul#topnav').superfish();
	$(".nav").hover(
		function () {
			var id = $(this).attr('id');
			$('.subnav').hide();
			$(".nav").removeClass('highlight');
			if($(this).attr('id') !== '') { $(this).addClass('highlight'); }
			$('#'+id+'_subnav').show();
			over = true;
			clearTimeout(timer);
		}, 
		function () {
			over = false;
			timer = setTimeout ( function() {
				hideSubnav();
			}, 1000);
		}
	);
	
	$(".subnav").hover(
		function () {
			over = true;
			clearTimeout(timer);
		}, 
		function () {
			over = false;
			timer = setTimeout ( function() {
				hideSubnav();
			}, 1000);
		}
	);
	
	

});