function valider(strLangue,intForm)
{
var msg = "";
var nom_browser = navigator.appName.toLowerCase();
var version_browser = parseFloat(navigator.appVersion);

switch( strLangue.toLowerCase() )
	{
	case "fr" :
		msg = "Vous utilisez un navigateur de version antérieure, \nla validation des champs n'est pas activée.\nÊtes-vous sûr d'avoir rempli tous les champs obligatoires ? "
	break;
	case "an" :
		msg = "You are using a navigator version that does not support the validation of the input.\nAre you sure that you have completed all the mendatory fields?"
	break;
	case "es" :
		msg = "You are using a navigator version that does not support the validation of the input.\nAre you sure that you have completed all the mendatory fields?"
	break;
	}

if (nom_browser == "netscape" && version_browser < 5) 
	return confirm(msg);
else
	return validation(strLangue,intForm)
}


function assignerVarMsg(strLangue)
{
switch( strLangue.toLowerCase() )
	{
	case "fr" :
			msgHeader = "Votre formulaire est incomplet :\t\t\n       Entrez :\n\n"
			msgFooter = "\n\nVeuillez faire les corrections qui s'imposent.\t\t"	
			strAnnee = " (Année)"
			strMois = "  (Mois)"
			strJour = "  (Jour)"
			strFormat = " - AAAA-MM-JJ"
	break;
	case "an" :
			msgHeader = "Your form is not complete :\t\t\n       Please enter :\n\n"
			msgFooter = "\n\nPlease make the corrections which are essential.  \t\t"
			strAnnee = " (Year)"
			strMois = " (Month)"
			strJour = " (Day)"
			strFormat = " - YYYY-MM-DD"
	break;
	case "es" :
			msgHeader = "Su formulario está incompleto :\t\t\n       Ingrese :\n\n"
			msgFooter = "\n\nSírvase hacer la correcciones necesarias.\t\t"	
			strAnnee = " (Año)"
			strMois = " (Mes)"
			strJour = " (Día)"
			strFormat = " - AAAA-MM-DD"
	break;
	}
msg = "";
space = "\t- ";
return true;
}  // Fin de la fonction assignerVarMsg()  ////////////////////////////////////////////////////////



function validation(strLangue,intForm)
{
//--------------------------------------------------------------------
//Les variables utilisées:  -----------------------------------------

assignerVarMsg(strLangue);

var blnFocus = true;
var msg = "";
//--------------------------------------------------------------------

if (intForm==null)
	intForm=0
	
	
with (document.forms[intForm])
	{
	for(i=0;i<elements.length;i++)
		{
		if(elements[i].title != "" )
			{
			switch(elements[i].type)
				{
				case "radio":
				case "checkbox":
					var control = eval("document.forms[intForm]." + elements[i].name)
					var crochet = false;
					
					if(control.length > 1 )
						{
						for(j=0;j<control.length;j++)
							{
							if (control[j].checked)
								{
								crochet = true;
								j = control.length
								}
							}
							
						if (!crochet)
							{
							msg += space + elements[i].title + "\n"
							i = i + control.length
							}
						}
				break;
				
				case "text":
					strName = elements[i].name.toLowerCase()
					if(strName.search("email")!= -1 || strName.search("courriel")!= -1 || strName.search("couriel")!= -1 )
						{
						var posA = elements[i].value.indexOf("@",1)
						var posPoint = elements[i].value.indexOf(".",posA + 2)

						if ( posA == -1 || posPoint >= elements[i].value.length-1 || posPoint == -1)
							{
							msg += space + elements[i].title + "\n"
							if (blnFocus){elements[i].focus();blnFocus=false;}
							}
						}
					else
						if(elements[i].value == "")
							{
							msg += space + elements[i].title + "\n"
							if (blnFocus){elements[i].focus();blnFocus=false;}
							}
						else if ( (elements[i].name.search("dte") != -1 || elements[i].className=="date") && validDate(elements[i].value)) 
							{
							msg += space + elements[i].title + validDate(elements[i].value) + "\n"
							if (blnFocus){elements[i].focus();blnFocus=false;}
							}
				break;
				
				case "textarea":
					if(elements[i].value == "")
						{
						msg += space + elements[i].title + "\n"
						if (blnFocus){elements[i].focus();blnFocus=false;}
						}
								
				break;
				
				case "password":
					if(elements[i+1].type=="password")
						{
						strName = elements[i+1].name.toLowerCase()
						if(strName.search("pwd")!= -1 || strName.search("passe")!= -1 || strName.search("password")!= -1)
							{
							if(elements[i].value == "" || elements[i].value != elements[i+1].value)
								{
								msg += space + elements[i].title + "\n"
								if (blnFocus){elements[i].focus();blnFocus=false;}
								}
							i++;
							}
						}
					else if (elements[i].value == "")
							{
							msg += space + elements[i].title + "\n"
							if (blnFocus){elements[i].focus();blnFocus=false;}
							}
				break;
				
				case "select-one":
					if(elements[i].selectedIndex == -1)
						msg += space + elements[i].title + "\n"
					else if(elements[i].options[elements[i].selectedIndex].value == "")
						msg += space + elements[i].title + "\n"
				break;
				
				case "file":
					if(elements[i].value == "")
						msg += space + elements[i].title + "\n"
				break;
				}
			}
		}	
	}
if ( msg.length > 0 )
	{
	alert(msgHeader + msg + msgFooter) 
	return false
	}
return true;
}// FIN valider()  ///////////////////////////////////////////////////////////////////////



