function displayrooms (select) {

	var html = ""
	for (var i=1; i<=select.options.selectedIndex; i++) {
		html += "<span class=\"clear\"></span>"
		html += "<br/>"
		switch(i) {
			case 1: var s = "st"; break;
			case 2: var s = "nd"; break;
			case 3: var s = "rd";	break;
			default: var s = "th";
		}
		html += "<label style=\"width: 140px;\">"+i+s+" Rooms</label>";
		//html += "<input type=\"text\" name=\"rooms"+i+"\" class=\"fl\"/>";
		
		html += "<select name=\"adultsNum"+i+"\" id=\"search-people\" class=\"fl\"> ADULTS";
										html+= "<option value=\"0\">Number of adults</option>";
										html+= "<option value=\"1\">1</option>";
										html+= "<option value=\"2\">2</option>";
										html+= "<option value=\"3\">3</option>";
										html+= "<option value=\"4\">4</option>";
										
									html+= "</select>";
									
			
			html += "<select name=\"childnum"+i+"\" id=\"search-people\" class=\"fl\" onChange=\"displayChildAges(this,"+i+");\"> Children";
										html+= "<option value=\"0\">Number of children</option>";
										html+= "<option value=\"1\">1</option>";
										html+= "<option value=\"2\">2</option>";
										html+= "<option value=\"3\">3</option>";
										
									html+= "</select>";
								
		html += "<span class=\"clear\"></span>";
	}
	document.getElementById("adultsFields").innerHTML = html;
	
}



function displayChildAges (select,a) {

	var html = ""
	for (var i=1; i<=select.options.selectedIndex; i++) {
		html += "<span class=\"clear\"></span>"
		html += "<br/>"
		switch(i) {
			case 1: var s = "st"; break;
			case 2: var s = "nd"; break;
			case 3: var s = "rd";	break;
			default: var s = "th";
		}
		html += "Room "+a+"<label style=\"width: 140px;\">"+i+s+" child's age</label>";
		html += "<input type=\"text\" name=\"childAge"+a+i+"\" class=\"fl\"/>";
		html += "<span class=\"clear\"></span>";
	}
	
	document.getElementById("childAgesFields"+a+"").innerHTML = html;
}





function selectFilter(selCountry, idSelAirport, php) {
	var selAirport = document.getElementById(idSelAirport);
	var params = "country="+selCountry.options[selCountry.selectedIndex].value;
	if (selAirport) {
		var xhr_object = null;
		if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else {
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return;
		}
		xhr_object.open("POST", php, true);
		xhr_object.onreadystatechange = function() {
			if (xhr_object.readyState == 4) {
				eval(xhr_object.responseText);
			}
		}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		xhr_object.send(params);
	}
}

function show(id, link, word) {
	if (document.getElementById(id)) {
		if (document.getElementById(id).style.display == "none") {
			document.getElementById(id).style.display = "block";
			link.innerHTML = "<font size=+1><img src='../images/fleche.gif' width='15'> "+word+"</font>";
		} else {
			document.getElementById(id).style.display = "none";
			link.innerHTML = "<font size=+1><img src='../images/fleche.gif' width='15'> "+word+"</font>";
		}
	}
}

function bookItAction(bbId3,roomId, hotelId, hotelRoomTypeId, productId, price, occupId, dblBed) {
//alert(bbId3);

	if (document.getElementById("roomId")
		&& document.getElementById("hotelId")
		&& document.getElementById("hotelRoomTypeId")
		&& document.getElementById("productId")
		&& document.getElementById("price")
		&& document.getElementById("dblBed")
		&& document.getElementById("occupId")) {
		document.getElementById("roomId").value = roomId;
		document.getElementById("hotelId").value = hotelId;
		document.getElementById("hotelRoomTypeId").value = hotelRoomTypeId;
		document.getElementById("productId").value = productId;
		document.getElementById("price").value = price;
		document.getElementById("occupId").value = occupId;
		document.getElementById("dblBed").value = dblBed;
		document.getElementById("bbId3").value = bbId3;
		return true;
	} else {
		alert("champs introuvables");
		return false;
	}
}
