function annulerInscription(deconnecter) {
if (confirm("Voulez-vous vraiment annuler cette inscription ?")) {
if (deconnecter) {
document.location.href = formAction+"?etape=connexion&todo=deconnecter&redir=annulation";
} else {
document.location.href = formAction+"?etape=voyage&todo=annuler&redir=annulation";
}
}
}
function nouvelleInscription() {
if (confirm("Avez-vous bien imprimé cette page, pour l'envoyer à Amada ?\n\nSi oui, cliquez sur OK pour commencer une nouvelle inscription.")) {
document.location.href = formAction+"?todo=recommencer&redir=nouvelle_inscription";
}
}
function FormateDate(oDate) {
return (oDate.getDate()<10?"0":"")+oDate.getDate()+"/"+((oDate.getMonth()+1)<10?"0":"")+(oDate.getMonth()+1)+"/"+oDate.getFullYear()
}
function date_sql2html(sqldate) {
oRegExp = /^([0-9]{4})[^0-9]([0-9]{2})[^0-9]([0-9]{2}).*$/;
if (oRegExp.test(sqldate)) {
dateParts = oRegExp.exec(sqldate);
jour = parseInt(dateParts[3], 10);
mois = parseInt(dateParts[2], 10);
annee = parseInt(dateParts[1], 10);
testDate = new Date(annee, mois-1, jour);
return FormateDate(testDate);
}
return '';
}
/* ******** CONNEXION ******** */
function connexion_checkForm() {
if (!TesteEMail(document.TheForm.cli_email, 255, true)) return false;
}
function connexion_rappelPwd() {
if (document.TheForm.cli_email.value == '') {
alert("Veuillez saisir l'adresse e-mail que vous avez utilisé lors de votre première inscription.");
document.TheForm.cli_email.focus();
return false;
}
if (!TesteEMail(document.TheForm.cli_email, 255, true)) return false;
document.TheForm.cli_pwd.value = "";
document.TheForm.todo.value = "rappel";
document.TheForm.submit();
}
/* ******** CLIENT ******** */
function client_checkForm() {
if (!TesteEMail(document.TheForm.cli_email, 200, true)) return false;
if (!TesteChaine(document.TheForm.cli_pwd, "Mot de passe", 20, true)) return false;
if (!TesteChaine(document.TheForm.cli_nom, "Nom", 50, true)) return false;
if (!TesteChaine(document.TheForm.cli_prenom, "Prénom", 50, true)) return false;
if (!TesteChaine(document.TheForm.cli_date_naissance, "Date de naissance", 10, true)) return false;
if (!CheckDate2(document.TheForm.cli_date_naissance)) return false;
if (!TesteChaine(document.TheForm.cli_adresse1, "Adresse", 200, true)) return false;
if (!TesteChaine(document.TheForm.cli_code_postal, "Code postal", 20, true)) return false;
if (!TesteChaine(document.TheForm.cli_ville, "Ville", 100, true)) return false;
if (!TesteChaine(document.TheForm.cli_pays, "Pays", 100, true)) return false;
if (document.TheForm.cli_tel_domicile.value == '' && document.TheForm.cli_mobile.value == '') {
alert("Veuillez saisir votre numéro de téléphone (domicile ou mobile).");
document.TheForm.cli_tel_domicile.focus();
return false;
}
if (!TesteChaine(document.TheForm.cli_passeport, "Numéro de passeport", 100, true)) return false;
if (!TesteChaine(document.TheForm.cli_prevenir, "Personne à prévenir", 255, true)) return false;
return true;
}
/* ******** VOYAGE ******** */
function voyage_changeVoyage(oSel) {
voy_id = parseInt(oSel.options[oSel.selectedIndex].value, 10);
if (isNaN(voy_id)) voy_id = 0;
httpRequest("POST", "http://www.amada-aventure.com/static/amada_ajax.htm", true, voyage_ajaxChangeVoyage, "method=detail_voyage&voy_id="+voy_id);
}
function voyage_ajaxChangeVoyage() {
if(ajaxRequest.readyState == 4) {
if (ajaxRequest.status == 200) {
var ajaxResult = ajaxRequest.responseXML;
var xmlResult = ajaxResult.documentElement;
if (xmlResult.hasChildNodes()) {
var voyNode = xmlResult.firstChild;
voy_date_debut = simpleXmlValue(voyNode, "voy_date_debut");
voy_date_fin = simpleXmlValue(voyNode, "voy_date_fin");
voy_moto = simpleXmlValue(voyNode, "voy_moto");
voy_quad = simpleXmlValue(voyNode, "voy_quad");
voy_4x4 = simpleXmlValue(voyNode, "voy_4x4");
voy_raider = simpleXmlValue(voyNode, "voy_raider");
voyage_domChangeVoyage(voy_date_debut, voy_date_fin, parseInt(voy_moto, 10), parseInt(voy_quad, 10), parseInt(voy_4x4, 10), parseInt(voy_raider, 10));
return;
}
}
voyage_domEffaceVoyage();
}
}
function voyage_domChangeVoyage(voy_date_debut, voy_date_fin, voy_moto, voy_quad, voy_4x4, voy_raider) {
var descriptif_voyage = getElt("descriptif_voyage");
while(document.TheForm.type_vehicule.options.length > 1) {
document.TheForm.type_vehicule.options[1] = null;
}
nb_vehicules_possibles = voy_moto + voy_quad + voy_4x4 + voy_raider;
if (voy_raider == 1) {
is_selected = (nb_vehicules_possibles==1 || voyage_insc_vehicule == "4x4 Raider");
document.TheForm.type_vehicule.options[document.TheForm.type_vehicule.options.length] = new Option("4x4 catégorie Raider", "4x4 Raider", is_selected, is_selected);
}
if (voy_4x4 == 1) {
is_selected = (nb_vehicules_possibles==1 || voyage_insc_vehicule == "4x4");
document.TheForm.type_vehicule.options[document.TheForm.type_vehicule.options.length] = new Option("4x4", "4x4", is_selected, is_selected);
}
if (voy_quad == 1) {
is_selected = (nb_vehicules_possibles==1 || voyage_insc_vehicule == "Quad");
document.TheForm.type_vehicule.options[document.TheForm.type_vehicule.options.length] = new Option("Quad", "Quad", is_selected, is_selected);
}
if (voy_moto == 1) {
is_selected = (nb_vehicules_possibles==1 || voyage_insc_vehicule == "Moto");
document.TheForm.type_vehicule.options[document.TheForm.type_vehicule.options.length] = new Option("Moto", "Moto", is_selected, is_selected);
}
if (!descriptif_voyage) {
var td_voyage = getElt("td_voyage");
if (td_voyage) {
descriptif_voyage = document.createElement("div");
if (descriptif_voyage) {
descriptif_voyage.setAttribute("id", "descriptif_voyage");
td_voyage.appendChild(descriptif_voyage);
}
}
}
if (descriptif_voyage) {
tab_voy_date_debut = voy_date_debut.split('-');
str_voy_date_debut = tab_voy_date_debut[2]+"/"+tab_voy_date_debut[1]+"/"+tab_voy_date_debut[0];
tab_voy_date_fin = voy_date_fin.split('-');
str_voy_date_fin = tab_voy_date_fin[2]+"/"+tab_voy_date_fin[1]+"/"+tab_voy_date_fin[0];
descriptif_voyage.innerHTML = "Du "+str_voy_date_debut+" au "+str_voy_date_fin+"";
}
}
function voyage_domEffaceVoyage() {
var descriptif_voyage = getElt("descriptif_voyage");
if (descriptif_voyage) {
descriptif_voyage.parentNode.removeChild(descriptif_voyage);
}
}
function voyage_checkForm() {
if (document.TheForm.voy_id.selectedIndex == 0) {
alert("Veuillez sélectionner le voyage/raid choisi.");
document.TheForm.voy_id.focus();
return false;
}
if (document.TheForm.type_vehicule.selectedIndex == 0) {
alert("Veuillez sélectionner le type de véhicule à inscrire.");
document.TheForm.type_vehicule.focus();
return false;
}
return true;
}
/* ******** PARTICIPANTS ******** */
function participants_ajouteParticipant(actionURL, part_role) {
document.location.href = actionURL+"?etape=participants&todo=ajouter&role="+part_role;
}
function participants_modifieParticipant(actionURL, part_id) {
document.location.href = actionURL+"?etape=participants&todo=modifier&part_id="+part_id;
}
function participants_supprimeParticipant(actionURL, part_id) {
if (!confirm('Voulez-vous vraiment supprimer ce participant ?')) return false;
document.location.href = actionURL+"?etape=participants&todo=supprimer&part_id="+part_id;
}
function participants_changeParticipant(oSel) {
part = oSel.options[oSel.selectedIndex].value;
if (part.substr(0, 9) == "client___") {
if (!confirm("Voulez-vous vraiment pré-remplir le formulaire avec vos données personnelles ?")) {
oSel.selectedIndex = 0;
return;
}
cli_id = parseInt(part.substr(9), 10);
if (isNaN(cli_id)) cli_id = 0;
httpRequest("POST", "http://www.amada-aventure.com/static/amada_ajax.htm", true, participants_ajaxChangeParticipant, "method=detail_clientparticipant&cli_id="+cli_id);
} else {
if (!confirm("Voulez-vous vraiment pré-remplir le formulaire avec les données personnelles de "+oSel.options[oSel.selectedIndex].text+" ?")) {
oSel.selectedIndex = 0;
return;
}
part_id = parseInt(part, 10);
if (isNaN(part_id)) part_id = 0;
httpRequest("POST", "http://www.amada-aventure.com/static/amada_ajax.htm", true, participants_ajaxChangeParticipant, "method=detail_participant&part_id="+part_id);
}
}
function participants_ajaxChangeParticipant() {
if(ajaxRequest.readyState == 4) {
if (ajaxRequest.status == 200) {
var ajaxResult = ajaxRequest.responseXML;
var xmlResult = ajaxResult.documentElement;
if (xmlResult.hasChildNodes()) {
var partNode = xmlResult.firstChild;
part_niveau = simpleXmlValue(partNode, "part_niveau");
part_nom = simpleXmlValue(partNode, "part_nom");
part_prenom = simpleXmlValue(partNode, "part_prenom");
part_date_naissance = simpleXmlValue(partNode, "part_date_naissance");
part_profession = simpleXmlValue(partNode, "part_profession");
part_adresse1 = simpleXmlValue(partNode, "part_adresse1");
part_adresse2 = simpleXmlValue(partNode, "part_adresse2");
part_code_postal = simpleXmlValue(partNode, "part_code_postal");
part_ville = simpleXmlValue(partNode, "part_ville");
part_pays = simpleXmlValue(partNode, "part_pays");
part_tel_domicile = simpleXmlValue(partNode, "part_tel_domicile");
part_tel_pro = simpleXmlValue(partNode, "part_tel_pro");
part_mobile = simpleXmlValue(partNode, "part_mobile");
part_fax = simpleXmlValue(partNode, "part_fax");
part_email = simpleXmlValue(partNode, "part_email");
part_passeport = simpleXmlValue(partNode, "part_passeport");
part_prevenir = simpleXmlValue(partNode, "part_prevenir");
participants_domChangeParticipant(part_niveau, part_nom, part_prenom, part_date_naissance, part_profession, part_adresse1, part_adresse2, part_code_postal, part_ville, part_pays, part_tel_domicile, part_tel_pro, part_mobile, part_fax, part_email, part_passeport, part_prevenir);
return;
}
}
}
}
function participants_domChangeParticipant(part_niveau, part_nom, part_prenom, part_date_naissance, part_profession, part_adresse1, part_adresse2, part_code_postal, part_ville, part_pays, part_tel_domicile, part_tel_pro, part_mobile, part_fax, part_email, part_passeport, part_prevenir) {
if (document.TheForm.part_niveau) {
old_selectedIndex = document.TheForm.part_niveau.selectedIndex;
document.TheForm.part_niveau.selectedIndex = 0;
for (i = 0; i < document.TheForm.part_niveau.options.length; i++) {
if (document.TheForm.part_niveau.options[i].value == part_niveau) {
document.TheForm.part_niveau.selectedIndex = i;
}
}
}
document.TheForm.part_nom.value = part_nom;
document.TheForm.part_prenom.value = part_prenom;
document.TheForm.part_date_naissance.value = date_sql2html(part_date_naissance);
document.TheForm.part_profession.value = part_profession;
document.TheForm.part_adresse1.value = part_adresse1;
document.TheForm.part_adresse2.value = part_adresse2;
document.TheForm.part_code_postal.value = part_code_postal;
document.TheForm.part_ville.value = part_ville;
document.TheForm.part_pays.value = part_pays;
document.TheForm.part_tel_domicile.value = part_tel_domicile;
document.TheForm.part_tel_pro.value = part_tel_pro;
document.TheForm.part_mobile.value = part_mobile;
document.TheForm.part_fax.value = part_fax;
document.TheForm.part_email.value = part_email;
document.TheForm.part_passeport.value = part_passeport;
document.TheForm.part_prevenir.value = part_prevenir;
}
function participants_annulerParticipant() {
if (confirm("Voulez-vous vraiment annuler les modifications concernant ce participant ?")) {
document.location.href = formAction+"?etape=participants&redir=annulation_participant";
}
}
function participants_checkForm() {
if (nb_participants <= 0) {
alert("Veuillez ajouter au moins le pilote.");
if (btn = getElt("ajoutPilote")) {
try {
btn.focus();
} catch (e) {}
}
return false;
}
}
function participants_checkForm2() {
if (!TesteChaine(document.TheForm.part_nom, "Nom", 50, true)) return false;
if (!TesteChaine(document.TheForm.part_prenom, "Prénom", 50, true)) return false;
if (!TesteChaine(document.TheForm.part_date_naissance, "Date de naissance", 10, true)) return false;
if (!CheckDate2(document.TheForm.part_date_naissance)) return false;
if (!TesteChaine(document.TheForm.part_adresse1, "Adresse 1", 255, true)) return false;
if (!TesteChaine(document.TheForm.part_code_postal, "Code postal", 255, true)) return false;
if (!TesteChaine(document.TheForm.part_ville, "Ville", 255, true)) return false;
if (!TesteChaine(document.TheForm.part_pays, "Pays", 255, true)) return false;
if (!TesteChaine(document.TheForm.part_prevenir, "Personne à prévenir", 255, true)) return false;
if (document.TheForm.part_niveau) {
if (document.TheForm.part_niveau.selectedIndex == 0) {
alert("Veuillez choisir le niveau du "+document.TheForm.part_role.value);
document.TheForm.part_niveau.focus();
return false;
}
}
return true;
}
/* ******** GROUPE ******** */
function groupe_modifieGroupe(actionURL) {
document.location.href = actionURL+"?etape=groupe&todo=modifier";
}
function groupe_supprimeGroupe(actionURL) {
if (!confirm('Voulez-vous vraiment supprimer ce groupe ?')) return false;
document.location.href = actionURL+"?etape=groupe&todo=supprimer";
}
function groupe_dechoisitGroupe(actionURL) {
document.location.href = actionURL+"?etape=groupe&todo=dechoisir";
}
function groupe_choisitGroupe(actionURL) {
document.location.href = actionURL+"?etape=groupe&todo=choisir";
}
function groupe_ajouteGroupe(actionURL) {
document.location.href = actionURL+"?etape=groupe&todo=ajouter";
}
/* ******** VEHICULE ******** */
function vehicule_checkForm() {
if (document.TheForm.insc_categorie_moto_quad) {
if (document.TheForm.insc_categorie_moto_quad.selectedIndex == 0) {
alert("Veuillez choisir la catégorie "+document.TheForm.insc_vehicule.value);
document.TheForm.insc_categorie_moto_quad.focus();
return false;
}
}
if (!TesteChaine(document.TheForm.insc_vehicule_marque, "Marque", 100, true)) return false;
if (!TesteChaine(document.TheForm.insc_vehicule_modele, "Modèle", 100, true)) return false;
if (!TesteChaine(document.TheForm.insc_vehicule_annee, "Année", 4, true)) return false;
if (!TesteNombre(document.TheForm.insc_vehicule_annee, "Année", true)) return false;
if (!TesteChaine(document.TheForm.insc_vehicule_immatriculation, "N° immatriculation", 50, true)) return false;
return true;
}
/* ******** ASSURANCE ******** */
function assurance_checkForm() {
if (!TesteChaine(document.TheForm.insc_assurance_vehicule_nom, "Nom de l'assurance véhicule", 200, true)) return false;
if (!TesteChaine(document.TheForm.insc_assurance_vehicule_numero_police, "N° de police de l'assurance véhicule", 100, true)) return false;
if (!TesteChaine(document.TheForm.insc_assurance_vehicule_ville, "Ville de l'assurance véhicule", 100, true)) return false;
if (!TesteChaine(document.TheForm.insc_assurance_vehicule_tel, "N° de téléphone de l'assurance véhicule", 50, true)) return false;
if (document.TheForm.insc_assurance_annulation_amada) {
if (!document.TheForm.insc_assurance_annulation_amada.checked) {
if (!TesteChaine(document.TheForm.insc_assurance_rapatriement_nom, "Nom de l'assurance rapatriement", 200, true)) return false;
if (!TesteChaine(document.TheForm.insc_assurance_rapatriement_numero_police, "N° de police de l'assurance rapatriement", 100, true)) return false;
if (!TesteChaine(document.TheForm.insc_assurance_rapatriement_ville, "Ville de l'assurance rapatriement", 100, true)) return false;
if (!TesteChaine(document.TheForm.insc_assurance_rapatriement_tel, "N° de téléphone de l'assurance rapatriement", 50, true)) return false;
if (!TesteChaine(document.TheForm.insc_assurance_rapatriement_tel_assistance_24, "N° d'appel de l'assistance 24h/24", 50, true)) return false;
}
}
return true;
}
/* ******** PAIEMENT ******** */
function paiement_checkForm() {
var mode_paiement = "";
if (document.TheForm.insc_mode_paiement) {
for (i = 0; i < document.TheForm.insc_mode_paiement.length; i++) {
if (document.TheForm.insc_mode_paiement[i].checked) {
mode_paiement = document.TheForm.insc_mode_paiement[i].value;
}
}
}
if (mode_paiement == "") {
alert("Veuillez sélectionner le mode de paiement");
document.TheForm.insc_mode_paiement[0].focus();
return false;
}
if (!document.TheForm.insc_accepte_conditions_generales.checked) {
alert("Vous devez accepter les conditions générales et particulières pour soumettre le formulaire.\nVeuillez cocher la case correspondante.");
document.TheForm.insc_accepte_conditions_generales.focus();
return false;
}
msg = "Vous allez pouvoir valider votre pré-inscription.\n\nSi vous avez bien vérifié l'exactitude des informations et des montants, veuillez cliquer sur OK pour procéder à l'enregistrement des données saisies.\n\nAprès avoir soumis ce formulaire, vous devrez imprimer votre pré-inscription et l'envoyer à Amada avec votre réglement.";
if (!confirm(msg)) return false;
return true;
}