function OpenNewWindow(URL, name, options)
{
  window.open(URL, name, options);
}

function EnvoyerDemande()
{
	if (document.frmAmiCornemuse.prenom.value == "")
  {
    alert("You must enter your first name. ");
    document.frmAmiCornemuse.prenom.focus();
    return false;
  }
  
  if (document.frmAmiCornemuse.nom.value == "")
  {
    alert("You must enter your last name. ");
    document.frmAmiCornemuse.nom.focus();
    return false;
  }
  
  if (document.frmAmiCornemuse.annee[document.frmAmiCornemuse.annee.selectedIndex].value == ""
      || document.frmAmiCornemuse.mois[document.frmAmiCornemuse.mois.selectedIndex].value == ""
      || document.frmAmiCornemuse.jours[document.frmAmiCornemuse.jours.selectedIndex].value == "")
  {
    alert("You must enter your date of birth. ");
    document.frmAmiCornemuse.annee.focus();
    return false;
  }    
  
  var newDateObj = new Date(document.frmAmiCornemuse.annee[document.frmAmiCornemuse.annee.selectedIndex].value,
                            document.frmAmiCornemuse.mois[document.frmAmiCornemuse.mois.selectedIndex].value,
                            document.frmAmiCornemuse.jours[document.frmAmiCornemuse.jours.selectedIndex].value);
  
  var jourDate = newDateObj.getDate();
  var moisDate = newDateObj.getMonth();
  var anneeDate = newDateObj.getFullYear();
  
  if (jourDate != document.frmAmiCornemuse.jours[document.frmAmiCornemuse.jours.selectedIndex].value
      || moisDate != document.frmAmiCornemuse.mois[document.frmAmiCornemuse.mois.selectedIndex].value
      || anneeDate != document.frmAmiCornemuse.annee[document.frmAmiCornemuse.annee.selectedIndex].value)
  {
    alert("Your date of birth is not valid. ");
    document.frmAmiCornemuse.annee.focus();
    return false;
  }
  
  if (document.frmAmiCornemuse.courriel.value == "")
  {
    alert("You must enter your e-mail. ");
    document.frmAmiCornemuse.courriel.focus();
    return false;
  }
    
  if (document.frmAmiCornemuse.courriel.value.indexOf("@") == -1
      || document.frmAmiCornemuse.courriel.value.indexOf(".") == -1
      || document.frmAmiCornemuse.courriel.value.indexOf(".", document.frmAmiCornemuse.courriel.value.indexOf("@")) == -1)
  {
    alert("Your e-mail is not valid. ");
    document.frmAmiCornemuse.courriel.focus();
    return false;	
  }
  
  if (document.frmAmiCornemuse.confirmcourriel.value == "")
  {
    alert("You must confirm your e-mail. ");
    document.frmAmiCornemuse.confirmcourriel.focus();
    return false;
  }
  
  if (document.frmAmiCornemuse.confirmcourriel.value.indexOf("@") == -1
      || document.frmAmiCornemuse.confirmcourriel.value.indexOf(".") == -1
      || document.frmAmiCornemuse.confirmcourriel.value.indexOf(".", document.frmAmiCornemuse.confirmcourriel.value.indexOf("@")) == -1)
  {
    alert("Your e-mail confirmation is not valid. ");
    document.frmAmiCornemuse.confirmcourriel.focus();
    return false;	
  }
  
  if (document.frmAmiCornemuse.courriel.value != document.frmAmiCornemuse.confirmcourriel.value)
  {
    alert("Your e-mail are not the same. ");
    document.frmAmiCornemuse.courriel.focus();
    return false;	
  }
  
  if (document.frmAmiCornemuse.motpasse.value == "" || document.frmAmiCornemuse.confirmMotPasse.value == "")
  {
    alert("You must enter and confirm your password. ");
    document.frmAmiCornemuse.motpasse.focus();
    return false;
  }
  
  if (document.frmAmiCornemuse.motpasse.value != document.frmAmiCornemuse.confirmMotPasse.value)
  {
    alert("Your password are not the same. ");
    document.frmAmiCornemuse.motpasse.focus();
    return false;
  }
  
  if (document.frmAmiCornemuse.promotion.checked && document.frmAmiCornemuse.courrielp.value == "")
  {
    alert("You must enter your parents' e-mail. ");
    document.frmAmiCornemuse.courrielp.focus();
    return false;  
  }
  
  if (document.frmAmiCornemuse.promotion.checked && document.frmAmiCornemuse.courrielp.value != "")
  {
     if (document.frmAmiCornemuse.courrielp.value.indexOf("@") == -1
         || document.frmAmiCornemuse.courrielp.value.indexOf(".") == -1
         || document.frmAmiCornemuse.courrielp.value.indexOf(".", document.frmAmiCornemuse.courrielp.value.indexOf("@")) == -1)
     {
       alert("Your parents' e-mail is not valid. ");
       document.frmAmiCornemuse.courrielp.focus();
       return false;
     }	
  }
  
  if (document.frmAmiCornemuse.promotion.checked && document.frmAmiCornemuse.confirmcourrielp.value == "")
  {
    alert("You must confirm your parents' e-mail. ");
    document.frmAmiCornemuse.confirmcourrielp.focus();
    return false;  
  }    
  
  if (document.frmAmiCornemuse.courrielp.value != document.frmAmiCornemuse.confirmcourrielp.value)
  {
    alert("Your parent's e-mail are not the same. ");
    document.frmAmiCornemuse.courrielp.focus();
    return false;
  }
  if (document.frmAmiCornemuse.promotion.checked && document.frmAmiCornemuse.confirmcourrielp.value != "")
  {
     if (document.frmAmiCornemuse.confirmcourrielp.value.indexOf("@") == -1
         || document.frmAmiCornemuse.confirmcourrielp.value.indexOf(".") == -1
         || document.frmAmiCornemuse.confirmcourrielp.value.indexOf(".", document.frmAmiCornemuse.confirmcourrielp.value.indexOf("@")) == -1)
     {
       alert("Your confirmation parents' e-mail is not valid. ");
       document.frmAmiCornemuse.confirmcourrielp.focus();
       return false;
     }	
  }
  
  if (document.frmAmiCornemuse.promotion.checked)
  {
     if (document.frmAmiCornemuse.courrielp.value != document.frmAmiCornemuse.confirmcourrielp.value)
     {
       alert("Your parents' e-mail are not the same. ");
       document.frmAmiCornemuse.courrielp.focus();
       return false;
     }	
  }
  
  return true;
  //document.frmAmiCornemuse.submit();
}

