// animation af ole hop

var ole = {navn: "ole", tid: -1};
var rammer = new Array();


ole.start = function(ant)
{
  this.ant = ant;
  
  for (var i = 0; i < this.ant; i++)
  {
    rammer[i] = new Object();
    rammer[i].id = document.getElementById(this.navn + i);
  }

  this.left = Math.round(100*Math.random())%100;
  this.top  = 200+Math.round(200*Math.random())%200;

  this.max = 25;
  this.i = 0;
  this.j = 0;
  this.tid = -1;
  ole.interval(300);
}


ole.interval = function(ant)
{
  clearInterval(this.tid);
  this.tid = setInterval("ole.walk()", ant);
}



ole.walk = function()
{
  this.i = this.j%this.ant;

  rammer[(this.i -1 +this.ant)%this.ant].id.style.visibility = "hidden";

  if (this.j == 0) 
  {
    this.left = Math.round(100*Math.random())%100;
    this.top  = 200+Math.round(200*Math.random())%200;
    ole.interval(200);
  }

  if (this.j < this.max) 
  {
    rammer[this.i].id.style.top = this.top;
    rammer[this.i].id.style.left = this.left;
    rammer[this.i].id.style.visibility = "visible";
  }

  this.j = this.j + 1;
  this.left = this.left + 25;

  if (this.j > this.max) 
  {
    this.j = 0;
    ole.interval(2000);
  }
}



ole.hop = function()
{
  this.left = 10+Math.round(100*Math.random())%70;
  this.top = 10+Math.round(100*Math.random())%70;
  this.id.style.left = this.left + "%";
  this.id.style.top = this.top + "%";
}





