function validateonsubmit(){
	if (document.forms['moteurh'].destinationId.options[0].selected){
		alert('veuillez sélectionner une ville de destination');
		return false;
	}
	for(i=1;i<=document.forms['moteurh'].rooms.value;i++){
		for(j=1;j<=document.forms['moteurh'].elements["child"+i].value;j++){
			if(document.forms['moteurh'].elements["age"+i+"_"+j].value==""){
				alert("Chambre " + i + " : Veuillez indiquer l\'âge des enfants");
				return false;
			}
		}
	}
	return true;
}
function validateonsubmit2(){
	if (document.forms['moteurp'].destinationId.options[0].selected){
		alert('veuillez sélectionner une ville de destination');
		return false;
	}
	for(i=1;i<=document.forms['moteurp'].rooms.value;i++){
		for(j=1;j<=document.forms['moteurp'].elements["child"+i].value;j++){
			if(document.forms['moteurp'].elements["age"+i+"_"+j].value==""){
				alert("Chambre " + i + " : Veuillez indiquer l\'âge des enfants");
				return false;
			}
		}
	}
	return true;
}
function changeEnf(f){
	document.getElementById("libAges").style.display="inline";
	tAges = document.getElementById("tab-ages");
	for(i=eval(tAges.rows.length-1);i>=f.elements["rooms"].value;i--){
		tAges.deleteRow(i);
	}
	for(r=1;r<=f.elements["rooms"].value;r++){
		var champ = "document.forms['moteurh'].child"+r+".value";
		//alert(eval(champ));
	}
}
function changeRooms(n,t){
	rooms = document.getElementById(t);
	for(i=eval(rooms.rows.length-1);i>1;i--){
		rooms.deleteRow(i);
	}
	for(i=1;i<n;i++){
		var row = rooms.insertRow(i+1);
		var cell = row.insertCell(0);
		cell.innerHTML = "Chambre " + eval(i+1) + " :";
		
		var cell = row.insertCell(1);
		var sElem = document.createElement('select');
		sElem.name = "adults" + eval(i+1);
		//alert(sElem.name);
		sElem.className="pax";
		
		for(pax=0;pax<=4;pax++){
			var opt = document.createElement("option");
			opt.appendChild(document.createTextNode(pax));
			opt.value = pax;
			if(pax==2) opt.selected = true;
			sElem.appendChild(opt);
		}
		cell.appendChild(sElem);
		var valer=i+1;
		var cell = row.insertCell(2);
		var sElem = document.createElement('select');
		sElem .setAttribute("onchange", "showAges2(this.value,"+valer+")");
		sElem.name = "child" + eval(i+1);
		sElem.className="pax";
		
		//sElem.id=eval(i+1);
		//sElem.setAttribute("className", "pax");
		
		for(pax=0;pax<=3;pax++){
			var opt = document.createElement("option");
			opt.appendChild(document.createTextNode(pax));
			opt.value = pax;
			sElem.appendChild(opt);
		}
		
		if(window.addEventListener){
			//sElem.addEventListener("change", test, true);
			//alert(window.event.srcElement.value);
		}else
			if (window.attachEvent){
				sElem.index = sElem.value;
				sElem.room = sElem.id;
				
				sElem.onchange = function() { 
					changeEnf(document.forms["moteurh"]);
					/*idLib = "room"+this.room+"_age";
					document.getElementById(idLib).style.display="inline";
					q = event.srcElement.value;
					if(q>0){
						document.getElementById("libAges").style.display="inline";
						for(enf=1;enf<=q;enf++){
							ids = "age"+this.room+"_"+enf;
							document.getElementById(ids).style.display="inline";
						}
					}else{
						document.getElementById(idLib).style.display="none";
					}*/
				}
			}
			/*else{
				sElem.index = sElem.value;
				
				sElem.onchange = function() { 
					//alert(this.index);
				}
			}*/
		cell.appendChild(sElem);
	}
}
function changeMoteur(tab){
	var m0 = document.getElementById("moteur-package");
	var m1 = document.getElementById("moteur-hotel");
	var m2 = document.getElementById("moteur-vol");
	
	var ico0 = document.getElementById("ico_package");
	var ico1 = document.getElementById("ico_hotel");
	var ico2 = document.getElementById("ico_vol");
	
	if(tab==1){
		m0.style.display="inline";
		m1.style.display="none";
		m2.style.display="none";
		
		ico0.src = "images/m_hotel+vol.jpg";
		ico1.src = "images/m_hotel_off.jpg";
		ico2.src = "images/m_vol_off.jpg";
	}
	if(tab==0){
		m0.style.display="none";
		m1.style.display="inline";
		m2.style.display="none";
		
		ico0.src = "images/m_hotel+vol_off.jpg";
		ico1.src = "images/m_hotel.jpg";
		ico2.src = "images/m_vol_off.jpg";
	}
	if(tab==2){
		m0.style.display="none";
		m1.style.display="none";
		m2.style.display="inline";
		
		ico0.src = "images/m_hotel+vol_off.jpg";
		ico1.src = "images/m_hotel_off.jpg";
		ico2.src = "images/m_vol.jpg";
		
		m2.innerHTML = "";
		var iframe = document.createElement("iframe");
		if(tab==2){
			iframe.setAttribute("src", "includes/moteur_vols.html");
			var width = document.createAttribute('height');
			width.nodeValue = "320";
			iframe.setAttributeNode(width);
		}
		var width = document.createAttribute('width');
		width.nodeValue = "100%";
		iframe.setAttributeNode(width);
		
		var frameborder = document.createAttribute('frameborder');
		frameborder.nodeValue = "no";
		iframe.setAttributeNode(frameborder);
		width
		m2.appendChild(iframe);
	}
}

function afficher()
{
	if(document.getElementById("more2").style.display=="none"){
		document.getElementById("more2").style.display="inline";
		document.getElementById("more").src="images/moins.jpg";
	}
	else {
		document.getElementById("more2").style.display="none";
		document.getElementById("more").src="images/plus.jpg";
	}    
}
function afficherbis()
{
	if(document.getElementById("more2bis").style.display=="none"){
		document.getElementById("more2bis").style.display="inline";
		document.getElementById("morebis").src="images/moins.jpg";
	}
	else {
		document.getElementById("more2bis").style.display="none";
		document.getElementById("morebis").src="images/plus.jpg";
	}    
}
