
function init() {
	// on recupere chaque champ a verifier;
	var email = document.getElementById('email');
	
	// initialise l'appel aux fonctions pour chaque champ
	// il y a des différences de traitement DOM entre IE et Firefox, notamment pour l'affectation d'évenement
	// pour IE
	if (window.attachEvent) {
		email.onkeyup = function() { verifEmail(email); };
	}
	// pour Firefox
	else {
		email.setAttribute('onKeyUp', 'verifEmail(email)');
	}
}

function verifEmail(email) {
	adresse = email.value;
	email_alert = document.getElementById('email_alert');
	// suppression du texte existant
	while(email_alert.firstChild != null) {
		email_alert.removeChild(email_alert.firstChild);
	}
	// creation du message suivant le cas
	if (!checkEmail(adresse)) {
		var texte = document.createTextNode("Format d'adresse incorrect");
		email_alert.appendChild(texte);
	} else {
		var texte = document.createTextNode("Format d'adresse correct");
		email_alert.appendChild(texte);
	}
}

function checkEmail(email) {
	var arobase = email.indexOf("@");
	var point = email.lastIndexOf(".");
	if((arobase < 3) || (point + 3 > email.length) || (point < arobase+3)) {
		return false;
	}
	return true;
}