
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function LocationSuggestions() 
{
    this.foobar = 123;
    global_self = this;
}

var global_self;

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
LocationSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/) 
{
    global_self.oAutoSuggestControl = oAutoSuggestControl;

    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;

    var url = 'suggest.cgi?type=location&kw=' + sTextboxValue;
    http_request(LocationSuggestions.prototype.fillSuggestions, url, 0);
    
    //if (sTextboxValue.length > 0){
        // aSuggestions.push(this.states[i]);
    //}

    //provide suggestions to the control
    //oAutoSuggestControl.autosuggest(aSuggestions);
};

LocationSuggestions.prototype.fillSuggestions = function (json_data) 
{
    if (json_data != null)
        global_self.oAutoSuggestControl.autosuggest(eval(json_data));
}

