$(function () {

    var $el, leftPos, newWidth,
        $mainNav = $("#typeSoft");


    if ($(".current_page_item").length == 0) { $mainNav.append("<li class='current_page_item'><a style='display: none;' /></li><li id='magic-line' style='width: 0px'></li>"); }
        else
    $mainNav.append("<li id='magic-line'></li>");
    var $magicLine = $("#magic-line");


    $magicLine
            .width($(".current_page_item").width())
            .css("left", $(".current_page_item a").position().left)
            .data("origLeft", $magicLine.position().left)
            .data("origWidth", $magicLine.width());


    $("#typeSoft li a").hover(function () {
        $("#magic-line").show();
        $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")
        });
    });
});
