
$(document).ready(function () {
	
	var topnav = $('#top-nav').children();
	topnav.activeId = topnav.filter('.active').attr('id');

	function slideIn(id) {
		
		if(topnav.activeId === id) {
			return; //subnav already active
		}
		
		var newsub = $('#sub-'+id);
		var oldsub = $('#sub-'+topnav.activeId);

		topnav.activeId = id;
		
		if(oldsub.length !== 0) {
			oldsub.stop().animate({fontSize: 0, left: 1000}, 400);
		}
		
		if(newsub.length !== 0) {
			newsub.stop().css({left: 0, fontSize: 0}).animate({fontSize: 25}, 400);
		}	
	}
	

	$('#top-nav li').hover(
		function () {
			slideIn($(this).attr('id'));
		},
		function () {
			//
		}
	);

});
