/*
  functions for the buttons on the index page
*/

var button = {

name:new Array('leclub', 'clubinfo', 'calendrier', 'contact', 'galerie', 'partenaires', 'resultats', 'actualites', 'visages', 'lemot',  'lemotMt', 'cotisations', 'horaires', 'acces', 'docs', 'secrets', 'divers', 'lapresse' ),

image:new Array(),

loadImages:function()
{
  for(var x in this.name)
    this.image[ this.name[x] ] = new this.define( this.name[x] );
},

red:function(imageName)
{
  document.getElementById(imageName).src = this.image[imageName].red;
},

yellow:function(imageName)
{
  document.getElementById(imageName).src = this.image[imageName].yellow;
},

// constructor

define:function(imageName)
{
  this.imageYellow = new Image();
  this.imageRed    = new Image();

  this.yellow = this.imageYellow.src = 'images/' + imageName + '_jaune.jpg';
  this.red    = this.imageRed.src    = 'images/' + imageName + '_rouge.jpg';
}
}

var menu = {

style:new Array(), pos:new Array(), shift:new Array(1,1), index:new Array(0,0), 

mouseover:new Array(false,false), busy:new Array(false,false),

text:new Array('leclub','clubinfo'),

start:function()
{
  for( var i = 0; i < 41; i++ )
    this.pos[i] = Math.round(82.5 * (1 - Math.cos(Math.PI * i / 40)));

  for( var k = 0; k < 2; k++ )
    this.style[k] = document.getElementById('menu' + k).style;
},

show:function(k)
{
  this.mouseover[k] = true;

  button.red(this.text[k]);

  this.shift[k] = 1;

  if( this.busy[k] ) return;

  this.busy[k] = true;

  this.move(k);
},

hide:function(k)
{
  this.mouseover[k] = false;
},

move:function(k)
{
  this.index[k] = Math.min(Math.max(this.index[k] + this.shift[k],0),55);

  if( this.index[k] <= 40 )
    this.style[k].top = -this.pos[this.index[k]];

  if( this.index[k] == 55 )
  {
    if( ! this.mouseover[k] )
      this.shift[k] = -1;
  }
  else if( this.index[k] == 0 )
  {
    button.yellow(this.text[k]);

    this.busy[k] = false;

    return;
  }

  setTimeout('menu.move(' + k + ')',30);
}
} 

button.loadImages();

