function findValue(li) {
    if( li == null ) return alert("No match!");
    window.location = li.extra[0];
}

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

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

function lookupAjax(){
    var oSuggest = $("#query")[0].autocompleter;

    oSuggest.findValue();

    return false;
}

$(document).ready(function() {
    $("#query").autocomplete(
        "/ajax/firme.php",
        {
            delay:10,
            minChars:3,
            matchSubset:1,
            matchContains:1,
            cacheLength:10,
            onItemSelect:selectItem,
            onFindValue:findValue,
            formatItem:formatItem,
            autoFill:true
        }
    );
});
