<!--

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("In process.");
		return false;
	}
	
	// verif titre
	if (Form.title.value == "") {
		alert("The 'title' field is mandatory");
		Form.title.focus() ;
		return false;
	}	

	// verif date
	if ((Form.day.value == "")||(Form.month.value == "")||(Form.year.value == "")) {
		alert("The date is incorrect");
		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("The party's starting time is incorrect");
		Form.hour_begin.focus() ;
		return false;
	}	
	
	// verif organisateur
	if (Form.leader.value == "") {
		alert("The 'Organizers' field is mandatory");
		Form.leader.focus() ;
		return false;
	}	
	
	// verif lieu
	if (Form.place.value == "") {
		alert("The 'place' field is mandatory");
		Form.place.focus() ;
		return false;
	}	
	
	premier_clic = false;
	return true;
}

function ValideForm2(Form) {
	if (premier_clic == false) {
		alert("In process.");
		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("The price of the party is invalide, please enter only numbers.");
		Form.price.focus() ;
	    return (false);
	}	
	
	premier_clic = false;
	return true;
}

function ValideForm3(Form) {
	if (premier_clic == false) {
		alert("In process.");
		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("The phone number is invalid");
		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("In process.");
		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("The reference number is invalid");
		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("In process.");
		return false;
	}
	
	// Verif nom
	if (Form.auteur.value == "") {
		alert("The 'name' field is mandatory");
		Form.auteur.focus() ;
		return false;
		}

	// Verif adresse email
	if (Form.mail) {
		if (!verifMail(Form)) {
			return false ;
		}
	}

	if (Form.texte.value == "") {
		alert("Add your comment !!");
		Form.texte.focus() ;
		return false;
		}
	
	premier_clic = false;
	return true;
}

function ValideFriend(Form) {
	if (premier_clic == false) {
		alert("In process.");
		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("Only include letters, numbers and the following characters '-@_.'  in 'your e-mail'.");
		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("Your e-mail is incorrect");
		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("Only include letters, numbers and the following characters '-@_.'  in 'your friend's e-mail'.");
		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("Your friend's e-mail is incorrect.");
		Form.courriel.focus() ;
	    return (false);
	}

	premier_clic = false;
	return true;
}

function verifPasswd (Form) {
	longueur = Form.password.value.length ;
	if (longueur < 4) {
		alert("The 'password' field must be comprised of 4 to 8 characters");
		Form.password.focus() ;
	return false;
	}
	if (Form.password.value == "") {
		alert("The 'password' field is mandatory");
		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("Only include letters, numbers and the following characters '-@_.'  in '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("You have not indicated a valid e-mail address.");
		Form.mail.focus() ;
	    return (false);
	}

	return true;
}
//-->
