$(document).ready(function() {

	$("a.shadowbox").attr("rel","shadowbox");

	var active = false;
	var height = $("#menu").outerHeight() + 145;
	var oldsrc = "links-about";
	
	$("#menu").css({"margin-top": "-"+height+"px"});
	$("#menu").show();
	
	$("#nav li.about a, #nav li.lastinger a, #nav li.teacher a, #nav li.early a, #nav li.child a, #nav li.online a, #nav li.innovations a").mouseenter(function(){
		if(oldsrc == null){oldsrc == 'links-about'}
		title = $(this).children("img").attr('alt');
		newsrc = title.toLowerCase();
		newsrc = newsrc.replace(/\s+/g, '-');
		
		//hide the current links
		$('#menu .links-'+oldsrc).hide();
		$('#menu .'+oldsrc+'-section').hide();
		$('#menu .'+oldsrc+'-container').hide();
		$('#menu .links-'+oldsrc).css({'display': 'none'});
		//show the new links
		$('#menu .links-'+newsrc).show();
		$('#menu .'+newsrc+'-section').show();
		$('#menu .'+newsrc+'-container').show();
		oldsrc = newsrc;
		height = $("#menu").outerHeight() + 130;
		
		newsrc = "http://205.186.139.237/wp-content/themes/lastinger-center/images/tt-menu-" + newsrc + ".png";
		$("#menu .title img").attr("src", newsrc);
		
	});

	$("#nav li.about, #nav li.lastinger, #nav li.teacher, #nav li.early, #nav li.child, #nav li.online, #nav li.innovations, #menu, .top-shadow").hover(function(){
		if($(this).is("#nav > li") == true || $(this).is("#menu") == true){
			active = true;
		}else if(active == false){
			return false;
		}
		$("#menu").stop(true, false).animate({"margin-top": "0"}, 500, "swing"); //show the dropdown menu
  	}, 
  	function(){
  		if(active == true){
		$("#menu").stop(true, false).animate({"margin-top": "-"+height+"px"}, 500, "swing", function(){
			active = false;
		});
		}	
  	});
});
