$(document).ready(function() {
			   			   
	var t; 
	var t2;
	var isHovered = false;
	var length = 200;
	function isHoveredFalse(){
	isHovered = false;
	}

	$("#main-nav > li").hover(
		
		function() {
			
			thisNav = $(this);
			clearTimeout(t);
			clearTimeout(t2);
			if(isHovered == false){						
				t = setTimeout("thisNav.children('.sub1').show();thisNav.parent().addClass('showBackground');", length);
				isHovered = true;
			}
			else{
				thisNav.children('.sub1').show();
				thisNav.parent().addClass('showBackground');
			}
			
		},
		function() {
			clearTimeout(t);
			//isHovered = false;
			t2 = setTimeout(isHoveredFalse, 100);
			$(this).children('.sub1').hide();
			$(this).parent().removeClass('showBackground');
					
		});
});      

