
function Resort(airID, resID, resName, resIsDefault)
{
	this.AirportID = airID;
	this.ResortID = resID;
	this.ResortName = resName;
	this.ResortIsDefault = resIsDefault;
}

function loadResorts()
{
        var objAirportList = document.getElementById('CMDropDownList_ArrivalAirport');
        var objResortList = document.getElementById('DropDownList_Resort');

        var parentID = objAirportList.options[objAirportList.selectedIndex].value;
        var parentName = objAirportList.options[objAirportList.selectedIndex].text;

        // Remove all resorts from the dropdown box
        objResortList.length = 0;

        // Remove the contents of the span tag used to display the name of the selected resort
        $('#uniform-DropDownList_Resort span').html('');

	if (parentID.substring(0, 1) == 'A')
	{
		var airportResorts = new Array();
		var resortSelected = false;

		// An airport has been selected
		for (var i = 0; i < resorts.length; i++)
		{
			// If the selected airport has resorts, add these resorts to the resorts dropdown
			if (parentID.substring(1) == resorts[i].AirportID)
			{
				airportResorts[airportResorts.length] = new Option(resorts[i].ResortName, resorts[i].ResortID, false, resorts[i].ResortIsDefault);

				// Remember if a default resort has been selected
				if (resorts[i].ResortIsDefault)
					resortSelected = true;
			}
		}

		if (airportResorts.length > 0)
		{
			// If there is more than one resort, and no resort has been selected, add a "please select" option to the list
			if (airportResorts.length > 1 && ! resortSelected)
				objResortList.options[objResortList.length] = new Option("Please select...", "");
			
			// Output each resort as a dropdown option
			for (var i = 0; i < airportResorts.length; i++)
			{
				objResortList.options[objResortList.length] = airportResorts[i];
			}

			// If no resort has been selected by default, select the first record in the list
			if (objResortList.selectedIndex < 0)
				objResortList.selectedIndex = 0;

			// Display the name of the selected resort in the span tag
			$('#uniform-DropDownList_Resort span').html(objResortList.options[objResortList.selectedIndex].text);
		}
	}
	else if (parentID.substring(0, 1) == 'R')
        {
		// A resort (top destination) has been selected, so add the resort to the resorts dropdown
		objResortList.options[objResortList.length] = new Option(parentName, parentID.substring(1));

		// Select the resort, and display its name in the span tag
		objResortList.selectedIndex = 0;
		$('#uniform-DropDownList_Resort span').html(objResortList.options[objResortList.selectedIndex].text);
	}
}

