
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function StateSuggestions() {
	/*
		NOT NEEDED HERE AS WE GET ALL OUR DATA FROM THE DATABASE!
	
    this.states = [
        "Alabama", "Alaska", "Arizona", "Arkansas",
        "California", "Colorado", "Connecticut",
        "Delaware", "Florida", "Georgia", "Hawaii",
        "Idaho", "Illinois", "Indiana", "Iowa",
        "Kansas", "Kentucky", "Louisiana",
        "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", 
        "Mississippi", "Missouri", "Montana",
        "Nebraska", "Nevada", "New Hampshire", "New Mexico", "New York",
        "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", 
        "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota",
        "Tennessee", "Texas", "Utah", "Vermont", "Virginia", 
        "Washington", "West Virginia", "Wisconsin", "Wyoming"  
    ];
    
  */
  
  
}

/**
 * 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){
    	
    	/* Added by T0oL */
      oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
		  AjaxRequest.get(
			  {
			    'url':'search.php?value='+sTextboxValue
			    ,'onSuccess':function(req){ 
			    	var suggestions = [];
			    	var response;
			    	response = req.responseText;
			    	
				    	if(response.length > 0)
				    	{
					    	suggestions = response.split("|");
					    	//provide suggestions to the control
		    				oAutoSuggestControl.autosuggest(suggestions, bTypeAhead);
				    	}
			    	}
			    ,'onError':function(req){  }
			  }
			);
			/* End of code added by T0oL */ 
			
    }

};