
/**
 * Provides suggestions for Onet Titles from onesoc data and search titles.
 * @class
 * @scope public
 */
function TitleSuggestions(strArray) {


fields = strArray.split('^');


this.titles = fields;


}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
TitleSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    
   
	//var str = new String(sTextboxValue); 

   if (sTextboxValue.length > 0){
    
   var sTextBoxValueLC = sTextboxValue.toLowerCase();
  
   //search for matching titles
        for (var i=0; i < this.titles.length; i++) { 
		var suggestionLC = this.titles[i].toLowerCase();


if (suggestionLC.indexOf(sTextBoxValueLC) >= 0) {
           
			if (suggestionLC.indexOf(sTextBoxValueLC)==0) {
                aSuggestions.push(this.titles[i]);
               }
     } 
        }
   }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};



