var t;

function navHover(id) {

		//show its submenu
		$('ul.sub', id).animate({ opacity: 1 }, 100, function() {});
    	$('ul.sub', id).slideDown(100);
    	clearTimeout(t);
	}

$(document).ready( function() {
	
	$('#nav li').hover(
	    function () {
	    	var elem = this;
	    	t = setTimeout(function(){navHover(elem);elem=null;},200);  // elem = null is for an IE memory leak bug. YAY IE!
	    		
	    		
        },
        function () {
        	
        	// clear the timeout if the animation hasn't started to avoid delayed animation
        	clearTimeout(t);
        	
            //hide its submenu
        	$('ul.sub', this).animate({opacity: 0}, 100, function() {});
        	$('ul.sub', this).slideUp(100);
    });


});
