/* Copyright 2008 - Lorenzo Sfarra */

/* Colors for the fade effect on the text */
cols = new Array ();
cols[0] = '#333333';
cols[1] = '#888888';
cols[2] = '#aaaaaa';
cols[3] = '#cccccc';
cols[4] = '#f8f8f8';
cols[5] = '#ffffff';
x = 15.0;
y = 0.31;


function bigbang () {
  /* Coordination of the the presentation.
   * Set the correct timeout to display/hide a div. */
  
  startClock ();
  displayText ('first');
  setTimeout ("hideText ('first');", 3000);
  setTimeout ("displayText ('second');", 3000);
  setTimeout ("hideText ('second');", 6000);
  setTimeout ("displayText ('third');", 6000);
  setTimeout ("hideText ('third');", 9000);
  setTimeout ("displayText ('fourth');", 9000);
  setTimeout ("hideText ('fourth');", 12000);
  setTimeout ("displayText ('fifth');", 12000);
  setTimeout ("hideText ('fifth');", 15000);
  setTimeout ("showLogo ();", 16000);
  setTimeout ("showML ();", 17000);
  setTimeout ("showHP ();", 17500);
}

function displayText (divname) {
  var obj = document.getElementById (divname);
  obj.style.display = 'block';
  for (var i = cols.length - 1; i >= 0; i--) {
    setTimeout("document.getElementById('" + divname + "').style.color = cols[" + i + "]", i * 100);
  }
}

function hideText (divname) {
  var obj = document.getElementById (divname);
  for (var i = cols.length - 1, j = 0; i >= 0; i--, j++) {
    setTimeout("document.getElementById('" + divname + "').style.color = cols[" + j + "]", i * 200);
    obj.style.display = 'none';
  }
}

function showLogo () {
  var obj = document.getElementById ('logo');
  var body = document.getElementsByTagName ("body")[0];
  body.style.backgroundColor = "#000";
  body.style.backgroundImage = "url('intro/background.png')";
  body.style.backgroundRepeat = "no-repeat";
  body.style.backgroundPosition = "right top";
  obj.style.display = "block";
}

function showML () {
  var obj = document.getElementById ('ml');
  obj.style.display = "block";
}

function showHP () {
  var obj = document.getElementById ('homepage');
  obj.style.display = "block";
}


function startClock() {
  x = x - y;
  countdown = document.getElementById ('countdownp');
  var b = x.toString ();
  if (b.length > 4)
    countdown.innerHTML = "- " + x.toString().substring (0, 4);
  else
    countdown.innerHTML = "- " + x.toString().substring (0, 3);
    
  if (x <= 0)
    countdown.style.display = "none";
  else
    setTimeout("startClock()", 320);
}
