/*
  calendar script
*/

var calendar = {

month:new Array('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sept', 'Oct', 'Nov', 'Déc'),  

backStyle:null, paper1ID:null, paper2Id:null, shift:0, number:8, day:1, year:2008,

start:function()
{
  this.backStyle = document.getElementById('back').style; 

  this.paper1ID = document.getElementById('paper1');
  this.paper2ID = document.getElementById('paper2');

  this.move();
},

move:function(k)
{
  this.shift++;

  this.backStyle.clip = 'rect(0px ' + (155 - this.shift) + 'px ' + this.shift + 'px ' + (105 - this.shift) + 'px)'; 
  this.backStyle.top = 50 - this.shift; 

  this.paper2ID.style.clip = 'rect(' + (50 - this.shift) + 'px 40px 50px ' + (40 - this.shift) + 'px)'; 

  if(this.shift < 105 )
    setTimeout('calendar.move()',10);
  else
  {
    this.nextDay();

    this.shift = 0;

    setTimeout('calendar.move()',500);
  }
},

nextDay:function()
{
  this.day = ++this.day % 31; 

  if( this.day == 0)
  {
    this.number = ++this.number % 12;

    if(this.number == 0) this.year++;
  }
  else if( this.day == 29 && this.number == 1)
  {
    this.day = 0;

    this.number = 2;
  }

  else if( this.day == 30 && (this.number == 3 || this.number == 5 || this.number == 8 || this.number == 10 ) )
  {
    this.day = 0;

    this.number++;

  }

  this.paper1ID.innerHTML = this.paper2ID.innerHTML; 

  this.paper2ID.style.clip = 'rect(50px 40px 50px 40px)'; 

  this.paper2ID.innerHTML = this.month[this.number] + '<br><span style="color:#FF0000; font-size:13pt">'+ (this.day + 1) + '</span><span style="font-size:6pt"><br>'+ this.year + '</span>';
}
}

