$(document).ready(function(){
	
	$changeWidth = false;
	
	//check browser and version to add margin to right of main nav for IE7
	 jQuery.each(jQuery.browser, function(i, val) {
     	if( i == 'msie' && jQuery.browser.version == '7.0' )
		{ $changeWidth = true; }
    });

	if( $changeWidth ) $("#nav ul").css("margin-right","10px");
	
	$("#nav > ul > li > a").not(".current").next("ul").hide(); //hide all subnavs
	
	var $isCurrent = $("#nav ul li a.current");
	var $timeOut;

	$("#nav > ul > li").hover(
		function(){			
			clearTimeout($timeOut); //clear timeout set in hover out
			
			$('#nav > ul > li').each(function() {
				$(this).children("a").removeClass("current").next("ul").hide(); //clear all tabs and hide their subnavs
			});
			
			$(this).children("a").addClass("current").next("ul").show(); //set current to tab and show subnav
		},
		function(){			
			var cur = $(this);
			var def = $isCurrent;
			$timeOut = setTimeout(function(){
				cur.children("a").removeClass("current").next("ul").hide();
				def.addClass("current");
				def.addClass("current").next("ul").show();
			}, 1000);
		}
	);
	
});