
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function N2NSuggestions(sCode) {
	this.states = sCode;
        var aSuggestions = [];
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
N2NSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    
    if (sTextboxValue.length > 0){
    
        //convert value in textbox to lowercase
        var sTextboxValueLC = sTextboxValue.toLowerCase();
	var iCount = 0;

        //search for matching states
//        for (var i=0; i < this.states.length; i++) { 
        for (var i=0; i < this.states.length; i++) { 

            //convert state name to lowercase
            var sStateLC = this.states[i].toLowerCase();
           
            //compare the lowercase versions for case-insensitive comparison
            if (sStateLC.indexOf(sTextboxValueLC) == 0 /*&& iCount < this.ilimit*/) {

                //add a suggestion using what's already in the textbox to begin it                
                aSuggestions.push(this.states[i]);
//                aSuggestions.push(sTextboxValue + this.states[i].substring(sTextboxValue.length));
		//iCount++;
            } 
        }
    }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};
