function animatedObject(direction,startingPosition,currentPosition,endPosition,frameChange,speed,elementName,moving,loop,objectNumber,attached,delay,attachedElement,delayLimit,delayTime,returnHome,returnDirection){
this.direction = direction;
this.startingPosition = startingPosition;
this.currentPosition = currentPosition;
this.endPosition = endPosition;
this.frameChange = frameChange;
this.speed = speed;
this.elementName = elementName;
this.moving = moving;
this.loop = loop;
this.objectNumber = objectNumber;
this.attached = attached;
this.attachedElement = attachedElement;
this.delay = delay;
this.delayLimit = delayLimit;
this.delayTime = delayTime;

this.directionStyle;
this.directionSymbol;

this.prepareAnimation();
this.boundary = this.endPosition;
this.timeout;
this.timeoutDelay;

this.returnHome = returnHome;
this.returnDirection = returnDirection;
}


animatedObject.prototype.returnState = function(){
 this.timeoutDelay = setTimeout("animate["+this.objectNumber+"].moveout()","5000");
}


animatedObject.prototype.moveout = function(){
 if(!this.moving)
  {
   this.moving = true;
   this.movement();
    if(this.attached && !animate[this.attachedElement].moving)
	 {
	  animate[this.attachedElement].moving = true;
	  animate[this.attachedElement].movement();
	 }
  }
}

animatedObject.prototype.movement = function(){


 if(this.currentPosition != this.boundary)
 {
   if(this.delay && this.currentPosition % this.delayLimit == 0 && this.currentPosition != this.delayLimit && this.currentPosition != this.endPosition)
    {
	 this.timeout = setTimeout("animate["+this.objectNumber+"].movement()","5000");
    }
   else
    {
     this.timeout = setTimeout("animate["+this.objectNumber+"].movement()","1");
    }
	
	eval('this.currentPosition' + this.directionSymbol + '= this.frameChange');
    eval('document.getElementById(this.elementName).style.' + this.directionStyle + '= this.currentPosition + "px" ');
 }

 
 else
  {
   window.clearTimeout(this.timeout);
   this.moving = false;
   this.switchDirection();
    if(this.loop)
	 {
	  this.currentPosition = this.startingPosition;
	  this.movement();
	 }
   
    if(this.direction == this.returnDirection && this.returnHome)
     {
	  this.returnState();     
	 }	 
  }
}

animatedObject.prototype.prepareAnimation = function(){
 switch(this.direction)
  {
   case 'right':
   this.directionStyle = 'left';
   this.directionSymbol = '+';
   break;
   
   case 'left':
   this.directionStyle = 'left';
   this.directionSymbol = '-';
   break;
   
   case 'down':
   this.directionStyle = 'top';
   this.directionSymbol = '+';
   break;
   
   case 'up':
   this.directionStyle = 'top';
   this.directionSymbol = '-';
   break;
  }
}

animatedObject.prototype.switchDirection = function(){
 switch(this.direction)
  {
   case 'left':
   this.direction = 'right';
   break;
   
   case 'right':
   this.direction = 'left';
   break;
   
   case 'up':
   this.direction = 'down';
   break;
   
   case 'down':
   this.direction = 'up';
   break;
  }
 
  switch(this.boundary)
   {
    
	case this.endPosition:
	this.boundary = this.startingPosition;
	break;
	
	case this.startingPosition:
	this.boundary = this.endPosition;
	break;
   }
   
   this.prepareAnimation();
}