var NumDrops=10;
DropX = new Array(NumDrops);
DropY = new Array(NumDrops);
DropV = new Array(NumDrops);
DropS = new Array(NumDrops);
DropT = new Array(NumDrops);

for (var i = 0; i < NumDrops; i++) {
	DropX[i]=0;
	DropY[i]=9999;
	DropV[i]=64;
	DropS[i]=1;
}

var Height=15;
var Width=25;

var TimerID = 0;

Pic = new Array(Height*Width);
PicT = new Array(Height*Width);

var NumStrings=6;
Strings=new Array();
Strings[0]="  ···`´¨'ˆ•~¹×…’÷“˜‹—ªª¡³;{>¦¸«|/\%%ii¤l‡tí77î&¯¿ƒ$6wwYe‰TöZFÏú£";
//Welcome to the matrix...
Strings[1]="    ...xirtam eht ot emocleW";
//This is my home...
Strings[2]="    ...emoh ym si sihT";
Strings[3]="    ··`´¨'ˆ•~¹×…’÷“˜‹—ªEMOCLEW";
//Can this be real?
Strings[4]="  ?laer eb siht naC";
//and the devil may care, but I don't mind.
Strings[5]="    ...dnim t'nod I tub ,erac yam lived eht dna..."


function SetPic(x,y,v,t) {
	Pic[y*Width+x]=v;
	PicT[y*Width+x]=t;
}

for (var y=0; y<Height ; y++) {
  for (var x=0; x<Width ;x++) {
    SetPic(x,y, 0, 0);
  }
}


function GetPic(x,y) {
	return Pic[y*Width+x];
}

function GetPicT(x,y) {
	return PicT[y*Width+x];
}

function GetChar(value,t) {
	if (value > Strings[t].length-1) value=Strings[t].length-1;
	if (value < 0) value=0;
	return Strings[t].charAt(value)
}

function Update() {

  IntroFrame.document.open();

  IntroFrame.document.writeln('<HTML><BODY text="#FFFFFF" bgcolor="#000000"><CENTER><TABLE><TR><TD><PRE>');

  for (var y=0; y<Height; y++) {
    var a = "";
    for (var x=0; x<Width;x++) {
//	alert(x+","+y+","+GetPic(x,y)+","+GetPicT(x,y));
      a= a + " " + GetChar(GetPic(x,y),GetPicT(x,y));
    }
    IntroFrame.document.writeln(a);
  }
 
  IntroFrame.document.writeln("</pre></td></tr></table></center></body></html>");
  IntroFrame.document.close();
}

function FadePic(fade,min) {
var a = 0;
  for (var y=0; y<Height; y++) {
    for (var x=0; x<Width;x++) {
      a= GetPic(x,y);
      if (a > min) {
          a -= fade;
	  if (a < min) a = min;
	  SetPic(x,y,a,GetPicT(x,y))
      }
    }
  }

}

function CreateFrame() {
   FadePic(1,0);
   for (var i = 0; i < NumDrops; i++) {
      DropY[i] += DropS[i];
      if (DropY[i] > Height) {
		DropY[i]=0;
		DropX[i]=Math.round(Math.random()*(Width-1));
	var b = Math.round(Math.random() * (NumStrings*3));
//	if (b==5) alert(b);
	if (b < NumStrings) {
		DropS[i]=1;
		DropV[i]= Strings[b].length - 1;
		DropT[i]=b;
		//alert("FADSFJA");
	} else {
		DropS[i]=Math.random()*.85+.15;
		DropV[i]=Math.round(Math.random()*55)+5;
		DropT[i]=0;
	}
//	alert(DropT[i]);
      }
//      SetPic(DropX[i],Math.round(DropY[i]),DropV[i]+GetPic(DropX[i],Math.round(DropY[i])));
      SetPic(DropX[i],Math.round(DropY[i]),DropV[i],DropT[i]);
//	alert(DropX[i] + "," + DropY[i] + "," + DropV[i] + "," + DropS[i]);
}
}

function NewFrame() {
	CreateFrame();
	CreateFrame();
	CreateFrame();
	Update();
	timerID=setTimeout('NewFrame()',500);
}

function Startup() {

//for (var i = 0; i < Height*3; i++) {CreateFrame();}
NewFrame();

}