$(document).ready(function() {
    var durationAnim = 500,
        delayAnim    = 1000,
        isKeepOnAnim = false,
        toggleAnim = function(ele, isReverse) {
            var colorStr = isReverse ? "#717273" : "#2d58a7";
            $(ele).delay(delayAnim).animate(
                {color: colorStr},
                {
                    duration:durationAnim,
                    complete:function()
                    {
                        if(isKeepOnAnim)
                        {
                            toggleAnim(ele, !isReverse);
                        }
                    }
                }
            );
    };

    $("#top article h2 a").add("footer a").hover(function() {
        isKeepOnAnim = true;
        $(this).animate(
            {color: "#2d58a7"},
            {
                duration:durationAnim,
                complete:function()
                {
                    toggleAnim(this, true);
                }
            }
        );
    });

    $("#top article h2 a").add("footer a").mouseleave(function() {
        isKeepOnAnim = false;
        $(this).queue([]);
        $(this).stop();
        $(this).animate({color: "#333333"}, durationAnim);
    });
});

