<!--

	function checkPassword()
	{
		var myFrom=document.post;
		var formErrors = false;

		if (myFrom.assoce_form_password_old.value.length == 0)
			formErrors="Vous devez entrer votre ancien password avant de valider.";
		else if (myFrom.assoce_form_password_new.value.length < 8)
			formErrors="Vous nouveau password doit comporter au moins 8 caracteres.";
		else if (myFrom.assoce_form_password_new.value != myFrom.assoce_form_password_renew.value)
			{
				myFrom.assoce_form_password_renew.value='';
				formErrors="Veuillez reconfirmer votre nouveau mot de passe";
			}
		else if (myFrom.assoce_form_password_new.value == myFrom.assoce_form_password_old.value)
				formErrors="Le nouveau password doit etre different de l'ancien";

		if (!formErrors) {return true;}

		alert(formErrors);
		return false;
	}

	function activeSize()
	{
		var myForm=document.post;
		for (var i=0;i< myForm.length; i++)
		{
			if (myForm.elements[i].name=="assoce_form_taille")
			{
				myForm.elements[i].disabled=!myForm.assoce_form_teeShirt.checked;
			}
			if (myForm.elements[i].name=="assoce_form_teeShirt_fdp")
			{
				myForm.elements[i].disabled=!myForm.assoce_form_teeShirt.checked;
			}
		}
	}

	function checkFormIdent()
	{
		formErrors = false;

		if (document.post.login.value.length == 0)
			formErrors = "Vous devez entrer votre login avant de valider.";
		else if (document.post.password.value.length == 0)
			formErrors = "Vous devez entrer votre password avant de valider.";

		if (!formErrors) {return true;}

		alert(formErrors);
		return false;
	}

	function checkForm()
	{
		var myForm=document.post;
		msg="";

		if (myForm.assoce_form_nom.value.length == 0) msg+="Nom\n";
		if (myForm.assoce_form_prenom.value.length == 0) msg += "Prénom\n";
		if (myForm.assoce_form_email.value.length == 0) msg += "E-mail\n";
		if (myForm.assoce_form_adresse.value.length == 0) msg += "Adresse\n";
		if (myForm.assoce_form_codePostal.value.match(/^\d+$/) == null) msg += "Code postal\n";
		if (myForm.assoce_form_ville.value.length == 0) msg += "Ville\n";
		if (myForm.assoce_form_pays.value.length == 0) msg += "Pays\n";
		if (myForm.assoce_form_telephone.value.length == 0) msg += "Téléphone\n";

		if (myForm.assoce_form_para[0].checked)
			{
				if (myForm.assoce_form_dateDebut.value == "null") msg += "Date de début\n";
				if (myForm.assoce_form_method.value == "null") msg += "Méthod\n";
				if (myForm.assoce_form_total.value.match(/^\d+$/) == null) msg += "Nbr saut total\n";
				if (myForm.assoce_form_annuel.value.match(/^\d+$/) == null) msg += "Nbr saut annuel\n";
				if (!myForm.assoce_form_matos[0].checked && !myForm.assoce_form_matos[1].checked) msg += "Matos perso\n";
				if (myForm.assoce_form_matos[0].checked || (!myForm.assoce_form_matos[0].checked && !myForm.assoce_form_matos[1].checked))
					{
						if (myForm.assoce_form_sac.value.length == 0) msg += "Sac/Harnais\n";
						if (myForm.assoce_form_vp.value.length == 0) msg += "Voile principale\n";
						if (myForm.assoce_form_vr.value.length == 0) msg += "Voile réserve\n";
					}
			}
		for (var i=0;i< myForm.length; i++)
		{
			if (myForm.elements[i].name=="assoce_form_teeShirt" && myForm.assoce_form_teeShirt.checked)
			{
				result=false;
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name=="assoce_form_taille" && myForm.elements[i].checked) result=true;
				}
				if (!result) msg += "Taille de tee-shirt\n";
				break;
			}
		}

		if (msg.length==0) return true;

		msg="Veuillez saisir CORRECTEMENT le(s) champ(s) suivant(s) avant de valider votre formulaire\n\n" + msg;
		alert(msg);
		return false;
	}

	function changeStatus()
	{
		document.post.assoce_form_submit.disabled=!document.post.assoce_form_accepte.checked;
		enableMatos(document.post.assoce_form_accepte.checked);
	}

	function checkPara(indice)
	{
		enableAll(document.post.assoce_form_para[indice].value=="oui");
	}

	function checkMatos(indice)
	{
		enableMatos(document.post.assoce_form_matos[indice].value=="oui");
	}

	function enableAll(status)
	{
		var myForm=document.post;
		myForm.assoce_form_dateDebut.disabled=!status;
		myForm.assoce_form_method.disabled=!status;
		myForm.assoce_form_total.disabled=!status;
		myForm.assoce_form_annuel.disabled=!status;
		for (var i=0;i< myForm.length; i++)
		{
			if (myForm.elements[i].name=="assoce_form_brevets[]") myForm.elements[i].disabled=!status;
			if (myForm.elements[i].name=="assoce_form_disciplines[]") myForm.elements[i].disabled=!status;
		}
		myForm.assoce_form_matos[0].disabled=!status;
		myForm.assoce_form_matos[1].disabled=!status;
		enableMatos(status);
	}

	function enableMatos(status)
	{
		var myForm=document.post;
		myForm.assoce_form_sac.disabled=!status;
		myForm.assoce_form_vp.disabled=!status;
		myForm.assoce_form_vr.disabled=!status;
	}

	function init(para,matos)
	{
		var myForm=document.post;
		for (var i=0;i< myForm.length; i++)
		{
			if (myForm.elements[i].name=="assoce_form_accepte") myForm.assoce_form_submit.disabled=!myForm.assoce_form_accepte.checked;
		}
		checkPara(para);
		checkMatos(matos);
		activeSize();
	}

	function autoCheck(brevets)
	{
		var myForm=document.post;
		found=false;
		for (var i=0;i< myForm.length; i++)
		{
			if (myForm.elements[i].name=="assoce_form_brevets[]" && myForm.elements[i].value==brevets && myForm.elements[i].checked==true)
			{
				found=true;
				break;
			}
		}
		if (!found) return;

		switch(brevets)
		{
			case 'PAC':
			case 'TDM':
			case 'BEES2':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='BEES1') myForm.elements[i].checked=true;
				}
			case 'MF':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='C') myForm.elements[i].checked=true;
				}
			case 'INIT B1':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='INIT B1' && myForm.elements[i].checked)
					{
						for (var i=0;i< myForm.length; i++)
						{
							if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
							if (myForm.elements[i].value=='B1') myForm.elements[i].checked=true;
						}
						break;
					}
				}
			case 'INIT B2':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='INIT B2' && myForm.elements[i].checked)
					{
						for (var i=0;i< myForm.length; i++)
						{
							if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
							if (myForm.elements[i].value=='B2') myForm.elements[i].checked=true;
						}
						break;
					}
				}
			case 'INIT B3':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='INIT B3' && myForm.elements[i].checked)
					{
						for (var i=0;i< myForm.length; i++)
						{
							if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
							if (myForm.elements[i].value=='B3') myForm.elements[i].checked=true;
						}
						break;
					}
				}
			case 'INIT B4':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='INIT B4' && myForm.elements[i].checked)
					{
						for (var i=0;i< myForm.length; i++)
						{
							if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
							if (myForm.elements[i].value=='B4') myForm.elements[i].checked=true;
						}
						break;
					}
				}
			case 'C':
			case 'B1':
			case 'B2':
			case 'B3':
			case 'B4':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='B') myForm.elements[i].checked=true;
				}
			case 'B':
				for (var i=0;i< myForm.length; i++)
				{
					if (myForm.elements[i].name!="assoce_form_brevets[]") continue;
					if (myForm.elements[i].value=='A') myForm.elements[i].checked=true;
				}
				break;
		}
	}

	function emailCheck (emailStr) {
	/* The following pattern is used to check if the entered e-mail address
	   fits the user@domain format.  It also is used to separate the username
	   from the domain. */
	var emailPat=/^(.+)@(.+)$/
	/* The following string represents the pattern for matching all special
	   characters.  We don't want to allow special characters in the address.
	   These characters include ( ) < > @ , ; : \ " . [ ]    */
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	/* The following string represents the range of characters allowed in a
	   username or domainname.  It really states which chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]"
	/* The following pattern applies if the "user" is a quoted string (in
	   which case, there are no rules about which characters are allowed
	   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	   is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")"
	/* The following pattern applies for domains that are IP addresses,
	   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	   e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* The following string represents an atom (basically a series of
	   non-special characters.) */
	var atom=validChars + '+'
	/* The following string represents one word in the typical username.
	   For example, in john.doe@somewhere.com, john and doe are words.
	   Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")"
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	/* The following pattern describes the structure of a normal symbolic
	   domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	/* Finally, let's start trying to figure out if the supplied address is
	   valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	   different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
	  /* Too many/few @'s or something; basically, this address doesn't
	     even fit the general mould of a valid e-mail address. */
		alert("L'adresse semble invalide (verifier @ et .'s)")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	// See if "user" is valid
	if (user.match(userPat)==null) {
	    // user is not valid
	    alert("Le user n'est pas valid")
	    return false
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	    // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("Destination IP address is invalid!")
			return false
		    }
	    }
	    return true
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("Le nom de domaine n'est pas valid")
	    return false
	}

	/* domain name seems valid, but now make sure that it ends in a
	   three-letter word (like com, edu, gov) or a two-letter word,
	   representing country (uk, nl), and that there's a hostname preceding
	   the domain or country. */

	/* Now we need to break up the domain to get a count of how many atoms
	   it consists of. */
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 ||
	    domArr[domArr.length-1].length>3) {
	   // the address must end in a two letter or three letter word.
	   alert("L'adrese doit se terminer par les 3 lettres d'un domaine ou les 2 lettres d'un pays.")
	   return false
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="L'adresse n'a pas de nom de serveur!"
	   alert(errStr)
	   return false
	}

	// If we've gotten this far, everything's valid!
	return true;
	}

	function checkEmail(adresseMail)
	{
		if (adresseMail.length == 0) return true;
		if (emailCheck(adresseMail)) return true;
		document.post.assoce_form_email.focus();
	}

//-->

