function inscription() {
	window.document.forms['inscription'].submit();
	return true;
}

function entrez() {
	window.document.forms['entrez'].submit();
	return true;
}

function entrer() {
	email= window.document.login.email.value;
	password= window.document.login.password.value;
	if (verifMail(email)!=true) {
		alert('Votre adresse e-mail est incorrecte.');
		window.document.login.email.focus();
	} else {
		if (password.length<6) {
			alert('Le mot de passe doit contenir au moins 6 caractères.');
			window.document.login.password.focus();
		} else {
			window.document.forms['login'].submit();
			return true;
		}
	}
}

	
function valide_bulletin() {
	if(document.forms['nouveau'].elements['MENTION']) {
		var mention = document.getElementById('MENTION').options[document.getElementById('MENTION').selectedIndex].value;
		if (mention=='-1') {
			alert('Choisissez votre mention.');
			return;
		}
	} 
	boucle = window.document.nouveau.NOMBRE.value;
	var nombre=0;
	var mesapp=0
	var apg = document.getElementById('apg').value; 

	for(i=1;i<=boucle;i++){
		note = document.getElementById('not' + i).value; 
		matiere = document.getElementById('mat' + i).value;
		app = document.getElementById('ap' + i).value;

		if (note.length>0) {
			if (verif_note(note)!=true) {
				alert('La note de la matière :' + matiere + ' n\'est pas correcte');
				window.document.getElementById('not' + i).focus();
				break;
			} else {
				if (matiere.length<3) {
					alert('La note ' + note + ' n\'a pas de matière.');
					window.document.getElementById('mat' + i).focus();
					break;
				} else {
					nombre++;
					if (app.length>3) {
						mesapp++;
					}
				}
			}
		}
	}
	if (nombre<6) {
		alert('Le nombre de notes doit être supérieur à 5');
	} else {
		if (mesapp<4) {
			if (confirm("Voulez-vous compléter les appréciations pour obtenir\n3 semaines de tirage suplémentaire ?")) {
			} else {			
				window.document.forms['nouveau'].submit();
			}
		} else {
			if (apg.length<3) {
				alert('Pensez à remplir l\'appréciation générale.');
				window.document.getElementById('apg').focus();
			} else {
				window.document.forms['nouveau'].submit();
			}
		}
	}
}
	

function verif_note(a) {
	testm = false ;
	var regEx=/^(([0-9]([\.,][0-9]{1,}|))|(1[0-9]([\.,][0-9]{1,}|))|20)$/gi; 
	if (regEx.test(a))  {testm = true;}
	return testm ;
}

function verifMail(a) 
{
	 testm = false ;
	 var regEx=/^[a-zA-Z]+[a-zA-Z0-9\-._]*\@([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,4}$/; 
	 if (regEx.test(a))  {testm = true;}
	return testm ;
}
