//////////////////////////////////////////////////////////////
// this function updates the destination drop down with the
// list of airports that are destinations for the selected origin
//
// NOTE: because of different behaviour in different browsers
// it is necessary to use the sessDest var if it is not ""
// can talk to warrecl about this if you are curious.
function updateDestinations(origBox, destBox, fromOnload, sessDest) {

	// get destination value
	var destIndex = 0;
	var destValue = "";
	destIndex += eval(destBox.selectedIndex);
	if (destIndex == -1){
		destIndex = 0;
	} else{
		destValue = destBox.options[destIndex].value;
	}
	// sessDest overrides destValue if it is available
	if (sessDest != ""){
		destValue = sessDest;
	}

	var origIndex = eval(origBox.selectedIndex);

	if (origIndex!=-1){
		var orig = origBox.options[origBox.selectedIndex].value;

		if ((orig != "null") && (orig != "")) {
			orig = eval(orig);
			destBox.innerHTML = "";
			destBox.length = 0;
			for (var i = 0; i < orig.length - 1; i++) {
				var oOption = document.createElement("OPTION");
				oOption.innerHTML = orig[i].meaning;
				oOption.value = orig[i].code;
				oOption.title = orig[i].meaning;
				// set selected element in drop down
				if ((destValue != "") && (orig[i].code == destValue)){
					oOption.selected = true;
				}
				destBox.appendChild(oOption);
			}

		} else {
			destBox.innerHTML = "";
			var oOption = document.createElement("OPTION");
			oOption.innerHTML = "--- none ---";
			oOption.value = "null";
			destBox.appendChild(oOption);
		}
	}
}
