function formatItem(row) {
	return row[0];
}

function findValue(li) {
	if( li == null ) return;

	// 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;

	
}

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



var ac = $('#{{$fieldName}}').autocomplete("/{{$smarty.const.ADMIN_APP_DIR}}/autocomplete_backend.php", { delay:10,
			minChars:1,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem,
			onFindValue:findValue,
			formatItem:formatItem,
			autoFill:true
 });
 $('#{{$fieldName}}').parent().append('<img src="/{{$smarty.const.ADMIN_APP_DIR}}/images/arrow.gif" id="{{$fieldName}}_ac" value="find"/>');
 $('#{{$fieldName}}_ac').click(function(){
		ac[0].autocompleter.getResults();
 });
 $('#{{$fieldName}}_ac').css('cursor', 'pointer');