// DOM Ready


				   
$(function() {

	/* LOGO HIGHLIGHT */

   $("#logo").hover(function(){
   $(this).fadeTo("fast", 0.8); 
   },function(){
   $(this).fadeTo("fast", 1.0); 
   });

   /* SMOOTH SLIDE*/
   
   	$("a.top-link").click(function() {
		$("html, body").animate({
			scrollTop: $($(this).attr("href")).offset().top + "px"
		}, {
			duration: 500,
			easing: "swing"
		});
		return false;
	});
   
    var $el, leftPos, newWidth;
    
	/* MAIN MENU */
    
    /* Add Magic Line markup via JavaScript, because it ain't gonna work without */
	
	if($(".current-page").width()) {
	
		$("#menu").append("<li id='menu-underline'></li>");
		
		/* Cache it */
		var $magicLine = $("#menu-underline");
		
		$magicLine
			.width($(".current-page").width())
			.css("left", $(".current-page a").position().left)
			.data("origLeft", $magicLine.position().left)
			.data("origWidth", $magicLine.width());
			
		$("#menu li").find("a").hover(function() {
			$el = $(this);
			leftPos = $el.position().left;
			newWidth = $el.parent().width();
			
			$magicLine.stop().animate({
				left: leftPos,
				width: newWidth
			});
		}, function() {
			$magicLine.stop().animate({
				left: $magicLine.data("origLeft"),
				width: $magicLine.data("origWidth")
			});    
		});
		
		
		/* Kick IE into gear */
		$(".current-page-two a").mouseenter();
	}
    
});