function Valider()
{
  if (document.frmAmiCornemuseModif.prenom.value == "")
  {
    alert("You must enter your first name and last name. ");
    document.frmAmiCornemuseModif.prenom.focus();
    return;
  }
  
  if (document.frmAmiCornemuseModif.courriel.value == "")
  {
    alert("You must enter your e-mail. ");
    document.frmAmiCornemuseModif.courriel.focus();
    return;
  }
  
  if (document.frmAmiCornemuseModif.courriel.value.indexOf("@") == -1
      || document.frmAmiCornemuseModif.courriel.value.indexOf(".") == -1
      || document.frmAmiCornemuseModif.courriel.value.indexOf(".", document.frmAmiCornemuseModif.courriel.value.indexOf("@")) == -1)
  {
    alert("Your e-mail is not valid. ");
    document.frmAmiCornemuseModif.courriel.focus();
    return;
  }
  
  if (document.frmAmiCornemuseModif.motpasse.value == "")
  {
    alert("You must enter a password. ");
    document.frmAmiCornemuseModif.motpasse.focus();
    return;
  }
  
  document.frmAmiCornemuseModif.submit();
}

function Modifier()
{
  document.frmAmiCornemuseModif.action = "fiche_personnelle.cgi";
  Valider();
}

function Retirer()
{
  document.frmAmiCornemuseModif.action = "retirer_fiche.cgi";
  Valider();
}

