$(document).ready(function(){     
	$("ul.topnav li span").hover(function() { //When trigger is clicked...
		
	//Following events are applied to the subnav itself (moving subnav up and down)  
	$(this).find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
	
		
	$(this).parent().hover(function() {}, function() {  
		$(this).find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
	});
	
	//Following events are applied to the trigger (Hover events for the trigger)  
	}).hover(function() {
		$(this).addClass("subhover"); //On hover over, add class "subhover"
		
		var id = $(this).attr("id");
		$(this).parent().addClass("menu_sub_"+id);
		$(this).parent().removeClass("menu_"+id);
		
	}, function() {  //On Hover Out
		var id = $(this).attr("id");
		$(this).parent().addClass("menu_"+id);
		$(this).parent().removeClass("menu_sub_"+id);
		
		$(this).removeClass("subhover"); //On hover out, remove class "subhover"  
	});
	
	getViewportheight();
	
	$(window).resize(function() { getViewportheight(); });
});

function getViewportheight() {	
	if(document.getElementById('content')) {
		document.getElementById('content').style.minHeight = ($(window).height()-$('#header').height()-$('#footer').height()-20) + "px";
	}
}
