/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function StateSuggestions(autosuggests /*Autosuggest words*/) {
	
	this.autosuggests = autosuggests;
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
	
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value.toLowerCase();
    
    if (sTextboxValue.length > 0){
		
        //search for matching states
        for (var i=0; i < this.autosuggests.length; i++) { 
            if (this.autosuggests[i].toLowerCase().indexOf(sTextboxValue) == 0) {
                aSuggestions.push(this.autosuggests[i]);
            } 
        }
    }
	
    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
	
};