var Beginning = function(){
  var obj = {
    text : {
      time: MUSIC.barLength,
      s: [
        "YARR to all ALT-pirates!",
        "",
        "It's time to celebrate Paraguay's first birthday!",
        "We are now a year older and maybe a bit wiser...",
        "It has been a wonderful year of learning.",
        "",
        "Join to celebrate with us and remember:",
        "do{ drink; }while( tunnel );"
      ]
    },
    ended : false,
  };
  
  var started = false;
  var faded = false;
  var end = MUSIC.syncPoints.verse1+(MUSIC.barLength*4);
  var next = {line: 0, letter: 0};
  var cursor = "|";
  var element = document.getElementById("beginning");
  var textElement = document.getElementById("text");
  var lastUpdate = 0;
  
  obj.changeText = function(elapsedTime, tic){
    if(next.line < obj.text.s.length && elapsedTime >= obj.text.time){
      if(!started){
        element.style.position = "absolute";
        element.style.top = (TDEMO.height/4.1).toString() + "px";
        element.style.left = (TDEMO.width/4.1).toString() + "px";
        element.style.display = "block";
        element.style.opacity = 0.8;
        textElement.style.display = "inline";
        started = true;
      }
      
      if(next.letter < obj.text.s[next.line].length){
        if(tic){
          var str = textElement.innerHTML;
          str = str.substring(0, str.length - 1);
          textElement.innerHTML = str+obj.text.s[next.line][next.letter]+cursor;
          ++next.letter;
        }
      }
      else if(next.letter >= obj.text.s[next.line].length){
        var str = textElement.innerHTML;
        str = str.substring(0, str.length - 1);
        textElement.innerHTML = str + '<br>' + cursor;
        next.letter = 0;
        ++next.line;
      }
    }
    else if(next.line >= obj.text.s.length && elapsedTime >= end && !obj.ended){
      if(parseFloat(element.style.opacity) <= 0.0){
        obj.ended = true;
        element.style.display = "none";
        textElement.style.display = "none";
        obj.ended = true;
      }
      else{
        element.style.opacity = parseFloat(element.style.opacity)-0.05;
      }
    }
  }
  
  return obj;
}