// < areastream >
// copyright 2005
// Manuel  Schott
// finalstage.org

var filled=' ';
var queued=new Array();

function postline(line,vl)
 {
 if(vl)
  {
  while(line.length<80){line=line+' ';}
  forward(line.split(""));
  }
 else
  {
  filled=document.f.t.value;
  while(line.length<80){line=line+' ';}
  line=line.split("");
  line=line.reverse();
  backward(line.join(""),'');
  }
 }

function backward(chars,zk)
 {
 document.f.t.value=filled;
 var ln=chars.slice(0,1)+zk;
 var zk=ln;
 while(ln.length<80){ln=' '+ln;}
 document.f.t.value=filled+ln;
 if(chars.length>0)
  {
  var tout=19;
  if(chars.slice(0,1)==' '){tout=5;}
  setTimeout("backward('"+chars.slice(1,chars.length)+"','"+zk+"')",tout);
  }
 else{postchar(String.fromCharCode(10));queue(0,0,1);}
 }

function forward(chars)
 {
 var count=5;
 while(chars.length>0)
  {
  var nx=chars.shift();
  window.setTimeout("postchar('"+nx+"');",count);
  if(nx==' '){count=count+10;}else{count=count+25;}
  }
 window.setTimeout("postchar(String.fromCharCode(10))",count);
 window.setTimeout("queue(0,0,1)",count+5);
 }

function postchar(ch){document.f.t.value=document.f.t.value+ch;}

function queue(text,direction,get)
 {
 if(get)
  {
  if(queued.length>0)
   {
   var tmp=queued.shift();
   postline(tmp.shift(),tmp.shift());
   delete(tmp);
   }
  else
   {
   window.setTimeout("top.location.href='http://home.finalstage.org';",3000);
   }
  }
 else
  {
  var tmp=new Array(text,direction);
  queued.push(tmp);
  delete(tmp);
  }
 }
