/**********************************\
* LED Spectrum analyzer Javascript *
* Copyright (c) Phil Baker         *
* Permission to use provided       *
* this notice stays attached       *
* http://www.feist.com/~rlangdon   *
\**********************************/
function draw() {
 document.write("<table border=5 bgcolor=black cellpadding=3 cellspacing=0><tr><td>");
 for(y=ny-1;y>=0;y--) {
  for(x=0;x<nx;x++) {
   document.write("<img src=baroff.gif height=7 width=15>");
   if(y==0) {this[x]=0;};
  };
  if(y){document.write("<br>");};
 };
 document.write("</td></tr></table>");
};
function go() {
 setTimeout("go();",delay);
 if(Math.floor(Math.random()*2)) {
  up();
 }else{
  dn();
 };
};
function up() {
 x=Math.floor(Math.random()*nx);
 if(x>0) {
  stepup(x-1);
 };
 stepup(x);
 stepup(x);
 if(x<nx-1) {
  stepup(x+1);
 };
};
function stepup(x) {
 if(level[x]<ny) {
  level[x]++;
  document.images[im1+(ny-level[x])*nx+x].src="baron.gif";
 };
};
function dn() {
 x=Math.floor(Math.random()*nx);
 if(x>0) {
  stepdn(x-1);
 };
 stepdn(x);
 stepdn(x);
 if(x<nx-1) {
  stepdn(x+1);
 };
};
function stepdn(x) {
 if(level[x]>0) {
  document.images[im1+(ny-level[x])*nx+x].src="baroff.gif";
  level[x]--;
 };
};
