function compteur() {
var f = document.contact.MessageContact;
var txt = f.value;
var nb  = txt.length;
if (nb > 1500) {
    alert("Pas plus de 1500 caractères dans ce champ. Merci");
    f.value=txt.substring(0,1500);
    nb=1500;
    }
}

function timer() {
	compteur();
	setTimeout("timer()",100);
}

function check(formElement)
{
	/*	Ajouter dans cette fonction l'ensemble des controles à faires sur les champs de formulaires avant soumission du formulaire.	*/

	var test=true;
	var message='';
	var missingother=false;
	var missingotherradio=false;
	var testradio=true;
	//alert('Longueur : ' + formElement.length);
	for (i=0;i<formElement.length;i++) {
		curnom = formElement[i].name
		curlength=curnom.length;
		IsValide = (curnom=='valide');
		IsAxn = (curnom=='axn');
		IsType = (curnom.substr(curlength-4,4)=='type');
		IsCodeRef = (curnom=='CodesReferences');
		IstRef = (curnom=='tReference');
		IsUploadFichier = (curnom=='uploadfichier');
		IsRequired = (curnom.substr(curlength-8,8)=='Required');
		IsMessage = (curnom.substr(0,7)=='Message');
		IsEmail = (curnom.substr(0,5)=='Email');
		if (IsMessage==true) {
			var f = document.contact.MessageContact;
			var txt = f.value;
			var nb  = txt.length;
			if (nb > 1500) {
				message+='\nPas plus de 1500 caractères dans le message';
				f.value=txt.substring(0,1500);
				test=false;
			}
		}
		if (IsType==false && IsValide==false && IsRequired==false && IsAxn==false && IsCodeRef==false && IstRef==false && IsUploadFichier==false) {
			//IsCurRequired = (formElement[i-2].value==1);
			IsCurRequired = (formElement[curnom+'_Required'].value==1);
			//IsCurSuggested = (formElement[i-2].value==3);
			IsCurSuggested = (formElement[curnom+'_Required'].value==3);
			//curtype = formElement[i-1].value;
			curtype = formElement[curnom+'_type'].value;
			curvalue = formElement[curnom].value;
			curtypeelement = formElement[curnom].type;
			if (curvalue=='NULL') curvalue='';
			if (IsCurRequired) {
				//alert('curnom : ' + curnom + ' : ' + curtypeelement);
				if (IsEmail==true && isNotEmailAdress(curvalue))
				{
					message+='\nVous devez saisir une adresse email valide !';
					formElement[curnom].style.backgroundColor='red';
					formElement[curnom].style.color='white';
					test=false;
				}
				else  {
					if (curtypeelement==undefined) {
						radio = formElement[curnom]
						radiostyle = document.getElementById(curnom+'_style');
						radiostyle.style.backgroundColor='red';
						radiostyle.style.color='white';
						missingotherradio=true;
						//radio.style.backgroundColor='red';
						//radio.style.border='2px solid red';
						//radio.style.color='white';
						testradio=false;
						for (var j=0; j<radio.length;j++) {
							if (radio[j].checked) {
								missingotherradio=false;
								radiostyle.style.backgroundColor='white';
								radiostyle.style.color='#000000';
								testradio=true;
							}
						}
					}
					else {
					
						if (isEmpty(curvalue))
						{
							missingother=true;
							formElement[curnom].style.backgroundColor='red';
							formElement[curnom].style.color='white';
							test=false;
						}
						else
						{
							formElement[curnom].style.backgroundColor='white';
							formElement[curnom].style.color='#000000';
						}
					}
				}
			}
			if (IsCurSuggested && test && testradio) {
				if (isEmpty(curvalue)) {
					test=confirm('Aucun fichier joint.\nSouhaitez-vous valider le formulaire sans joindre de document ?');
				}
			}
		}
	
	}
	if (missingother || missingotherradio) message+='\nToutes les informations en gras doivent être saisies !';
	if (message!='')  {
		alert(message);
		test=false;
	}
	return test;
}