﻿// Renvoie si le navigateur est Internet Explorer <= 6
function ie6() {
  return navigator.appVersion.indexOf("MSIE") > 0 &&  parseFloat(navigator.appVersion.split("MSIE")[1]) < 7;
}

// Centre un élément sur l'explorateur
function centrer($element) {
  $element.style.position = "absolute";
  var $document = document.documentElement;
  $element.style.left = $document.scrollLeft + (($document.clientWidth - $element.clientWidth) / 2) + "px";
  $element.style.top = $document.scrollTop + (($document.clientHeight - $element.clientHeight) / 2) + "px";
}

// N'autorise que les caractères numériques et . sur un champ input
function filtreNumeriques($event) {
  var $el = new Event($event).target;
  var $reg = new RegExp("[^0-9\.,]", "g");
  if ($reg.test($el.value))
    $el.value = $el.value.replace($reg, "");
}

// Pour faire un lien mailto en protégeant contre les robots
function mailTo($email, $nom) {
  $email = $email.replace("*", "@");
  if(!$nom)
    $nom = $email;
  document.write("<a href=\"mailto:" + $email + "\">" + $nom + "</a>");
  
}
// Classe pour l'affichage des listes
function HtmlTable($id) {

  this.table = $($id);
  this.currentTr = null;
  this.currentTrClassName = "";


  this.init = function() {
    var $lignes = this.table.getElementsByTagName("tr");
    for (var $i = 0; $i < $lignes.length; $i++) {
      $lignes[$i].onmouseover = this.hover.bind(this, $lignes[$i]);
      $lignes[$i].onmouseout = this.out.bind(this);
    }
  }

  this.hover = function($tr) {
    this.currentTr = $tr;
    this.currentTrClassName = $tr.className;
    $tr.className = "Hover";
  }

  this.out = function($event) {
    if (this.currentTr) {
      this.currentTr.className = this.currentTrClassName;
      this.currentTr = null;
      this.currentTrClassName = "";
    }
  }


  this.click = function($event, $url) {
    var $el = $event.target ? $event.target : $event.srcElement;
    if ($el.tagName == "TD")
      window.location = $url;
  }
  
  this.init();
}

function Patientez() {
  
  this.div = null;

  this.div = document.createElement("div");
  this.div.className = "Patientez";
  this.div.innerHTML = "Veuillez patientez...";
  document.body.appendChild(this.div);
  centrer(this.div);

  this.fermer = function() {
    document.body.removeChild(this.div);
    this.div = null;
  }
}

function promoCligno($param) {
  var $promo = $("ctl00_Promotions");
  if(!$promo)
    return;
  $promo.style.color = ($param ? "white" : "#e7a279");
  setTimeout("promoCligno(" + ($param ? "null" : "1") + ")", 500);
}
