var initList = initList || []; 
initList.push(function() {
    /* FORCE GAME */
   
    
    
    var tiempos=["00 s","04 s","08 s","10 s"]
    var velocidades=[0 , 8 ,16 , 20 ];
    var distancias=[0 , 16 ,64 , 100 ];
    
    var forcesNames=["pesas","carro"];/*Names for the forces*/
    var index_moment=0 ;

    var forceGame=$("#force_game");

    var distSpan=forceGame.find('.img.distancia');
    var veloSpan=forceGame.find('.img.velocidad');
    var reloj=forceGame.find('.clock');

    var btnStart=forceGame.find(".start");

    var move_forces = function(){  //se hace el movimiento
        index_moment++;

        var moveClassX="moveX"+index_moment;
        var moveClassY="moveY"+index_moment;

        forceGame.find(".img.car,  .img.res,  .forces.res, .forces.car").addClass(moveClassX);
        distSpan.addClass(moveClassX);
        veloSpan.addClass(moveClassX);

        distSpan.html("");
        veloSpan.html("");
        reloj.html("");

        forceGame.find(".img.rocks").addClass(moveClassY);

        btnStart.unbind("click", move_forces).removeClass("active").addClass('disabled');
        veloSpan.one('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', 
        function() {
        //do something
            
            distSpan.html(distancias[index_moment]);
            veloSpan.html(velocidades[index_moment]);
            reloj.html(tiempos[index_moment]);


            if (index_moment==3) {
                // btnStart.unbind("click", move_forces).removeClass("active").addClass('disabled');
            }else{
                btnStart.unbind("click", move_forces).removeClass("active").addClass('disabled');
                btnStart.bind("click", move_forces).addClass("active").removeClass('disabled');
                if (index_moment==1){
                    btnStart.addClass('continuar');
                    btnStart.addClass('tada');
                }
            }
        });
    };


    var restart_forces = function(){    //vuelvo todo a los estados iniciales

        forceGame.find(" * ").removeClass('moveX1 moveX2 moveX3');
        forceGame.find(" * ").removeClass('moveY1 moveY2 moveY3');

        index_moment=0;
        distSpan.html(distancias[index_moment]);
        veloSpan.html(velocidades[index_moment]);
        reloj.html(tiempos[index_moment]);

        btnStart.unbind("click", move_forces);
        btnStart.bind("click", move_forces).addClass("active").removeClass('disabled');
        btnStart.removeClass('continuar');
        btnStart.removeClass('tada');


    };

    forceGame.find(".restart").bind("click", restart_forces);
    var begin_game=function(){    
        restart_forces();
    };
    begin_game();


   

});