/*
  Javascript for shaking an object

  only one single can be shaken at the same time

  position of the object must be defined (relative or absolute)
*/

var shake = {

style:null, x:0, y:0, n:0, active:false, 

amphor:new Array(-2,-2, 2, 2),
ampver:new Array( 2,-2,-2, 2),

start:function(ID)
{
  this.style = document.getElementById(ID).style;

  this.x = parseInt(this.style.left);
  this.y = parseInt(this.style.top );

  this.n = 0;

  this.active = true;
},

run:function()
{
  if( this.active )
  {
    this.style.left = this.x + this.amphor[this.n];
    this.style.top  = this.y + this.ampver[this.n];

    this.n = ++this.n % 4;
  }

  setTimeout("shake.run()",50);
},

stop:function()
{
  this.active = false;

  this.style.left = this.x;
  this.style.top  = this.y;
}
}

shake.run();
