
$(document).ready(function(){

	// default
	$("#nav").hide();
	
	$("#nav li:not(:last)").hover(
		function(){
			$(this).addClass("hover");
		},
		function(){
			$(this).removeClass("hover");
		}
	);
	
	$(".close").click(function(){
		toggleWithAnimation($("#nav"), "out", 400);
	});
	
	var navTimer = '';
	$(".nav-trigger").mouseover(function(){
		navTimer = setTimeout(function() { toggleWithAnimation($("#nav:hidden"), "in", 400) } , 275);
	}).mouseout(function(){
		clearTimeout(navTimer);
	});

	
});

// this is a generic cross-browser "toggleWithAnimation" functions
// IE does not support fade in of transparent pngs,
// this function checks the browser compatability and either
// calls jquery "fadeIn" or a regular "show"
function toggleWithAnimation(obj, direction, speed){

	if(direction == "in"){
		if(jQuery.support.opacity){
			obj.fadeIn(speed);
		}else{
			obj.show();
		}
	}else if(direction == "out"){
		if(jQuery.support.opacity){
			obj.fadeOut(speed);
		}else{
			obj.hide();
		}	
	}
}