var subnavInterval;

$(document).ready(function()
{    
    $('.subnav').hide();

    $('#nav a.news, #newsNav').bind('mouseover', function() {
        showSubnav('news');
    });
    $('#nav a.news, #newsNav').bind('mouseout', function() {
        hideSubnav('news');
    });

	$('#nav a.about, #aboutNav').bind('mouseover', function() {
        showSubnav('about');
    });
    $('#nav a.about, #aboutNav').bind('mouseout', function() {
        hideSubnav('about');
    });

});                           

function showSubnav(whichOne)
{
    clearInterval(subnavInterval);
    
	switch(whichOne) {
		
		case 'news':
		$('#newsNav').show();
		$('#aboutNav').hide();
		break;
		
		case 'about':
		$('#aboutNav').show();
		$('#newsNav').hide();
		break;
	}
}

function hideSubnav(whichOne)
{    
    clearInterval(subnavInterval);
    
    subnavInterval = setInterval(function(whichOne) {
		clearInterval(subnavInterval);
         
		switch(whichOne) {
			
			case 'news':
			$('#newsNav').hide();
			break;
			
			case 'about':
			$('#aboutNav').hide();
			break;
		}
         
    }, 500, whichOne);
}
