$(function(){

    var $el, leftPos, newWidth,
          $mainNav2 = $("#navibar");

    $mainNav2.append("<li id='navi'></li>");
    
    var $naviBar = $("#navi");
    
    $naviBar
        .width($(".current").width())
        .height($mainNav2.height())
        .css("left", $(".current a").position().left)
        .data("origLeft", $(".current a").position().left)
        .data("origWidth", $naviBar.width())
        .data("origColor", $(".current a").attr("rel"));
                
    $("#navibar li").find("a").hover(function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        $naviBar.stop().animate({
            left: leftPos,
            width: newWidth,
            backgroundColor: $el.attr("rel")
        })
    }, function() {
        $naviBar.stop().animate({
            left: $naviBar.data("origLeft"),
            width: $naviBar.data("origWidth"),
            backgroundColor: $naviBar.data("origColor")
        });    
    });
});