function validDate(strDateValue)
{
var strRetour = false
strDateValue = strDateValue.replace("/","-")
strDateValue = strDateValue.replace("\\","-")
var arrDate = strDateValue.split("-");			
		
if (arrDate.length != 3)
	strRetour = strFormat;
else if (arrDate[0].length != 4 || isNaN(arrDate[0]))
	strRetour = strFormat + strAnnee;
else if (parseFloat(arrDate[1]) > 12 || parseFloat(arrDate[1]) < 1)
	strRetour = strFormat + strMois;
else if (parseFloat(arrDate[2]) > 31 || parseFloat(arrDate[2]) < 1 || arrDate[2]=="")
	strRetour = strFormat + strJour;
	
return strRetour;		
}// Fin validDate()  ////////////////////////////////////////////////////////////////////////////////////


function validerDate(objtxtDate,strLangue)
{
// Cette fonction permet de valider le contenu
// d'un textbox date même si le champs n'est pas obligatoire.
if ( objtxtDate.value )
	{
	assignerVarMsg(strLangue);
	var strRetour = validDate(objtxtDate.value);

	if ( strRetour )
		{
		alert(msgHeader +"\t"+strRetour + msgFooter)
		objtxtDate.focus();
		}
	}
}  // Fin de la fonction validerDate()  /////////////////////////////////////////////////////////
							


function numeric(event) 
{
//   Cette fonction s'assure qu'un txtBox ne contienne
//   que des nombres à décimale.
//   Pour l'utiliser il suffit d'inscrire dans le textBox:
//   onkeypress="return numeric(event)"


if(document.all)
	asc=event.keyCode
else
	asc=event.which
		
if(asc<48 || asc>58)
	if(asc!=44 && asc!=46 && asc != 8 && asc != 0 && asc!=13)
		return false
}// FIN de numeric()  /////////////////////////////////////////



function telephone(event) 
{
//   Cette fonction s'assure qu'un txtBox ne contienne
//   qu'un no de tél.
//   Pour l'utiliser il suffit d'inscrire dans le textBox:
//   onkeypress="return telephone(event)"

if(document.all)
	asc=event.keyCode
else
	asc=event.which

if(asc<48 || asc>57)
	if(asc!=40 && asc!=41 && asc!=45 & asc!=32 && asc != 8 && asc != 0 && asc!=13)
		return false
}// FIN de numeric()  /////////////////////////////////////////


function integer(event)
{
//   Cette fonction s'assure qu'un textBox ne contienne
//   que des nombres entiers.
//   Pour l'utiliser il suffit d'inscrire dans le textBox:
//   onkeypress="return integer(event)"

if(document.all)
	asc=event.keyCode
else
	asc=event.which

if(asc<48 || asc>57)
	if(asc != 8 && asc != 0 && asc!=13 )
		return false
}//FIN de integer()  //////////////////////////////////////////


function trim(str)
{
var i = 0
while(str.charAt(i++)==" ");
j=str.length;
while(str.charAt(--j)==" ");
str=str.slice(--i,++j);
return str;
}//FIN de trim()  ////////////////////////////////////////////
