var backgroundColors = ['#00ffd2', '#00ffb4', '#00ffe4'];

var loopColors = function() {
    var otherElements = $('#wrapper');
    $('body').animateBackgroundColor(backgroundColors[1], otherElements)
        .animateBackgroundColor(backgroundColors[0], otherElements)
        .animateBackgroundColor(backgroundColors[2], otherElements)
        .animateBackgroundColor(backgroundColors[0], otherElements, loopColors);
};

$.fn.animateBackgroundColor = function(color, otherElements, callback) {
    return this.each(function() {
        $(this).animate({'backgroundColor':color}, {
            duration: 5000, 
            easing: 'linear', 
            step: function(){ 
                if (otherElements) otherElements.css('backgroundColor', $(this).css('backgroundColor')); 
            },
            complete: callback
        });
    });
};

$(function() {
    loopColors();
});