var tabMois = new Array('janvier', 'f&eacute;vrier', 'mars', 'avril', 'mai', 'juin', 'juillet', 'ao&ucirc;t', 'septembre', 'octobre', 'novembre', 'd&eacute;cembre');

var posSouris = new Array();

function lanceTrackSouris(){
  addListener(document, 'mousemove', defPositionSouris);        
}

function defPositionSouris(e){
  if (!e)
    var e = window.event;

  posSouris = new Array((navigator.appName.substring(0,3) == "Net") ? e.pageX : window.event.clientX+document.body.scrollLeft,
                        (navigator.appName.substring(0,3) == "Net") ? e.pageY : window.event.clientY+document.body.scrollTop);

  if(document.getElementById('conteneurEncartLocation').style.visibility=='visible'){
    document.getElementById('conteneurEncartLocation').style.left = (posSouris[0] - 30 ) + 'px';
    document.getElementById('conteneurEncartLocation').style.top = (posSouris[1] + 30) + 'px';
  }
  if(document.getElementById('conteneurEncartVente').style.visibility=='visible'){
    document.getElementById('conteneurEncartVente').style.left = (posSouris[0] - 30 ) + 'px';
    document.getElementById('conteneurEncartVente').style.top = (posSouris[1] + 30) + 'px';
  }
}  // defPositionSouris

function rollOver(e) {
  if (!e)
    var e = window.event;
  var image = (window.event) ? e.srcElement : e.target;
  image.src = image.src.substring(0, image.src.length - 4) + '_over.gif';
} // rollOver(e)

function rollOut(e) {
  if (!e)
    var e = window.event;
  var image = (window.event) ? e.srcElement : e.target;
  image.src = image.src.substring(0, image.src.length - 9) + '.gif';
} // rollOut(e)

function afficheDate(maDate){
  return (maDate.getDate()<10 ? '0' : '') + maDate.getDate() + '/' + (maDate.getMonth()<9 ? '0' : '') + (maDate.getMonth()+1) + '/' + maDate.getFullYear();
}

function prechargement(){
  for (var i=0; i < prechargement.arguments.length; i++) {
    monImage = new Image();
    monImage.src=prechargement.arguments[i];
  }
} // prechargement()

function bindBouttonsMenu() {
  prechargement('/fr/images/menu1_over.gif', '/fr/images/menu2_over.gif', '/fr/images/menu3_over.gif', 
                '/fr/images/menu4_over.gif', '/fr/images/menu5_over.gif', '/fr/images/menu6_over.gif');
  document.getElementById('menu' + menuEnCours).src = document.getElementById('menu' + menuEnCours).src.substring(0, document.getElementById('menu' + menuEnCours).src.length - 4) + '_over.gif';
  for(i=1; i<=6; i++){
    if(i != menuEnCours){
      addListener(document.getElementById('menu' + i), 'mouseover', rollOver);
      addListener(document.getElementById('menu' + i), 'mouseout', rollOut);
    }
  }

  addListener(document.getElementById('menu1'), 'click', function() {rollOut; window.location='agence.php';});
  addListener(document.getElementById('menu2'), 'click', function() {rollOut; window.location='locations.php';});
  addListener(document.getElementById('menu3'), 'click', function() {rollOut; window.location='ventes.php';});
  addListener(document.getElementById('menu4'), 'click', function() {rollOut; window.location='acces.php';});
  addListener(document.getElementById('menu5'), 'click', function() {rollOut; window.location='contact.php';});
  addListener(document.getElementById('menu6'), 'click', function() {rollOut; window.location='partenaires.php';});

  // affichage encart
  if(document.getElementById('conteneurEncartLocation')){
    addListener(document.getElementById('menu2'), 'mouseover', function(){document.getElementById('conteneurEncartLocation').style.visibility='visible';});
    addListener(document.getElementById('menu2'), 'mouseout', function(){document.getElementById('conteneurEncartLocation').style.visibility='hidden';});
  }
  if(document.getElementById('conteneurEncartVente')){
    addListener(document.getElementById('menu3'), 'mouseover', function() {document.getElementById('conteneurEncartVente').style.visibility = 'visible';});
    addListener(document.getElementById('menu3'), 'mouseout', function() {document.getElementById('conteneurEncartVente').style.visibility='hidden';});
  }
} // bindBouttonsMenu()

function addListener(element, baseName, handler) {
    if (element.addEventListener)
        element.addEventListener(baseName, handler, false);
    else if (element.attachEvent)
        element.attachEvent('on' + baseName, handler);
    else
      element["on"+_type] = handler;
} // addListener(element, baseName, handler)


function ouvrirPopup(page,nom,largeur,hauteur,option){
  var haut;
  var gauche;
  var w;

  if(!largeur || !hauteur)
    if (window.screen) {
      largeur = window.screen.availWidth;
      hauteur = window.screen.availHeight;
      w = window.open(page, nom, "top=0, left=0, width=" + largeur + ", height=" + hauteur + "," + option);
    }
    else
      w = window.open(page, nom, "fullscreen," + option);
  else{
    haut=(screen.height-hauteur)/2 - 100;
    gauche=(screen.width-largeur)/2;
    w = window.open(page, nom, "top=" + haut + ", left=" + gauche + ", width=" + largeur + ", height=" + hauteur + "," + option);
  }

  w.focus();
  return w;
} // ouvrirPopup(page,nom,largeur,hauteur,option)
