
function NomSexe(p_nom, p_sexe)
{
  document.formEnvoieCourriel.nomPersonnage.value = p_nom;
  document.formEnvoieCourriel.sexe.value = p_sexe;
}

function EnvoyerCourriel()
{
  if (document.formEnvoieCourriel.radioCourriel[0].checked)
  {
    if (document.formEnvoieCourriel.prenomami.value == ""
        || document.formEnvoieCourriel.nomami.value == ""
        || document.formEnvoieCourriel.courrielami.value == "")
    {
      alert("Please enter the first name, last name and e-mail address of your friend. ");
      return false;
    }
    
    if (document.formEnvoieCourriel.courrielami.value.indexOf("@") == -1
        || document.formEnvoieCourriel.courrielami.value.indexOf(".") == -1
        || document.formEnvoieCourriel.courrielami.value.indexOf(".", document.formEnvoieCourriel.courrielami.value.indexOf("@")) == -1)
    {
      alert("Your friend's e-mail address is not valid. ");
      document.formEnvoieCourriel.courrielami.focus();
      return false;	
    }
    
    if (document.formEnvoieCourriel.confirmcourrielami.value.indexOf("@") == -1
        || document.formEnvoieCourriel.confirmcourrielami.value.indexOf(".") == -1
        || document.formEnvoieCourriel.confirmcourrielami.value.indexOf(".", document.formEnvoieCourriel.confirmcourrielami.value.indexOf("@")) == -1)
    {
      alert("Your friend's e-mail confirmatoin is not valid. ");
      return false;	
    }
    
    if (document.formEnvoieCourriel.courrielami.value != document.formEnvoieCourriel.confirmcourrielami.value)
    {
      alert("Your friend's e-mail addresses are not the same. ");
      return false;	
    }
    
    if (document.formEnvoieCourriel.prenom.value == ""
        || document.formEnvoieCourriel.nom.value == ""
        || document.formEnvoieCourriel.courriel.value == ""
        || document.formEnvoieCourriel.commentaires.value == "")
    {
      alert("Please enter your first name, last name and e-mail address along with your message. ");
      return false;
    } 
    
    if (document.formEnvoieCourriel.courriel.value.indexOf("@") == -1
        || document.formEnvoieCourriel.courriel.value.indexOf(".") == -1
        || document.formEnvoieCourriel.courriel.value.indexOf(".", document.formEnvoieCourriel.courriel.value.indexOf("@")) == -1)
    {
      alert("Your e-mail address is not valid. ");
      document.formEnvoieCourriel.courriel.focus();
      return false;	
    }
    
    if (document.formEnvoieCourriel.confirmcourriel.value.indexOf("@") == -1
        || document.formEnvoieCourriel.confirmcourriel.value.indexOf(".") == -1
        || document.formEnvoieCourriel.confirmcourriel.value.indexOf(".", document.formEnvoieCourriel.confirmcourriel.value.indexOf("@")) == -1)
    {
      alert("Your e-mail confirmation is not valid. ");
      document.formEnvoieCourriel.courriel.focus();
      return false;	
    }
    
    if (document.formEnvoieCourriel.courriel.value != document.formEnvoieCourriel.confirmcourriel.value)
    {
      alert("Your e-mail addresses are not the same. ");
      return false;	
    }
    
    // Valider type de bisou....
    
    //document.formEnvoieCourriel.submit();        
    return true;
  }
  else
  {
    if (document.formEnvoieCourriel.radioCourriel[1].checked)
    {
      if ( ! document.formEnvoieCourriel.radiobutton_pers[0].checked
          &&  ! document.formEnvoieCourriel.radiobutton_pers[1].checked
          &&  ! document.formEnvoieCourriel.radiobutton_pers[2].checked
          &&  ! document.formEnvoieCourriel.radiobutton_pers[3].checked
          &&  ! document.formEnvoieCourriel.radiobutton_pers[4].checked)
      {
      	alert("To which Cornemuse character do you wish to send this email?");
      	return false;
      }
      
    if (document.formEnvoieCourriel.prenom.value == ""
        || document.formEnvoieCourriel.nom.value == ""
        || document.formEnvoieCourriel.courriel.value == ""
        || document.formEnvoieCourriel.commentaires.value == "")
    {
      alert("Please enter your first name, last name and e-mail address along with your message. ");
      return false;
    } 
    
    if (document.formEnvoieCourriel.courriel.value.indexOf("@") == -1
        || document.formEnvoieCourriel.courriel.value.indexOf(".") == -1
        || document.formEnvoieCourriel.courriel.value.indexOf(".", document.formEnvoieCourriel.courriel.value.indexOf("@")) == -1)
      {
        alert("Your e-mail address is not valid.");
        return false;	
      }
    
    if (document.formEnvoieCourriel.confirmcourriel.value.indexOf("@") == -1
        || document.formEnvoieCourriel.confirmcourriel.value.indexOf(".") == -1
        || document.formEnvoieCourriel.confirmcourriel.value.indexOf(".", document.formEnvoieCourriel.confirmcourriel.value.indexOf("@")) == -1)
      {
        alert("Your e-mail confirmation is not valid. ");
        return false;	
      }
      
     if (document.formEnvoieCourriel.courriel.value != document.formEnvoieCourriel.confirmcourriel.value)
      {
        alert("Your e-mail addresses are not the same.");
        return false;	
      }
      
      return true;
      //document.formEnvoieCourriel.submit();     	
    }
    else
    {
      alert("To whom do you wish to send this e-mail?\nTo a friend or a Cornemuse character?");
		return false;
    }	 	
  }
}

function CompleterCarte() {
     
      if (document.formCarteVirtuelle.radiobutton.length == null) // Une seule carte
      {
      	if ( ! document.formCarteVirtuelle.radiobutton.checked)
      	{
      	  alert("Please select an e-card. ");
          return false;	 
      	}
      }
      else  // Array de carte
      {
        var cardSelected = false;
      
        for (i = 0; i < document.formCarteVirtuelle.radiobutton.length; ++i)
        {
          if (document.formCarteVirtuelle.radiobutton[i].checked)
          {
            cardSelected = true;
            break;
          }	
        }
      
        if ( ! cardSelected)
        {
          alert("Please select an e-card. ");
          return false;	
        }
      }	
      return true;
      //document.formCarteVirtuelle.submit();	
}

