﻿$(function() {
    $(".city-ac").autocomplete(cities, {
        minChars: 0,
        width: 220,
        scrollHeight: 300,
	    scroll: true,
	    matchContains: true,
        autoFill: false,

        formatItem: formatCityItem,
        formatMatch: formatCityMatch,
        formatResult: formatCityResult
    }).result(function(event, item) {
        $(this).attr("title", item.Name);
    });   
});

function formatCityItem(row, i, max) {
    return "<span class='name'>" + row.Name + "</span><span class='code'>(" + row.Code + ")</span><span class='en'>" + row.NameEn + "</span>";
}

function formatCityMatch(row, i, max) {
    return row.Name + " " + row.NameEn + " " + row.Code;
    //return row.NameEn + row.Code;
}

function formatCityResult(row) {
    return row.Name;
}


