
// Boucle de validation

function validateForm(form) {

if (isNotEmpty(form.nom)) {

if (isNotEmpty(form.tel)) {

if (isNotEmpty(form.adresse)) {

if (isNotEmpty(form.ville)) {

if (isNotEmpty(form.pays)) {

if (isNotEmpty(form.jour_de)) {

if (isNotEmpty(form.mois_de)) {

if (isNotEmpty(form.heure_de)) {

if (isNotEmpty(form.agence_de)) {

if (isNotEmpty(form.jour_re)) {

if (isNotEmpty(form.mois_re)) {

if (isNotEmpty(form.heure_re)) {

if (isNotEmpty(form.agence_re)) {

if (isNotEmpty(form.choix0)) {


return true;


}

}

}

}

}

}

}

}

}

}

}

}

}

}

return false;

}


// Vérifie si un champ a bien été renseigné
function isNotEmpty(elem) {
	var str = elem.value;
    var re = /.+/;
    if(!str.match(re)) {
        alert("Please fill the compulsory data");
        setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return false;
    } else {
        return true;
    }
}

// Positionne le curseur dans un champ donné
function focusElement(formName, elemName) {
    var elem = document.forms[formName].elements[elemName];
    elem.focus();
    elem.select();
}

list_choix = {

"tour" : ["NECESSARY : Choose a vehicle" , "Category A1 - Smart", "Category A - RENAULT TWINGO", "Category B - RENAULT CLIO - CITROËN C3 - PEUGEOT 206" , " Category C - RENAULT MEGANE- CITROEN C4 - PEUGEOT 307" , "Category D - RENAULT LAGUNA - RENAULT SCÉNIC - CITROËN C5" , "Category E1 - MERCEDES Classe C" , "Category E2 - MERCEDES Classe E", "Category F - RENAULT ESPACE - CITROËN C8"],
"util" : ["NECESSARY : Choose a vehicle" , "1 to 3m³ - RENAULT KANGOO - CLIO SOCIETE", "4 to 5m³ - MERCEDES VITO - CITROËN JUMPY" , "6 to 9m³ - MERCEDES 208 - RENAULT TRAFIC" , "10 to 12m³ - IVECO DAILY - MERCEDES 208", "20 to 26m³ - MERCEDES 410 - IVECO 35/10" , "20m³ with tailgate" , "Truck with dumper 3,5 tons", "Freight car truck","Refrigerating truck 3m³","Refrigerating truck 5m³","Refrigerating truck 12m³"]
}
function ajout(selection){
	nb_select = selection.parentNode.getElementsByTagName("select").length;
	if ( selection == selection.parentNode.getElementsByTagName("select")[nb_select-1] ) {
		element_select = selection;
		selection = selection.options[selection.selectedIndex].value;
		if ( list_choix[selection] ) {
			new_liste = document.createElement("select");
			element_select.parentNode.appendChild(new_liste);
			new_liste.setAttribute("id", "choix"+nb_select);
			new_liste.setAttribute("name", "choix"+nb_select);
			new_liste.setAttribute("onchange", "ajout(this)");
			for (var i=0; i<list_choix[selection].length; i++) {
				new_option = document.createElement("option");
				new_liste.appendChild(new_option);
				new_option.setAttribute("value", list_choix[selection][i]);
				new_option.text = list_choix[selection][i];
			}
		}
	}
	else {
		selection.parentNode.removeChild(selection.nextSibling);
		ajout(selection)
	}
}

