If I got it right, you want a background loop, well it has a CSS3 function that can do it for you, but can you imagine how this can help me? Good you can do with Javascript is add and remove class, you will need 3 items: HTM, CSS and JAVA SCRIP;
HTML
<div id="alpha" class="alpha">a</div>
CSS3
/*Alpha é uma class de cor inicial*/
    .alpha{
        width: 500px;
        height: 500px;
        background: #09f;
    }
    /*Beta é a class que faz a animação*/
    /*Ela sera adicionada e removida o tempo todo*/
    .beta{
        /*Nome da animação*/
        animation-name: cor;
        /*Tempo da animação 4s = 4 segundo / 0.5s = 0,50 segundos*/
        animation-duration: 4s;
    }
    /*Chama animação caso tenha class*/
    @keyframes cor{
        0% {background: #09f;}
        50% {background: #f00;}
        100% {background: #09f;}
    }
SCRIPT
//Define o elemento como uma variavel Global
    var elemento = document.getElementById("alpha");
    //Função principal
    function funcao(){
        //Loop por 5s setInterval(function(){}, 5000);
        setInterval(function(){ 
            //Linha abaixo é bom para verificar no console, F12 do teclado
            console.log("time");
            //Remove a class Beta
            elemento.classList.remove("beta");
            //Da um tempo de 1s para adicionar a Class Beta novamente
            setTimeout(adicionar, 1000);
        }, 5000);
    }
    //Função que adiciona a class
    function adicionar(){
        elemento.classList.add("beta");
    }
    //Chama a função principal
    window.onload = funcao();
Remember that the has to be the last content, because if not it has a chance not to find the div in the document, can have a practicalityMair using the jQuery api and some other interface control.
Good luck and good studies with your wish =D
							
							
						 
What’s the problem? Be a little more specific...
– Luiz Felipe