
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function ComboSuggest(oCombobox, intMaxLength) {
    this.combobox = oCombobox;
    this.maxlength = intMaxLength;
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
 

 
ComboSuggest.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    
    if (sTextboxValue.length > 0 && sTextboxValue!="(Alle)") {    
        //search for matching states
        for (var i=0; i < this.combobox.options.length; i++) { 
            if (this.combobox.options[i].text.toUpperCase().indexOf(sTextboxValue.toUpperCase()) != -1) {
                aSuggestions.push(this.combobox.options[i].text);
                //if (aSuggestions.length == this.maxlength)
                //  break;
            } 
        }
    }
    
    //MHU 20070109 added
    if(sTextboxValue=="(Alle)" ||sTextboxValue.length == 0 )
    {
        for (var i=0; i < this.combobox.options.length; i++) { 
            //if (this.combobox.options[i].text.toUpperCase().indexOf(sTextboxValue.toUpperCase()) != -1) {
                aSuggestions.push(this.combobox.options[i].text);
                //if (aSuggestions.length == this.maxlength)
                //  break;
            //} 
        }
        
        
    }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};
