var ola_a_todos = document.getElementById("ola_a_todos");
var os_q_vivem = document.getElementById("os_q_vivem");
var disc = document.getElementById("disc");
var menina_chateada = document.getElementById("menina_chateada");
var menina_feliz = document.getElementById("menina_feliz");

var countRepeat = 0;
function animation() {

  TweenLite.delayedCall(0.5, function () {
    const duration = 0.5;
    TweenLite.to(ola_a_todos, duration, { scale: 1, ease: Bounce.easeOut });
    TweenLite.to(ola_a_todos, duration, { opacity: 1, ease: Power2.easeOut });
    TweenLite.to(os_q_vivem, duration, { scale: 1, ease: Bounce.easeOut }).delay(0.7);
    TweenLite.to(os_q_vivem, duration, { opacity: 1, ease: Power2.easeOut }).delay(0.7);
  });
  TweenLite.delayedCall(4, function () {
    const duration = 0.4;
    TweenLite.to(menina_chateada, duration, { opacity: 0, ease: Power0.easeNone });
    TweenLite.to(menina_feliz, duration, { opacity: 1, ease: Power0.easeNone });
    TweenLite.to(ola_a_todos, duration, { left: '-100%', ease: Power0.easeNone });
    TweenLite.to(os_q_vivem, duration, { left: '-100%', ease: Power0.easeNone });
    TweenLite.to(disc, duration, { left: 0, ease: Power0.easeNone });
  });
  if (countRepeat < 2) {
    TweenLite.delayedCall(8, function () {
      const duration = 0.4;
      TweenLite.to(menina_feliz, duration, { opacity: 0, ease: Power0.easeNone });
      TweenLite.to(disc, duration, { left: '-100%', ease: Power0.easeNone });
      TweenLite.to(menina_chateada, duration, { opacity: 1 });
    });
  }
  TweenLite.delayedCall(10, function () {
    restartAnim();
  });
}

TweenLite.delayedCall(0.2, function () {
  animation();
});

function restartAnim() {
  if (countRepeat < 2) {
    countRepeat++;
    TweenLite.to(ola_a_todos, 0, { scale: 3 });
    TweenLite.to(ola_a_todos, 0, { opacity: 0 });
    TweenLite.to(ola_a_todos, 0, { left: 40 });
    TweenLite.to(os_q_vivem, 0, { scale: 0 });
    TweenLite.to(os_q_vivem, 0, { left: 5, onComplete: animation });
  }
}