
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
String.prototype.capitalize = function(){ //v1.0
    return this.replace(/\w+/g, function(a){
        return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
    });
};

function StateSuggestions() {
      
    
}

/**
 * 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*/,usp) {
    
    var sTextboxValue = oAutoSuggestControl.textbox.value;
 var aSuggestions = [];
  var aSuggestionsMsg = [];
var aSuggestionsID = [];
   if (sTextboxValue.length > 2){
var response=iknow.getAutosuggestText(oAutoSuggestControl.textbox.value);    
    var ds=response.value;
    

     for(var i=0; i<ds.Tables[0].Rows.length; i++)
      {  
   
      aSuggestions.push(ds.Tables[0].Rows[i].searchText);
      
//     aSuggestions.push(ds.Tables[0].Rows[i].Username+ ','+ds.Tables[0].Rows[i].Country);
//      // aSuggestions.push(ds.Tables[0].Rows[i].UserID);
//        aSuggestionsMsg.push(ds.Tables[0].Rows[i].Message);
//        aSuggestionsID.push(ds.Tables[0].Rows[i].ID);//alert(aSuggestionsID[i]);
      }
       
       }


      
    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead,aSuggestionsID,aSuggestionsMsg);
    
};