/*
   Javascript for type-writing a text and underline it
*/

var typing = {

length:0, n:0, delay:150,

spanID:function(number)
{
  return document.getElementById("messageChar" + number).style;
},

character:function()
{
  this.spanID(this.n).visibility = "visible";

  this.n++;

  if(this.n < this.length)
    setTimeout("typing.character()",this.delay);
  else
  {
    this.n = 0;

    setTimeout("typing.underline()",this.delay);
  }
},

underline:function()
{
  this.spanID(this.n).textDecoration = "underline";

  this.n++;

  if(this.n < this.length)
    setTimeout("typing.underline()",this.delay);
},

header:function()
{
  var message = document.getElementById('header').innerHTML;

  this.length = message.length;

  var text = '';

  for(var m = 0; m < this.length; m++)
    text += '<span id="messageChar'+ m +'" style="visibility:hidden">' + message.charAt(m) + '</span>';

  document.getElementById('header').innerHTML = text;

  this.n = 0;

  this.character();
}
}

