$(document).ready(function(){

	// Main nav functionality
	$('#nav li a:has(+ ul)').toggle(function(a){
		$('ul:first',$(this).parent()).slideDown();
		console.log(a);
		return false;
	},function(){
		$('ul:first',$(this).parent()).slideUp();
		return false;
	});
	
	// Main nav - open nav to appropriate place
	$('#nav li.active > ul:last-child').show();
	
	// Sub-nav hover states
	$('#column #subnav a').hover(function(){
		var tmpClass = $(this).parent().attr('class');
		$('#content #subnav .'+tmpClass+' img').show();
	},function(){
		tmpClass = $(this).parent().attr('class');
		$('#content #subnav .'+tmpClass+' img').hide();
	});
	
	// Work-around for floating elements to the bottom
	setFooterPosition();
	$(window).bind('resize',setFooterPosition);
});

function setFooterPosition()
{
	$("#grad-left").css("height","auto");
	if($("#grad-left").height() < $(window).height())
		$("#grad-left").css("height", $(window).height());
}
