// JavaScript Document
 list_choix = {
"trianon" : ["Mobil Home Confort", "Caravane estivale"],
"ladune" : ["Mobil Home Classic", "Mobil Home Confort", "Mobil Home 4 places"],
"vieuxport" : ["Mobil Home Espace 3ch ","Mobil Home Espace 2ch","Mobil Home Confort", "Module sans sanitaire", "Caravane estivale"],
"loupignada" : ["Chalet", "Mobil Home Confort","Mobil Home 4 places","Caravane estivale"],
"marina" : ["Mobil Home Confort"],
"interherault" : ["Mobil Home Confort", "Mobil Home Classic"],
"boscdenroug" : ["Mobil Home 2/4 places", "Mobil Home 4/6 places"]
} 
  
  
 function ajout(selection){

	while(document.getElementById("hebergement").hasChildNodes()) {
		var noeud=document.getElementById("hebergement").firstChild;
		disparu = document.getElementById("hebergement").removeChild(noeud);
		}

	new_option = document.createElement("option");
	document.getElementById("hebergement").appendChild(new_option);
	new_option.value = "";
	new_option.text = "Choisissez";

selection = selection.options[selection.selectedIndex].value;
if ( list_choix[selection] ) {
	for (var i=0; i<list_choix[selection].length; i++) {
		new_option = document.createElement("option");
		document.getElementById("hebergement").appendChild(new_option);
		new_option.value = list_choix[selection][i];
		new_option.text = list_choix[selection][i];
		}
	}


} 
function Calcul() {
theform=document.forms["formulaireresa"];
ok=true;
if (isNaN(theform.montant_sejour.value)||(theform.montant_sejour.value<=0)||(theform.montant_sejour.value=="")) {
	alert("Veuillez saisir le montant du séjour")
	ok=false;
	}

var theone=0
for (i=0;i<=theform.garantie_annulation.length;i++){
	if (theform.garantie_annulation[i].checked==true){
		theone=i
		break //exist for loop, as target acquired.
		}
	}	
		
if ((ok==true)&&(theform.garantie_annulation[i].value=="oui")) {
	if (isNaN(theform.nb_jour_garantie_annulation.value)||(theform.nb_jour_garantie_annulation.value<=0)||(theform.nb_jour_garantie_annulation.value=="")) {
		alert("Veuillez corriger le nombre de jour de garantie annulation ou cocher non pour la garantie annulation")
		ok=false;
		}
	}  
	
if ((ok==true)&&(theform.garantie_annulation[i].value=="non")) {
	if (theform.nb_jour_garantie_annulation.value>0) {
		alert("Veuillez corriger le nombre de jour de garantie annulation ou cocher oui pour la garantie annulation")
		ok=false;
		}
	}  

if (ok==true) {
	acc=theform.montant_sejour.value*0.25;
	theform.acompte.value=acc;
	document.getElementById("txtacompte").innerHTML=acc +" €" ;
	
	montantgarantie=theform.nb_jour_garantie_annulation.value*2;
	theform.montant_garantie_annulation.value=montantgarantie;
	document.getElementById("txtmontantgarantieannulation").innerHTML=montantgarantie +" €";
	
	montantregl=acc+montantgarantie+35
	theform.montant_reglement.value=montantregl;
	document.getElementById("txtmontantreglement").innerHTML=montantregl +" €";
	}
return ok;		
}
