$(document).ready(function() {
	var currentPos = $("div#cursor").css("left");
	var currentWidth = $("div#cursor").css("width");
	
    $("li.nav a").mouseover(function() {
        var leftVal = $(this).offset().left - $("#gnav").offset().left + 19;
        var widthVal = $(this).width() - 38;
        $("div#cursor").stop().animate({
            opacity: 1,
            width: widthVal,
            left: leftVal
        },
        {
            duration: 500,
            easing: "easeOutSine"
        });
		//alert(leftVal + " " + widthVal);
    });
    $("#gnav").bind('mouseleave',
    function() {
        $("div#cursor").stop().css({
            opacity: 0,
            width: currentWidth,
            left: currentPos
        })
        .animate({
            opacity: 1
        },
        {
            duration: 500
        });
    });
	$("#gnav #home").hover(function() {
        $("div#cursor").stop()
        .animate({
            opacity: 0
        }, 300
        ).css({
		    width: currentWidth,
            left: currentPos
		})}, function() {
        $("div#cursor").stop()
        .animate({
            opacity: 0
        }, 300
        ).css({
		    width: currentWidth,
            left: currentPos
		});
	});
	
	$("#leftnav, #rightnav").mouseover(function() {
        $(this).css({
            opacity: 0.5
        }).animate({
            opacity: 1
        },
        200);
    });
});
