/*
  visit counter script
*/
 
var visit = {

digitStyle:new Array( null, null, null, null ), pos:new Array( 0, 0, 0, 0 ),

shift:new Array( 0, 0, 0, 0 ), 

yearID:null, curryear:0, current:0, busy:false,

prepare:function( number )
{
  for( var i = 0; i < 3; i++ )
  {
    this.pos[i] = 19 * (number % 10);

    number = Math.floor(number/10);
  }

  this.pos[3] = 19 * number;
},

shiftDigits:function()
{
  this.busy = true;

  this.yearID = document.getElementById('year');

  for( var i = 0; i < 4; i++ )
    this.digitStyle[i] = document.getElementById('digit' + i).style;

  this.prepare( this.current );

  this.shiftDigit(3);
},

shiftDigit:function(k)
{
  if( this.shift[k] != this.pos[k] )
  {
    this.shift[k] = ++this.shift[k] % 190;

    this.digitStyle[k].top = -this.shift[k];

    if( this.shift[k] % 19 == 0 )
      setTimeout("visit.shiftDigit(" + k + ")",80);
    else
      setTimeout("visit.shiftDigit(" + k + ")",20);
  }
  else if( k != 0 ) 
    setTimeout("visit.shiftDigit(" + (k - 1) + ")",80);
  else
    this.busy = false;
},

shiftReset:function(year)
{
  if( this.busy ) return;

  this.busy = true;

  this.yearID.innerHTML = year;

  this.prepare( this.current );

  this.shiftDigit(3);
},

shiftTemp:function( year, number )
{
  if( this.busy ) return;

  this.yearID.innerHTML = year;

  this.busy = true;

  this.prepare( number );

  this.shiftDigit(3);
}
}

