function ValideIntro(theForm, nTab, sL)
{
  if (theForm.Sejour_Deb.value == "")
  {
    alert("Tapez une valeur pour le champ \"Date de début de séjour\".");
    theForm.Sejour_Deb.focus();
    return (false);
  }

  if (theForm.Sejour_Deb.value.length < 8)
  {
    alert("Tapez au moins 8 caractères dans le champ \"Date de début de séjour\".");
    theForm.Sejour_Deb.focus();
    return (false);
  }

  if (theForm.Sejour_Deb.value.length > 10)
  {
    alert("Tapez au plus 10 caractères dans le champ \"Date de début de séjour\".");
    theForm.Sejour_Deb.focus();
    return (false);
  }
  var checkOK = "0123456789-/";
  var checkStr = theForm.Sejour_Deb.value;
  var bCarDateD = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      bCarDateD = false;
      break;
    }
  }
  if (!bCarDateD)
  {
    alert("Ne tapez que  chiffre et \"/\" dans le champ \"Date de début de séjour\".");
    theForm.Sejour_Deb.focus();
    return (false);
  }

  if (ErrDate(theForm.Sejour_Deb) == true)
  {
    return (false);
  }

  if (theForm.Sejour_Fin.value == "")
  {
    alert("Tapez une valeur pour le champ \"Date de fin de séjour\".");
    theForm.Sejour_Fin.focus();
    return (false);
  }

  if (theForm.Sejour_Fin.value.length < 8)
  {
    alert("Tapez au moins 8 caractères dans le champ \"Date de fin de séjour\".");
    theForm.Sejour_Fin.focus();
    return (false);
  }

  if (theForm.Sejour_Fin.value.length > 10)
  {
    alert("Tapez au plus 10 caractères dans le champ \"Date de fin de séjour\".");
    theForm.Sejour_Fin.focus();
    return (false);
  }

  var checkOK = "0123456789-/";
  var checkStr = theForm.Sejour_Fin.value;
  var bCarDateF = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      bCarDateF = false;
      break;
    }
  }
  if (!bCarDateF)
  {
    alert("Ne tapez que  chiffre et \"/\" caractères dans le champ \"Date de fin de séjour\".");
    theForm.Sejour_Fin.focus();
    return (false);
  }
  if (ErrDate(theForm.Sejour_Fin) == true)
  {
    return (false);
  }
  var bDatesOK = false;
  sDebSej=theForm("Sejour_Deb").value;
  dDebSej=new Date(parseInt(sDebSej.substring(6,10),10),parseInt(sDebSej.substring(3,5),10)-1,parseInt(sDebSej.substring(0,2),10));
  sFinSej=theForm("Sejour_Fin").value;
  dFinSej=new Date(parseInt(sFinSej.substring(6,10),10),parseInt(sFinSej.substring(3,5),10)-1,parseInt(sFinSej.substring(0,2),10));
  for (i = 0;  i < nTab+1;  i++)
  {
    sDebProd=tDates[i][1];
    dDebProd=new Date(parseInt(sDebProd.substring(6,10),10),parseInt(sDebProd.substring(3,5),10)-1,parseInt(sDebProd.substring(0,2),10));
    sFinProd=tDates[i][2];
    dFinProd=new Date(parseInt(sFinProd.substring(6,10),10),parseInt(sFinProd.substring(3,5),10)-1,parseInt(sFinProd.substring(0,2),10));
    if ((dFinSej >= dDebProd) && (dDebSej <= dFinProd))
    {
      bDatesOK = true;
    }
  }
  if (!bDatesOK)
  {
    alert ("Les dates saisies sont en dehors des périodes couvertes par les formules du centre que vous avez choisi...");
    return (false);
  }
  return (true);
}


