﻿// JScript File
// A Trouble Halved Ltd 2008

<!--
var text="Default News content is here";
var delay=40;
var currentChar=1;
var destination="[not defined]";
var nextLine = 0;
var countChar = 1;

function type()
{
  if (document.getElementById)
  {
    var dest=document.getElementById(destination);
    if (dest)
    {
      
      dest.innerHTML=text.substr(nextLine, currentChar);
      currentChar++;
      countChar++;
      
      if (countChar>text.length)
      {
        currentChar=1;
        countChar=1;
        nextLine = 0;
        setTimeout("type()", delay);
      
      } else if (text.substr(countChar, 1) == "~") {
        nextLine = countChar + 1;
        currentChar = 1;
        dest.innerHTML = "";
        setTimeout("type()", delay);
      } else if (text.substr(countChar + 1, 1) == "~") {
         setTimeout("type()", 5000);
      }  else  {
        setTimeout("type()", delay);
      }
    }
  }
}

function startTyping(textParam, delayParam, destinationParam)
{
  text=textParam;
  delay=delayParam;
  currentChar=1;
  nextLine =0;
  destination=destinationParam;
  type();
}