
/* Flight Search ---------------------------------------------------------------------------------------- */

// perform child age dropdown show / hide
// supports any number of children
// <div> ids must be in the following format: div_child_[number]
function doChildAges(index) {
	// get all divs on the page
	divs = document.getElementsByTagName("div");
	for (i = 0; i < divs.length; i++) {
		div = divs[i];
		if(!div) continue;
		
		var divId = String(div.id)
		// if div starts with "div_child_"
		if (divId.indexOf("div_child_") == 0) {
			// get the number of the div
			var divNum = parseInt(divId.substring(10, divId.length));
			if (divNum <= index) {
				show(divId);
			} else {
				hide(divId);
			}
		}
	}
	
	//if child number is 0, hide the "div_lap"
	if(index==0)
	 hide("div_lap");
	// prevent scrollwheel bug
	window.focus();
}

// perform lap question show / hide
// supports any number of children
// <select> ids must be in the following format: select_child_age_[number]
function doChildLap() {
	// get all divs on the page
	selects = document.getElementsByTagName("select");
	for (i = 0; i < selects.length; i++) {
		select = selects[i];
		if(!select) continue;
		
		var selectId = String(select.id)
		// if select starts with "select_child_age_"
		if (selectId.indexOf("select_child_age_") == 0) {
			// if a "<2" option is selected, show lap question
			if (select.selectedIndex == 1) {
				show("div_lap");
				// prevent scrollwheel bug
				window.focus();
				return;
			}
		}
		hide("div_lap");
	}
	// prevent scrollwheel bug
	window.focus();
}

//make round trip and one-way search fields blank when multicity is clicked
function blankNonMultiCity(){
	document.airSearchForm.from[0].value='';
	document.airSearchForm.to[0].value='';
	
}

//make multi-city search fields blank when round trip or one-way is clicked
function blankMultiCity(){
	for(var i=1; i<document.airSearchForm.from.length; i++){
		document.airSearchForm.from[i].value='';
		document.airSearchForm.to[i].value='';
	}
}