var people = new Array(8);
var famouspeople = 0;
var direction;
var begin;
var nextpeople;
var imagesLoaded = 0;

for (var i=0; i < 8; ++i) {
people[i] = new Image();
people[i].src = "people2/famouspeople" + i + ".jpg";
people[i].onLoad = loadNext();
}

function loadNext() {
++imagesLoaded;
 if (imagesLoaded == 1)
  nextpeople = setInterval("rock()",3500);
}

function rock() {
 if (famouspeople == 0)
  direction = "right";

 if (famouspeople == 8)
  famouspeople = 1;	


 if (direction == "right")
  ++famouspeople;

 else if (direction == "left")
  --famouspeople;document.animation.src = people[famouspeople].src;
}