function airportlookup() {
	$.get("/cfc/lookup.cfc", {"method":"lookup", "cityname": $("#cityname").val()},lookupFinish)
}
function lookupFinish(req){
	var results = $(req).find("airport").get();
	if(results.length <= 0)
		$("#airportlookupresults").text("No airports found for " + $("#cityname").val());
	else if(results.length == 1){
		var win = document.getElementById("airportlookup");
		$("#"+win.returnID).val($(results).attr("id"));
		win.deactivate();
	} else {
		var selElem = document.createElement("select");
		selElem.multiple = true;
		selElem.id = "airportlookupselect";
		$(req).find("airport").each(function(i){
			selElem.options[i] = new Option($(this).text(), $(this).attr("id"));
		});
		selElem.onchange = function(){
			var win = document.getElementById("airportlookup");
			$("#"+win.returnID).val(this.value);
			win.deactivate();
		}
		selElem.style.width= "282px";
		selElem.style.height= "200px";
		$("#airportlookupresults").empty().append(selElem);
	}
}
function airportactivate(id){
	var win = document.getElementById("airportlookup");
	$("#airportlookupresults").empty();
	win.returnID = id;
	win.activate({keyhandler: airportlookupkeyhandler});
}
function deact(){
	document.getElementById("airportlookup").deactivate();
}

function airportlookupkeyhandler(key){
	switch(key.toLowerCase()){
		case "enter":
			airportlookup();
			return false;
		case "esc":
			deact();
			return false;
	}
	return true;
}
