
var saison=0 // 0 hiver 1 été

function updateDestinations(s) {
	var objSelect = document.DESTINATION.CARTE;

	objselvid(objSelect);

	objOption = document.createElement("option");
	objOption.innerHTML = "Choisissez";
	objOption.value = "";
	objSelect.appendChild(objOption);

	for (var i=1;i<destination[s].length;i++){
		if(destination[s][i][1]!=''){
			objOption = document.createElement("option");
			objOption.innerHTML = destination[s][i][0];
			objOption.value = destination[s][i][1];
			optGroup.appendChild(objOption);
		} else {
			optGroup = document.createElement("optgroup");
			optGroup.label = destination[s][i][0];
			optGroup.value = destination[s][i][1];
			objSelect.appendChild(optGroup);
		}
	}
	updateLocalabs(1);
}

function updateDate(s){
	var objSelect = document.DESTINATION.DATEDEB;

	objselvid(objSelect);

	objOption = document.createElement("option");
	objOption.innerHTML = "Choisissez votre date";
	objOption.value = "";
	objSelect.appendChild(objOption);

	for(var i=1;i<datedep[s].length;i++){
		objOption = document.createElement("option");
		objOption.innerHTML = datedep[s][i][0];
		objOption.value = datedep[s][i][1];
		objSelect.appendChild(objOption);
	}
}

function  updateLocalisation(dest){

	var d=0;
	var s=saison;
	for(var i=1;i<destination[s].length;i++){
		if(destination[s][i][1]==dest){
			d=i;
		}
	}

	updateLocalabs(d);
	deselectheme();
}
function updateLocalabs(d){

	var objSelect = document.DESTINATION.PAGE;
	var s=saison;
	objselvid(objSelect);

	objOption = document.createElement("option");
	objOption.innerHTML = "Indifférent";
	objOption.value = "";
	objSelect.appendChild(objOption);

	for(var i=0;i<destination[s][d][2].length;i++){
		objOption = document.createElement("option");
		objOption.innerHTML = destination[s][d][2][i][0];
		objOption.value = destination[s][d][2][i][1];
		objSelect.appendChild(objOption);
	}
}

function updateThemes(s){
	var objSelect = document.DESTINATION.CODTHE;

	objselvid(objSelect);

	objOption = document.createElement("option");
	objOption.innerHTML = "Choisissez un thème";
	objOption.value = "";
	objSelect.appendChild(objOption);

	for(var i=0;i<themes[s].length;i++){
		objOption = document.createElement("option");
		objOption.innerHTML = themes[s][i][0];
		objOption.value = themes[s][i][1];
		objSelect.appendChild(objOption);
	}
}

function deselectlocal(){
	var objSelect = document.DESTINATION.CARTE;
	objSelect.options.selectedIndex = 0;
	var objSelect = document.DESTINATION.PAGE;
	objselvid(objSelect);

}

function changeAction() {
	document.DESTINATION.action="/cgi-net/ebuilder/RECHERCHE";
	document.DESTINATION.submit();
}

function changeActionDest() {
	document.DESTINATION.action="/cgi-net/ebuilder/CHOIX_RES";
	document.DESTINATION.submit();
}
/*
function swapsaison(s)
{
	
	

	document.DESTINATION.SAISON.value=(s==1)?'E07':'H07';
	document.DESTINATION.CODV02.value=(s==1)?'E07':'H07';
	document.DESTINATION.CODH.value=(s==1)?'320':'220';
if (document.getElementById("img-top") && (document.getElementById("img-top").src=='/img/bandeau-ete.jpg' || document.getElementById("img-top").src=='/img/locations-hiver-top.jpg')) {
    document.getElementById("img-top").src=(s==1)?'/img/bandeau-ete.jpg':'/img/locations-hiver-top.jpg';
}
	saison = s;
	montre(s);
	updateDestinations(s);
	updateDate(s);
	updateThemes(s);
	deselectlocal();
	deselectheme();
	
}
*/
function objselvid(objSelect){
	while (objSelect.hasChildNodes()) {
		objSelect.removeChild(objSelect.lastChild);
	}
}

function deselectheme(){
	var objSelect = document.DESTINATION.CODTHE;
	objSelect.options.selectedIndex = 0;
}
