/*
  Javascript for ringing telephone
*/

var phone = {

phoneImage:new Image(),

phoneId:new Array(), count:new Array(0, 0, 0, 0, 0), amplitude:new Array(0, 0, 0, 0, 0),

read:function()
{
  this.phoneImage.src = "images/phone.gif";
},

start:function()
{
  for(var i = 0; i < 5; i++)
  {
    this.phoneId[i] = document.getElementById('telephone' + i);

    this.phoneId[i].src = this.phoneImage.src;
  }

  document.getElementById('allphones').style.visibility = 'visible';

  this.trigger();
},

trigger:function()
{
  this.move(1);
  setTimeout("phone.move(4)", 600);
  setTimeout("phone.move(0)",1200);
  setTimeout("phone.move(2)",1800);
  setTimeout("phone.move(3)",2400);

  setTimeout('phone.trigger()',3000);
},

move:function(k)
{
  this.amplitude[k] = 3 - this.amplitude[k]; 

  this.phoneId[k].style.top = 20 - this.amplitude[k];

  this.count[k] = ++this.count[k] % 50;

  if(this.count[k] > 0)
    setTimeout('phone.move(' + k + ')',20);
}
}

phone.read();