function ValideForm(theForm, sL)
{
  for (k = 1; k < 9; k++)
  {
    sNum = k+"ème";
    if (k == 1)
      sNum = k+"ère";
    sNom = ((k-1)*4+5);
    if (sNom < 10)
      sNom = "0"+sNom;
    sNom = "_"+sNom+"_Comp_Nom"+k;
    if (k == 1)
    {
      if (theForm(sNom).value == "")
      {
        alert("Tapez une valeur pour le champ \"Nom de la "+sNum+" ligne de composition\".");
        theForm(sNom).focus();
        return (false);
      }

      if (theForm(sNom).value.length < 2)
      {
        alert("Tapez au moins 2 caractères dans le champ \"Nom de la "+sNum+" ligne de composition\".");
        theForm(sNom).focus();
        return (false);
      }
    }

    if (theForm(sNom).value.length > 25)
    {
      alert("Tapez au plus 25 caractères dans le champ \"Nom de la "+sNum+" ligne de composition\".");
      theForm(sNom).focus();
      return (false);
    }

    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
    var checkStr = theForm(sNom).value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
      if (j == checkOK.length)
      {
        allValid = false;
        break;
      }
    }
    if (!allValid)
    {
      alert("Ne tapez que  lettre, blanc et \"-\" caractères dans le champ \"Nom de la "+sNum+" ligne de composition\".");
      theForm(sNom).focus();
      return (false);
    }
    sPrenom = ((k-1)*4+6);
    if (sPrenom < 10)
      sPrenom = "0"+sPrenom;
    sPrenom = "_"+sPrenom+"_Comp_Prenom"+k;
    if (k == 1 || theForm(sNom).value != "")
    {
      if (theForm(sPrenom).value == "")
      {
        alert("Tapez une valeur pour le champ \"Prénom de la "+sNum+" ligne de composition\".");
        theForm(sPrenom).focus();
        return (false);
      }

      if (theForm(sPrenom).value.length < 2)
      {
        alert("Tapez au moins 2 caractères dans le champ \"Prénom de la "+sNum+" ligne de composition\".");
        theForm(sPrenom).focus();
        return (false);
      }
    }
    if (theForm(sPrenom).value.length > 25)
    {
      alert("Tapez au plus 25 caractères dans le champ \"Prénom de la "+sNum+" ligne de composition\".");
      theForm(sPrenom).focus();
      return (false);
    }

    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
    var checkStr = theForm(sPrenom).value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
      if (j == checkOK.length)
      {
        allValid = false;
        break;
      }
    }
    if (!allValid)
    {
      alert("Ne tapez que  lettre, blanc et \"-\" caractères dans le champ \"Prénom de la "+sNum+" ligne de composition\".");
      theForm(sPrenom).focus();
      return (false);
    }
    sSexe = ((k-1)*4+7);
    if (sSexe < 10)
      sSexe = "0"+sSexe;
    sSexe = "_"+sSexe+"_Comp_Sexe"+k;
    if (k == 1 || theForm(sNom).value != "")
    {
      var radioSelected = false;
      for (i = 0;  i < theForm(sSexe).length;  i++)
      {
        if (theForm(sSexe)[i].checked)
            radioSelected = true;
      }
      if (!radioSelected)
      {
        alert("Sélectionnez une des options \"Sexe de la "+sNum+" ligne de composition\".");
        return (false);
      }
    }
    sNaiss = ((k-1)*4+8);
    if (sNaiss < 10)
      sNaiss = "0"+sNaiss;
    sNaiss = "_"+sNaiss+"_Comp_Naiss"+k;
    if (k == 1 || theForm(sNom).value != "")
    {
      if (theForm(sNaiss).value == "")
      {
        alert("Tapez une valeur pour le champ \"Date de naissance de la "+sNum+" ligne de composition\".");
        theForm(sNaiss).focus();
        return (false);
      }

      if (theForm(sNaiss).value.length < 8)
      {
        alert("Tapez au moins 8 caractères dans le champ \"Date de naissance de la "+sNum+" ligne de composition\".");
        theForm(sNaiss).focus();
        return (false);
      }
    }
    if (theForm(sNaiss).value.length > 10)
    {
      alert("Tapez au plus 10 caractères dans le champ \"Date de naissance de la "+sNum+" ligne de composition\".");
      theForm(sNaiss).focus();
      return (false);
    }

    var checkOK = "0123456789-/";
    var checkStr = theForm(sNaiss).value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
      if (j == checkOK.length)
      {
        allValid = false;
        break;
      }
    }
    if (!allValid)
    {
      alert("Ne tapez que  chiffre et \"/\" caractères dans le champ \"Date de naissance de la "+sNum+" ligne de composition\".");
      theForm(sNaiss).focus();
      return (false);
    }

    if (ErrDate(theForm(sNaiss)) == true)
    {
      return (false);
    }
  }

  if (theForm("_42_ID_Nom").value == "")
  {
    alert("Tapez une valeur pour le champ \"Nom du demandeur\".");
    theForm("_42_ID_Nom").focus();
    return (false);
  }

  if (theForm("_42_ID_Nom").value.length < 2)
  {
    alert("Tapez au moins 2 caractères dans le champ \"Nom du demandeur\".");
    theForm("_42_ID_Nom").focus();
    return (false);
  }

  if (theForm("_42_ID_Nom").value.length > 25)
  {
    alert("Tapez au plus 25 caractères dans le champ \"Nom du demandeur\".");
    theForm("_42_ID_Nom").focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkStr = theForm("_42_ID_Nom").value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Ne tapez que  lettre, blanc et \"-\" caractères dans le champ \"Nom du demandeur\".");
    theForm("_42_ID_Nom").focus();
    return (false);
  }

  if (theForm("_43_ID_Prenom").value == "")
  {
    alert("Tapez une valeur pour le champ \"Prénom du demandeur\".");
    theForm("_43_ID_Prenom").focus();
    return (false);
  }

  if (theForm("_43_ID_Prenom").value.length < 2)
  {
    alert("Tapez au moins 2 caractères dans le champ \"Prénom du demandeur\".");
    theForm("_43_ID_Prenom").focus();
    return (false);
  }

  if (theForm("_43_ID_Prenom").value.length > 25)
  {
    alert("Tapez au plus 25 caractères dans le champ \"Prénom du demandeur\".");
    theForm("_43_ID_Prenom").focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkStr = theForm("_43_ID_Prenom").value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Ne tapez que  lettre, blanc et \"-\" caractères dans le champ \"Prénom du demandeur\".");
    theForm("_43_ID_Prenom").focus();
    return (false);
  }

  if (theForm("_44_ID_Adresse").value == "")
  {
    alert("Tapez une valeur pour le champ \"Adresse du demandeur\".");
    theForm("_44_ID_Adresse").focus();
    return (false);
  }

  if (theForm("_44_ID_Adresse").value.length < 2)
  {
    alert("Tapez au moins 2 caractères dans le champ \"Adresse du demandeur\".");
    theForm("_44_ID_Adresse").focus();
    return (false);
  }

  if (theForm("_44_ID_Adresse").value.length > 40)
  {
    alert("Tapez au plus 40 caractères dans le champ \"Adresse du demandeur\".");
    theForm("_44_ID_Adresse").focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789--, \t\r\n\f";
  var checkStr = theForm("_44_ID_Adresse").value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Ne tapez que  lettre, chiffre, blanc et \"-,\" caractères dans le champ \"Adresse du demandeur\".");
    theForm("_44_ID_Adresse").focus();
    return (false);
  }

  if(theForm("_48_ID_Pays").options[theForm("_48_ID_Pays").selectedIndex].text == "France")
  {
    if (theForm("_46_ID_CP").value == "")
    {
      alert("Pour la France, tapez une valeur pour le champ \"Code Postal du demandeur\".");
      theForm("_46_ID_CP").focus();
      return (false);
    }

    if (theForm("_46_ID_CP").value.length != 5)
    {
      alert("Pour la France, tapez 5 caractères dans le champ \"Code Postal du demandeur\".");
      theForm("_46_ID_CP").focus();
      return (false);
    }

    var checkOK = "0123456789-";
    var checkStr = theForm("_46_ID_CP").value;
    var allValid = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
        break;
      if (j == checkOK.length)
      {
        allValid = false;
        break;
      }
      allNum += ch;
    }
    if (!allValid)
    {
      alert("Pour la France, Ne tapez que  chiffre caractères dans le champ \"Code Postal du demandeur\".");
      theForm("_46_ID_CP").focus();
      return (false);
    }
  }
  if (theForm("_47_ID_Ville").value == "")
  {
    alert("Tapez une valeur pour le champ \"Ville du demandeur\".");
    theForm("_47_ID_Ville").focus();
    return (false);
  }

  if (theForm("_47_ID_Ville").value.length < 1)
  {
    alert("Tapez au moins 1 caractères dans le champ \"Ville du demandeur\".");
    theForm("_47_ID_Ville").focus();
    return (false);
  }

  if (theForm("_47_ID_Ville").value.length > 40)
  {
    alert("Tapez au plus 40 caractères dans le champ \"Ville du demandeur\".");
    theForm("_47_ID_Ville").focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkStr = theForm("_47_ID_Ville").value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Ne tapez que  lettre, blanc et \"-\" caractères dans le champ \"Ville du demandeur\".");
    theForm("_47_ID_Ville").focus();
    return (false);
  }

  if (theForm("_49_ID_EMail").value == "")
  {
    alert("Tapez une valeur pour le champ \"Adresse E-Mail du demandeur\".");
    theForm("_49_ID_EMail").focus();
    return (false);
  }

  if (theForm("_49_ID_EMail").value.length < 5)
  {
    alert("Tapez au moins 5 caractères dans le champ \"Adresse E-Mail du demandeur\".");
    theForm("_49_ID_EMail").focus();
    return (false);
  }

  if (theForm("_49_ID_EMail").value.length > 100)
  {
    alert("Tapez au plus 100 caractères dans le champ \"Adresse E-Mail du demandeur\".");
    theForm("_49_ID_EMail").focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789--_@. \t\r\n\f";
  var checkStr = theForm("_49_ID_EMail").value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Ne tapez que  lettre, chiffre, blanc et \"-_@.\" caractères dans le champ \"Adresse E-Mail du demandeur\".");
    theForm("_49_ID_EMail").focus();
    return (false);
  }
  else
  {
    if (VerifMail(theForm("_49_ID_EMail").value) == false)
    {
      theForm("_49_ID_EMail").focus();
      return (false);
    }
  }
  if (theForm("_50_ID_Tel").value.length > 20)
  {
    alert("Tapez au plus 20 caractères dans le champ \"Numéro de téléphone du demandeur\".");
    theForm("_50_ID_Tel").focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm("_50_ID_Tel").value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Ne tapez que  chiffre caractères dans le champ \"Numéro de téléphone du demandeur\".");
    theForm("_50_ID_Tel").focus();
    return (false);
  }
  sDeb=tDates[theForm("_04_Sejour_Type").selectedIndex][1];
  dDeb=new Date(parseInt(sDeb.substring(6,10),10),parseInt(sDeb.substring(3,5),10)-1,parseInt(sDeb.substring(0,2),10));
  sFin=tDates[theForm("_04_Sejour_Type").selectedIndex][2];
  dFin=new Date(parseInt(sFin.substring(6,10),10),parseInt(sFin.substring(3,5),10)-1,parseInt(sFin.substring(0,2),10));
  sDeb1=theForm("_02_Sejour_Deb").value;
  dDeb1=new Date(parseInt(sDeb1.substring(6,10),10),parseInt(sDeb1.substring(3,5),10)-1,parseInt(sDeb1.substring(0,2),10));
  sFin1=theForm("_03_Sejour_Fin").value;
  dFin1=new Date(parseInt(sFin1.substring(6,10),10),parseInt(sFin1.substring(3,5),10)-1,parseInt(sFin1.substring(0,2),10));
  if (!(((dDeb1 >= dDeb) && (dDeb1 <= dFin)) || ((dFin1 >= dDeb) && (dFin1 <= dFin))))
  {
    alert ("La période couverte par la formule que vous avez choisie est comprise entre le "+sDeb+" et le "+sFin+"... Les dates que vous avez indiquées pour votre séjour n'entrent pas dans cette période.");
    return (false);
  }
  return (true);
}

