var SearchBoxLinker = Class.create();
SearchBoxLinker.prototype =
{
    initialize : function()
    {
        this.sbox = null;
        this.ajaxHandler = null;
        this.callback = null;
    },

    //sets the callback, invokes ajax
    getData : function(callback)
    {
        this.callback = callback;
        this.ajaxHandler.invokeAjax();
    },

    //this is called by the ajax handler before send the ajax request
    jsContextProvider : function()
    {
        return [document.getElementById('q').value];
    },

    handleData : function(response)
    {
        var json = response.responseText.evalJSON();
        if(json.data)
        {
            this.sbox.data = json.data;
        }
        else
        {
            this.sbox.data = new Array();
        }
        this.callback();
    },

    doSubmit : function()
    {
        document.form.submit();
    }
}

var sboxLink = new SearchBoxLinker();

