$().ready(function()
{
    function findValueCallback(event, data, formatted)
    {
        $("<li>").html(!data ? "No match!" : "Selected: " + formatted).appendTo("#result");
    }

    function formatItem(row)
    {
        return row[0] + " (<strong>id: " + row[1] + "</strong>)";
    }
    function formatResult(row)
    {
        return row[0].replace(/(<.+?>)/gi, '');
    }


    $("#tags_old").autocomplete(["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "pearl"], {
        width: 320,
        max: 4,
        highlight: false,
        multiple: true,
        multipleSeparator: " ",
        scroll: true,
        scrollHeight: 300
    });

//    $("#tags").autocomplete('tagsEngine.php', {
//        width: 300,
//        multiple: true,
//        matchContains: true,
//        multipleSeparator: " ",
//        scroll: true,
//        scrollHeight: 300,
//        extraParams: {
//            hidPluginUid: "plugin_" + 43212
//        },
//        //formatItem: formatItem,
//        formatResult: formatResult
//    });

});

function changeOptions()
{
    var max = parseInt(window.prompt('Please type number of items to display:', jQuery.Autocompleter.defaults.max));
    if (max > 0)
    {
        $("#suggest1").setOptions({
            max: max
        });
    }
}

function changeScrollHeight()
{
    var h = parseInt(window.prompt('Please type new scroll height (number in pixels):', jQuery.Autocompleter.defaults.scrollHeight));
    if (h > 0)
    {
        $("#suggest1").setOptions({
            scrollHeight: h
        });
    }
}

function changeToMonths()
{
    $("#suggest1")
    // clear existing data
		.val("")
    // change the local data to months
		.setOptions({ data: months })
    // get the label tag
		.prev()
    // update the label tag
		.text("Month (local):");
}
