function ResortRefinedSearchForm_manageAnyActivityCheckBox(turnOn) {
	return PlanAVacation_manageAnyActivityCheckBox(turnOn);
}

function PlanAVacation_manageAnyActivityCheckBox(turnOn) {
	var anyActivity = document.getElementById("anyActivityFormCheckbox");
	
	if (anyActivity == null) {
		alert("PlanAVacation_manageAnyActivityCheckBox():  Could not locate form element with id \"anyActivityFormCheckbox\".");
	} else {
		if (turnOn == false) {
			// A more specific activity was selected so turn off any activity
			anyActivity.checked = false;
		} else {
			// Any Activity was selected so clear out all selection except that one
			var activities = anyActivity.form.elements["query.activities"];
			
			for (i = 0; i < activities.length; i++) {
				activities[i].checked = false;
			}
			
			anyActivity.checked = true;
		}
	}
}


function ResortRefinedSearchForm_selectDestinationFormRadioWithId(id) {
	return PlanAVacation_selectDestinationFormRadioWithId(id);
}

function PlanAVacation_selectDestinationFormRadioWithId(id) {
	var radio = document.getElementById(id);
	
	if (radio == null) {
		alert("PlanAVacation_selectDestinationFormRadioWithId():  Could not locate form element with id \"" + id + "\".");
	} else {
		radio.checked = true;
	}
}


function ResortRefinedSearchForm_doChildAges(index) {
	return PlanAVacation_doChildAges(index);
}

// perform child age dropdown show / hide
// supports any number of children
// <div> ids must be in the following format: div_child_[number]
function PlanAVacation_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 {
				// Before hiding div, reset select to age 0
				var ageSelect = document.getElementById("select_child_age_" + divNum);
				if (ageSelect != null) {
					ageSelect.selectedIndex = 0;
				}
				hide(divId);
			}
		}
	}
	
	// If they changed child travellers to 0 then reset the radios and hide lap div
	if (index == 0) {
		var div = document.getElementById("div_lap");
		var inputs = div.getElementsByTagName("input");

		for (i = 0; i < inputs.length; i++) {
			var input = inputs[i];
			if (input.type == "radio" && input.id.indexOf("radio_child_travel_method_") == 0) {
				input.checked = false;
			}
		}
		hide("div_lap");
	}
	
	// prevent scrollwheel bug
	window.focus();
}


function ResortRefinedSearchForm_doChildLap() {
	return PlanAVacation_doChildLap();
}

// perform lap question show / hide
// supports any number of children
// <select> ids must be in the following format: select_child_age_[number]
function PlanAVacation_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");
	}
	
	// If we got to this point, it's because we didn't show the div.  Had we
	// shown it, we would of done a return out of the function.
	// So remove all the checkbox on the div_lap
	var div = document.getElementById("div_lap");
	var inputs = div.getElementsByTagName("input");

	for (i = 0; i < inputs.length; i++) {
		var input = inputs[i];
		if (input.type == "radio" && input.id.indexOf("radio_child_travel_method_") == 0) {
			input.checked = false;
		}
	}
	
	// prevent scrollwheel bug
	window.focus();
}


function ResortRefinedSearchFormclearLengthOfStayOther() {
	return PlanAVacation_clearLengthOfStayOther();
}

function PlanAVacation_clearLengthOfStayOther() {
	var field = document.getElementById("lengthOfStayOther_Text");

	if (field != null) {
		field.value = "";
	} else {
		alert("PlanAVacation_clearLengthOfStayOther():  Could not locate the form field with id \"lengthOfStayOther_Text\"");
	}
}


function ResortRefinedSearchForm_selectLengthOfStayOtherRadio() {
	return PlanAVacation_selectLengthOfStayOtherRadio();
}

function PlanAVacation_selectLengthOfStayOtherRadio() {
	var field = document.getElementById("lengthOfStayOther_Radio");

	if (field != null) {
		field.checked = true;
	} else {
		alert("PlanAVacation_selectLengthOfStayOtherRadio():  Could not locate the form field with id \"lengthOfStayOther_Radio\"");
	}
}


function ResortRefinedSearchForm_focusOnLengthOfStayOther() {
	return PlanAVacation_focusOnLengthOfStayOther();
}

function PlanAVacation_focusOnLengthOfStayOther() {
	var field = document.getElementById("lengthOfStayOther_Text");

	if (field != null) {
		field.focus();
	} else {
		alert("PlanAVacation_focusOnLengthOfStayOther():  Could not locate the form field with id \"lengthOfStayOther_Text\"");
	}
}