<!--

var premier_clic = true;

var eAccentGrav = "e";
var eAccentAigu = "e";
var eAccentCirc = "e";
var aAccentGrav = "a";

//On teste si le javascript >= 1.2
if ((String.fromCharCode(232))!=false && (String.fromCharCode(232))!=null) {
	var eAccentGrav = String.fromCharCode(232);
	var eAccentAigu = String.fromCharCode(233);
	var eAccentCirc = String.fromCharCode(234);
	var aAccentGrav = String.fromCharCode(224);
}

function ValideForm1(Form) {
	if (premier_clic == false) {
		alert("Execution en cours.");
		return false;
	}
	
	// verif titre
	if (Form.title.value == "") {
		alert("Le champ titre est obligatoire");
		Form.title.focus() ;
		return false;
	}	

	// verif date
	if ((Form.day.value == "")||(Form.month.value == "")||(Form.year.value == "")) {
		alert("La date est incorrecte");
		Form.day.focus() ;
		return false;
	}	

	// verif heure & minute de début
	if ((Form.hour_begin.value == "")||(Form.minute_begin.value == "")||(Form.hour_begin.value > 23)||(Form.minute_begin.value > 59)) {
		alert("L'heure de début du Party est incorrecte");
		Form.hour_begin.focus() ;
		return false;
	}	
	
	// verif organisateur
	if (Form.leader.value == "") {
		alert("Le champ Oragnisateurs est obligatoire");
		Form.leader.focus() ;
		return false;
	}	
	
	// verif lieu
	if (Form.place.value == "") {
		alert("Le champ lieu est obligatoire");
		Form.place.focus() ;
		return false;
	}	
	
	premier_clic = false;
	return true;
}

function ValideForm2(Form) {
	if (premier_clic == false) {
		alert("Execution en cours.");
		return false;
	}
	
	// Verif prix
	var checkOK = "0123456789.,";
	var checkStr = Form.price.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length) {
	      allValid = false;
	      break;
	    }
	}
	if (!allValid) {
	    alert("Le prix du party n'est pas valide, n'inscrivez que des chiffres");
		Form.price.focus() ;
	    return (false);
	}	
	
	premier_clic = false;
	return true;
}

function ValideForm3(Form) {
	if (premier_clic == false) {
		alert("Execution en cours.");
		return false;
	}
	
	// Verif adresse email
	if (Form.mail) {
		if (!verifMail(Form)) {
			return false ;
		}
	}

	// Verif tel
	/*var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-()";
	var checkStr = Form.tel.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length) {
	      allValid = false;
	      break;
	    }
	}
	if (!allValid) {
	    alert("Le numéro de téléphone n'est pas valide");
		Form.tel.focus() ;
	    return (false);
	}*/
	
	// verif password si champ existe
	// Detecter le champ de confirmation car l'autre est present (hidden si modif)
	if (Form.password2) {
		if (!verifPasswd(Form)) {
			return false ;
		}
	}
	
	premier_clic = false;
	return true;
}

function ValideCompte(Form) {
	if (premier_clic == false) {
		alert("Execution en cours.");
		return false;
	}
	
	// Verif numéro de référence
	var checkOK = "0123456789";
	var checkStr = Form.reference.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length) {
	      allValid = false;
	      break;
	    }
	}
	if ((!allValid)||(Form.reference.value == "")) {
	    alert("Le numéro de référence n'est pas valide");
		Form.reference.focus() ;
	    return (false);
	}
	
	// verif password si champ existe
	if (!verifPasswd(Form)) {
			return false ;
	}
	
	premier_clic = false;
	return true;
}

function ValideComm(Form) {
	if (premier_clic == false) {
		alert("Execution en cours.");
		return false;
	}
	
	// Verif nom
	if (Form.auteur.value == "") {
		alert("Le champ nom est obligatoire");
		Form.auteur.focus() ;
		return false;
		}

	// Verif adresse email
	if (Form.mail) {
		if (!verifMail(Form)) {
			return false ;
		}
	}

	if (Form.texte.value == "") {
		alert("Mettez votre commentaire !!");
		Form.texte.focus() ;
		return false;
		}
	
	premier_clic = false;
	return true;
}

function ValideFriend(Form) {
	if (premier_clic == false) {
		alert("Execution en cours.");
		return false;
	}
	
	// Verif adresse email expéditeur
	var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@_.";
	var checkStr = Form.name.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length) {
	      allValid = false;
	      break;
	    }
	}
	if (!allValid) {
	    alert("Ne tapez que lettres, chiffres, et les caract" + eAccentGrav + "res '-@_.'  dans le champ 'Votre courriel'.");
		Form.name.focus() ;
	    return (false);
	}
	
	posiA = checkStr.indexOf('@');
	posiP = checkStr.lastIndexOf('.');
	if (posiA==-1 || (posiP < posiA+3) || (checkStr.length < 5) || (posiP > checkStr.length - 3)) {
	    alert("Votre courriel est erroné");
		Form.name.focus() ;
	    return (false);
	}

	// Verif adresse email destinataire
	var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@_.";
	var checkStr = Form.courriel.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length) {
	      allValid = false;
	      break;
	    }
	}
	if (!allValid) {
	    alert("Ne tapez que lettres, chiffres, et les caract" + eAccentGrav + "res '-@_.'  dans le champ 'courriel de votre ami'.");
		Form.courriel.focus();
	    return (false);
	}
	
	posiA = checkStr.indexOf('@');
	posiP = checkStr.lastIndexOf('.');
	if (posiA==-1 || (posiP < posiA+3) || (checkStr.length < 5) || (posiP > checkStr.length - 3)) {
	    alert("Le courriel de votre ami est erroné.");
		Form.courriel.focus() ;
	    return (false);
	}

	premier_clic = false;
	return true;
}

function verifPasswd (Form) {
	longueur = Form.password.value.length ;
	if (longueur < 4) {
		alert("Le champ Mot de Passe doit comporter de 4 " + aAccentGrav + " 8 caract" + eAccentGrav + "res");
		Form.password.focus() ;
	return false;
	}
	if (Form.password.value == "") {
		alert("Le champ mot de passe est obligatoire");
		Form.password.focus() ;
	return false;
	}
	return true;
}

function verifMail (Form) {
	
	// Verif adresse email
	var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@_.";
	var checkStr = Form.mail.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length) {
	      allValid = false;
	      break;
	    }
	}
	if (!allValid) {
	    alert("Ne tapez que lettres, chiffres, et les caract" + eAccentGrav + "res '-@_.'  dans le champ 'Adresse e-mail'.");
		Form.mail.focus() ;
	    return (false);
	}
	
	posiA = checkStr.indexOf('@');
	posiP = checkStr.lastIndexOf('.');
	if (posiA==-1 || (posiP < posiA+3) || (checkStr.length < 5) || (posiP > checkStr.length - 3)) {
	    alert("Vous n'avez pas indiqu" + eAccentAigu + " une adresse e-mail valide.");
		Form.mail.focus() ;
	    return (false);
	}

	return true;
}
//-->
