
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function StateSuggestions() {
    this.states = [
        "Albuquerque","Anchorage","Asheville","Atlanta","Austin","Bakersfield","Baltimore","Birmingham","Boise","Boston","Brownsville","Buffalo","Calgary",
		"Charlotte","Chattanooga","Chicago-Evanston","Chico-Redding","Cincinnati","Cleveland","Columbus","Dallas","Denver","Detroit","Edmonton","Eureka","Flint",
		"Fort-Myers","Fresno","Grand-Rapids","Greenville","Harrisburg","Hartford","Honolulu","Houston","Indianapolis","Jacksonville","Kansas-City","Knoxville","Las-Vegas",
		"Lexington","Lincoln","Los-Angeles","Louisville","Macon","Manchester","Memphis","Miami","Milwaukee","Minneapolis","Montreal","Nashville","New-Haven","New-Orleans",
		"New-York-City","Norfolk","Oklahoma-city","Omaha","Orange-County","Orlando","Ottawa","Philadelphia","Phoenix","Pittsburgh","Portland","Portland-ME","Providence","Quebec-City",
		"Raleigh-Durham","Redding","Richmond","Rochester","Sacramento","Salinas-Monterey","Salt-Lake-City","San Francisco","San Jose","San-Antonio","San-Bernardino","San-Diego","Santa-Barbara",
		"Santa-Fe","Santa-Rosa","Seattle","Spokane","St-Louis","Stockton-Modesto","Tacoma","Tahoe","Tampa","Toledo","Toronto","Tucson","Vancouver","Vancouver-CAN","Washington-DC","West-Palm-Beach",
		"Winnipeg"];
}

/**
 * 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;
    
    if (sTextboxValue.length > 0){
    
        //search for matching states
        for (var i=0; i < this.states.length; i++) { 
            if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
                aSuggestions.push(this.states[i]);
            } 
        }
    }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};
