function popupplan(cible) {
  var fenetre = window.open(cible + '.htm', 'popliste', 'scrollbars=no,resizable=yes,resizable=no,width=800,height=590');
  fenetre.focus();
}

function popup(cible) {
  var fenetre = window.open(cible + '.htm', 'popliste', 'scrollbars=no,resizable=yes,resizable=no,width=550,height=590');
  fenetre.focus();
}

function popupsituation(cible) {
  var fenetre = window.open(cible + '.htm', 'popsituation', 'scrollbars=no,resizable=yes,resizable=no,width=520,height=480');
  fenetre.focus();
}

function roll_on(nom) {
  if (document.images) document.images[nom].src = 'img/bt_' + nom + '_off.jpg';
}

function roll_off(nom) {
  if (document.images) document.images[nom].src = 'img/bt_' + nom + '_on.jpg';
}

function verifform(formulaire) {
  if (test_champ(formulaire.nom)) { alert('Veuillez saisir votre nom'); return false }
  if (test_champ(formulaire.prenom)) { alert('Veuillez saisir votre prénom'); return false }
  if (test_champ(formulaire.email)) { alert('Veuillez saisir votre adresse e-mail'); return false }
  if (test_email_champ(formulaire.email)) { alert('Veuillez vérifier votre adresse e-mail'); return false }
  if(!formulaire.villak.checked && !formulaire.villad.checked) { alert('Veuillez spécifier une villa'); return false }
  return true;
}

function test_champ(champ) {
  if (test_vide(champ)) {
    champ.style.backgroundColor="#ff8400";
    champ.focus();
    return true;
  }
  else {
    champ.style.backgroundColor="#ffffff";
    return false;
  }
}

function test_email_champ(champ) {
  if (test_email(champ)) {
    champ.style.backgroundColor="#ffffff";
    return false;
  }
  else {
    champ.style.backgroundColor="#ff8400";
    champ.focus();
    return true;
  }
}

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_email(champ) {
  if (champ.value.indexOf(';') >= 0) { return false }
  if (champ.value.length < 5) { 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;
}