function ErrDate(champ)
{
  
  valcp=champ.value;
  if (valcp != "")
	{
  	msgerr=" Format des dates de type jj/mm/aa. Exemple 01/01/99"
  	pos=valcp.indexOf("/")
  	if (pos==-1)
  	{
    	alert("Il manque un séparateur."+msgerr);
    	champ.focus();
    	return (true);
  	}
  	pos1=valcp.indexOf("/", pos+1)
  	if (pos1==-1)
  	{
    	alert("Il manque un séparateur."+msgerr);
    	champ.focus();
    	return (true);
  	}
    	jour=valcp.substring(0,pos)
    	mois=valcp.substring(pos+1,pos1)
    	annee=valcp.substring(pos1+1,valcp.length)
   	jour=parseInt(jour,10)
    	mois=parseInt(mois,10)
    	annee=parseInt(annee,10)
	if (isNaN(jour)){
		alert("Le jour n'est pas correct."+msgerr);
		champ.focus();
		return (true);
	}
	if (isNaN(mois)){
		alert("Le mois n'est pas correct."+msgerr);
		champ.focus();
		return (true);
	}
	if (isNaN(annee)){
		alert("L'année n'est pas correcte."+msgerr);
		champ.focus();
		return (true);
	}
    	tDate=new Date(annee,mois-1,jour)
    	annee=tDate.getYear()
    	mois=tDate.getMonth()+1
	if (mois < 10) {
		mois="0"+mois
	}
    	jour=tDate.getDate()
	if (jour < 10) {
		jour="0"+jour
	}
    	champ.value=jour+"/"+mois+"/"+annee
	}
return(false);
}

function VerifMail(sAdr)
{
  TestM = false ;
  for (j = 1; j < sAdr.length; j++) {
    if (sAdr.charAt(j) == '@') { 
      if (j < (sAdr.length-4)) { 
        for (k = j; k < sAdr.length-2; k++) { 
          if (sAdr.charAt(k) == '.') {
            TestM = true; 
            break;
          }
        } 
      } 
    } 
  } 
  if (TestM == false) alert('Votre adresse e-mail est incorrecte.'); 
  return TestM; 
}
