
function findValue(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;
	document.getElementsByName("OrgAirportC")[0].value = sValue;
}


function findValue2(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;
	document.getElementsByName("DstAirportC")[0].value = sValue;
}

function selectItem(li) {
	findValue(li);
}


function selectItem2(li) {
	findValue2(li);
}

function formatItem(row) {
	return "<div class=auto_text>" + row[0] + " [" + row[1] + "] " + row[2] + "</div><div class=auto_img><img src=" + row[3] + " height=11></div>";
}

function lookupAjax(){
	var oSuggest = $("#CityAjax")[0].autocompleter;
	oSuggest.findValue();
	return false;
}

$(document).ready(function() {
	$("#OrgAirport").autocomplete(
		"/Autocomplete",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem,
			onFindValue:findValue,
			formatItem:formatItem,
			autoFill:true,
			width: 380,
			maxItemsToShow: 15

		}
	);
	
		$("#DstAirport").autocomplete(
		"/Autocomplete",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem2,
			onFindValue:findValue2,
			formatItem:formatItem,
			autoFill:true,
			width: 380,
			maxItemsToShow: 15
		}
	);
	
	
});