<!--

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 ValideRecherche(Form) {


	if((Form.jour_depart.selectedIndex!=0) && (Form.mois_depart.selectedIndex==0))
		{
		 alert("Choose a month for departure.");
		 return false;
		}

	if((Form.jour_arrivee.selectedIndex!=0) && (Form.mois_arrivee.selectedIndex==0))
		{
		 alert("Choose a month for arrival.");
		 return false;
		}

}

function ValideAjout(Form) {
	if (premier_clic == false) {
		alert("In progress.");
		return false;
	}
	
	var hd=Form.heure_depart.value;
	var ha=Form.heure_arrivee.value;
	var md=Form.minute_depart.value;
	var ma=Form.minute_arrivee.value;
	var ed=Form.ecart_depart.selectedIndex;
	var ea=Form.ecart_arrivee.selectedIndex;

	//Verif champ heure de depart
	if((hd != "") || (md != ""))
		{
		if ( isNaN(hd) || (hd<0) || (hd>24) || (hd=="")) {
         alert("Departure time : modify the hour.");
		 return false; 
      	}
		if ( isNaN(md) || (md<0) || (md>59) || (md=="")) {
         alert("Departure time : modify the minutes.");
		 return false; 
      	}
       }

	//Verif champ heure d'arrivee
	if((ha != "") || (ma != ""))
		{
		if ( isNaN(ha) || (ha<0) || (ha>24) || (ha=="")) {
         alert("Arrival time : modify the hour.");
		 return false; 
      	}
		
		if ( isNaN(ma) || (ma<0) || (ma>59) || (ma=="")) {
         alert("Arrival time : modify the minutes.");
		 return false; 
      	}
						
       }

	
	//Verif choix dans liste de villes de depart	
	if (Form.no_ville_depart.selectedIndex==0) {
		alert("Select a City of Departure");
		return false;
		}

	//Verif choix dans liste de villes d arrivee	
	if (Form.no_ville_arrivee.selectedIndex==0) {
		alert("Select a City of Arrival");
		return false;
		}
	
	
	if (Form.contact.value == "") {
		alert("The case Name is mandatory");
		Form.contact.focus() ;
		return false;
	}	
	
	if (Form.mail.value == "") {
		alert("The case E-mail is mandatory");
		Form.mail.focus() ;
		return false;
	}	
	
	// Verif adresse email
	if (Form.mail.value!="") {
		if (!verifMail(Form)) {
			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 progress.");
		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 not valid");
		Form.reference.focus() ;
	    return (false);
	}
	
	// verif password si champ existe
	if (!verifPasswd(Form)) {
			return false ;
	}
	
	premier_clic = false;
	return true;
}

function verifPasswd (Form) {
	longueur = Form.password.value.length ;
	if (longueur < 4) {
		alert("The case Password has to be consisted of 4 to 8 characters");
		Form.password.focus() ;
	return false;
	}
	if (Form.password.value == "") {
		alert("The case Password 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("Type only letters, numbers and the characters '-@_.'  in the case '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;
}
//-->