
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function StateSuggestions1() {
    this.states = [
        "Atlanta", "Boston", "Chicago", "Detroit",
        "Dallas", "Los Angeles", "Miami",
        "Minneapolis", "New York", "San Francisco", "Washington",
        "Aberdeen", "Abilene", "Adak Island", "Akron Canton",
        "Akutan", "Alakanuk", "Alamogordo",
        "Alamosa", "Albany", "Albuquerque", "Aleknagik", "Alexandria", 
        "Allentown", "Alliance", "Alpena",
        "Altoona", "Amarillo", "Ambler", "Amook", "Anacortes",
        "Anchorage", "Aniak", "Anniston", "Anvik", "Appleton", 
        "Arcata", "Arctic Village", "Asheville", "Ashland",
        "Aspen", "Atlanta", "Atlanta, USA (ATL)", "Atmautluak", "Atqasuk", 
        "Augusta", "Austin", "Bakersfield", "Bangor", "Bar Harbour", "Barrow",
		"Barter Island", "Baton Rouge", "Battle Creek", "Beaumont", "Beaver", "Beckley"
    ];
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
StateSuggestions1.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    
    if (sTextboxValue.length > 0){
    
        //convert value in textbox to lowercase
        var sTextboxValueLC = sTextboxValue.toLowerCase();

        //search for matching states
        for (var i=0; i < this.states.length; i++) { 

            //convert state name to lowercase
            var sStateLC = this.states[i][1].toLowerCase();
           
            //compare the lowercase versions for case-insensitive comparison
            if (sStateLC.indexOf(sTextboxValueLC) == 0) {

                //add a suggestion using what's already in the textbox to begin it                
                aSuggestions.push(sTextboxValue + this.states[i][1].substring(sTextboxValue.length));
            } 
        }
    }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};
