function animatedObject(elementName,loop,speed,steps,endRoutines,route){
  this.elementName = elementName;
  this.loop = loop;
  this.speed = speed;
  this.steps = steps;
  this.frameIndex = 0;
  this.endRoutines = endRoutines;
  this.route = route.split(',');
  this.animate = animateObject;
  this.move = moveObject;
  this.show = showObject;
  this.hide = hideObject;

  animatedObjects[elementName] = this;
}

function stopTimeline(timelineNumber){
   animationTime[timelineNumber] = animationTimeline[timelineNumber].length;
}


function startTimeline(timelineNumber) {
  animationTime[timelineNumber] = 0;
  timelineController(timelineNumber);
}

function timelineController(timelineNumber) {
    if (animationTime[timelineNumber] <= animationTimeline[timelineNumber].length - 1) {
      animationTime[timelineNumber]++;
        if (animationTimeline[timelineNumber][animationTime[timelineNumber]] != null){
          eval(animationTimeline[timelineNumber][animationTime[timelineNumber]]);
        }
        setTimeout('timelineController(' + timelineNumber + ')', 100);
    }
}

function showObject(){
  eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.visibility = "visible"');
}

function hideObject(){
  eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.visibility = "hidden"');
}

function moveObject(left, top){
  eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.top = top');
  eval(layerObj + '["' + this.elementName + '"]' + styleObj + '.left = left');
}

function animateObject(){
    if (this.route.length > 4 && this.frameIndex < this.route.length)  {
      this.move(this.route[this.frameIndex], this.route[this.frameIndex + 1]);
      this.frameIndex += 2;
      setTimeout('animatedObjects["' + this.elementName + '"].animate()', this.speed);
    }
    else if (this.route.length == 4 && this.frameIndex <= this.steps) {
      this.move(parseInt(this.route[0]) + (this.frameIndex * ((parseInt(this.route[2]) -
parseInt(this.route[0])) / this.steps)), parseInt(this.route[1]) + (this.frameIndex *
((parseInt(this.route[3]) - parseInt(this.route[1])) / this.steps)));
      this.frameIndex++;
      setTimeout('animatedObjects["' + this.elementName + '"].animate()', this.speed);
    }
    else {
      eval(this.endRoutines + "");
      this.frameIndex = 0;
        if (this.loop == "yes"){
          this.animate();
        }
    }
}

function initAnimation() {

  layerObj = (isNS) ? 'document' : 'document.all';
  styleObj = (isNS) ? '' : '.style';

  animationTime = new Array();
  animationTimeline = new Array();
  animatedObjects = new Object();

  wheel = new animatedObject('wheelh', 'no', 40, 80, 'null', '523,-100,523,18');
  robot1 = new animatedObject('robot1h', 'no', 40, 80, 'null', '500,130,500,32');
  robot2 = new animatedObject('robot2h', 'no', 40, 80, 'null', '500,130,500,50');
  robot3 = new animatedObject('robot3h', 'no', 40, 80, 'null', '500,130,500,68');
  robot4 = new animatedObject('robot4h', 'no', 40, 80, 'null', '500,130,500,86');
  robot5 = new animatedObject('robot5h', 'no', 40, 80, 'null', '500,130,500,104');
  robot6 = new animatedObject('robot6h', 'no', 40, 80, 'null', '500,130,500,122');
  robot7 = new animatedObject('robot7h', 'no', 40, 80, 'null', '500,130,500,140');
  robot8 = new animatedObject('robot8h', 'no', 40, 80, 'null', '500,130,500,158');
  robot9 = new animatedObject('robot9h', 'no', 40, 80, 'null', '500,130,500,176');
  robot10 = new animatedObject('robot10h', 'no', 40, 80, 'null', '500,130,500,194');
  robot11 = new animatedObject('robot11h', 'no', 40, 80, 'null', '500,130,500,212');
  robot12 = new animatedObject('robot12h', 'no', 40, 80, 'null', '500,130,500,230');
  animationTimeline[0] = new Array();

  animationTimeline[0][20] = 'robot1.show(); robot2.show(); robot3.show(); robot4.show(); robot5.show(); robot6.show(); robot7.show(); robot8.show(); robot9.show(); robot10.show(); robot11.show(); robot12.show(); robot1.animate(); robot2.animate(); robot3.animate(); robot4.animate(); robot5.animate(); robot6.animate(); robot7.animate(); robot8.animate(); robot9.animate(); robot10.animate(); robot11.animate(); robot12.animate();';
  animationTimeline[0][19] = 'wheel.show(); wheel.animate();';
  startTimeline(0);
}

var layerObj, styleObj, totalTime, currTime;
var animationTime, animationTimeline, animatedObjects;
var bon, boff;

var isNS = (navigator.appName == "Netscape");
var isDHTML = (parseInt(navigator.appVersion) > 3);