// JavaScript - FISH
// Copyright Søren Rom 10.02.1999
//
// 17.10.-05.11.2002 Support for Gecko (NS6, Mozilla, Phoenix) and Opera added

// Current position for fish0..fish11
var fishPosition = new Array(200,600,450,320,200,250,50,0,180,550,440,150);
// Speed for fish0..fish11.   minus means move-to-left; positive means move-to-right.
var fishSpeed = new Array(-5,-5,-3,-3,-2,-5,-6,1,5,5,4,2);

// global ID for fish motion timeout
var timeoutID;
// object reference for fish 0-11
var obj = new Array;

function initFish() {
  // initialize object reference to the fishes
  for (i=0; i<=11; i++) {
    if (isNS4)   obj[i] = eval("document.fish"+i);
    if (isIE)    obj[i] = eval("fish"+i);
    if (isDOM)   obj[i] = document.getElementById("fish"+i);
    if (isOPERA) obj[i] = document.getElementById("fish"+i);
  }
  timeoutID = setTimeout("moveFish()", 50);
}

function moveFish() {
  // cancel current ID so repeated invocations don't trigger multiple timeouts
  clearTimeout(timeoutID)

  //move fishes one step at a time
  for (i=0; i<=11; i++) {
    fishPosition[i] += fishSpeed[i];
    if (fishPosition[i] < -100) fishPosition[i] = 800;
    if (fishPosition[i] > 800)  fishPosition[i] = -100;
    if (isNS4)   obj[i].left = fishPosition[i];
    if (isIE)    obj[i].style.pixelLeft = fishPosition[i];
    if (isDOM)   obj[i].style.left = fishPosition[i];
    if (isOPERA) obj[i].style.pixelLeft = fishPosition[i];
  }

  // call this function again after 10 ms to nudge fish
  timeoutID = setTimeout("moveFish()", 100);
  return;
}

