function selected(li)
{
    WikiViz.loadNode(li.selectValue);
}

function setupCompletion()
{
    $("#form")[0].onsubmit = function()
    {
        return false;
    }

    var options = {
        minChars: 3,
        matchSubset: 0,
        matchContains: 1,
        cacheLength: 10,
        onItemSelect: selected,
        selectOnly: 1
    }

    $("#topic").autocomplete("/api.fcgi", options)
    $("#topic")[0].onclick = function()
    {
        this.style.textAlign = "left";
        this.value = "";
    }
    $("#topic")[0].onblur = function()
    {
        this.value = "";
    }
}

$(document).ready(setupCompletion);

