// animation af sol hop

var sol = {navn: "sol", tid: -1};
var rammer = new Array();


sol.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 = 90;
  this.i = 0;
  this.j = 0;
  this.tid = -1;
  sol.interval(200);
}


sol.interval = function(ant)
{
  clearInterval(this.tid);
  this.tid = setInterval("sol.walk()", ant);
}


sol.walk = function()
{
//  this.i = this.j%this.ant;
  this.i = Math.round((this.j*(this.ant-1))/this.max);


  rammer[(this.i -1 +this.ant)%this.ant].id.style.visibility = "hidden";

  if (this.j == 0) 
  {
    this.left = Math.round(50*Math.random())%50;
    this.top  = 250+Math.round(50*Math.random())%50;
    sol.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 + 8;
  this.top = this.top + 4*(Math.round((this.j*3/this.max) + Math.random() - 2));

  if (this.j > this.max) 
  {
    this.j = 0;
    sol.interval(2000);
  }
}


// 1 2 3 4 5 6     3 6 9 12 15 18  0 1 1 2 2 3   0 0 1 1 2 2
sol.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 + "%";
}





