function flip(cible) {
  if (document.getElementById("menu"+cible)) {
    if (document.getElementById("menu"+cible).style.display=="none") {
      document.getElementById("menu"+cible).style.display = "block";
    }
    else {
      document.getElementById("menu"+cible).style.display = "none";
    }
  }
}

function champBad(champ) {
  champ.style.backgroundColor="#ff8400";
  champ.focus();
}

function champGood(champ) {
  champ.style.backgroundColor="#ffffff";
}

function test_vide(champ) {
  if (champ.value.length == 0) return true;
  if (champ.value.length > 0) {
    for (var i = 0; i < champ.value.length; i++) {
      if (champ.value.substring(i, i + 1) != ' ') return false;
    }
  }
  return true;
}

function test_num(champ) {
  var validCars = "0123456789";
  var isNum = true;
  var carac;
  for (i=0;i<champ.value.length;i++) {
    carac = champ.value.charAt(i);
    if (validCars.indexOf(carac) == -1) isNum = false;
  }
  return isNum;
}

function test_email(champ) {
  if (champ.value.length < 5) { return false }
  if (champ.value.indexOf(' ') >= 0) { return false }
  if (champ.value.indexOf(',') >= 0) { return false }
  if (champ.value.indexOf(';') >= 0) { return false }
  if (champ.value.indexOf(':') >= 0) { return false }
  if (champ.value.indexOf('\t') >= 0) { return false }
  if (champ.value.indexOf('@') < 0) { return false }
  var mailparts = champ.value.split('@');
  if (mailparts[0].length < 1) { return false }
  if (mailparts[1].indexOf('.') < 0) { return false }
  var domaine = mailparts[1].split('.');
  if (domaine[0].length < 1) { return false }
  if (domaine[1].length < 2) { return false }
  return true;
}

function frmVerif(formulaire) {
  frmOK = true;
  champGood(formulaire.nom);
  champGood(formulaire.prenom);
  champGood(formulaire.mail);
  champGood(formulaire.depart);
  champGood(formulaire.arrivee);
  champGood(formulaire.jour);
  champGood(formulaire.contact);
  if (test_vide(formulaire.mail)) { champBad(formulaire.mail); frmOK = false }
  if (!test_email(formulaire.mail)) { champBad(formulaire.mail); frmOK = false }
  if (test_vide(formulaire.contact)) { champBad(formulaire.contact); frmOK = false }
  if (test_vide(formulaire.jour)) { champBad(formulaire.jour); frmOK = false }
  if (test_vide(formulaire.arrivee)) { champBad(formulaire.arrivee); frmOK = false }
  if (test_vide(formulaire.depart)) { champBad(formulaire.depart); frmOK = false }
  if (test_vide(formulaire.prenom)) { champBad(formulaire.prenom); frmOK = false }
  if (test_vide(formulaire.nom)) { champBad(formulaire.nom); frmOK = false }
  return frmOK;
}