/**
 * Provides suggestions for schools.
 * @class
 * @scope public
 */
function SchoolSuggestions(type) {
	this.type = type;
    this.elementary = [
        //Print schools
		"Annistown Elementary","Austin","Bonaire","Briarlake Elementary","East Newton","Fairview","Flat Shoals ","Hightower","Hubbard","Hubbard Elementary","Jasper County Schools","Jasper Primary","Lake Joy","Lamar County","Livingston","Lorraine","Mansfield","McDonough","McDonough Elementary","MONROE ","Oak Hill","Palmer Stone","Porterdale","Putnam","Rocky Branch Elementary","Russell","Sharon","Shoal Creek","Sims","Social Circle Elementary","Timber Ridge","Unity Grove","Unknown","Youth"    ];
    this.middle = [
        //Print schools
		"Austin","Austin Road","Bonaire","CARVER","Clements","Conyers","Cousins","Edwards","Feagan Mill","Henderson Middle","Henry County","Henry Middle","Hubbard","Hubbard Middle","Huntington","Indian Creek","Jasper","Jasper County Schools","Lamar County","Loganville","Malcolm Bridge Middle School","Memorial","Ola","Putnam","Social Circle Middle","Union Grove","Unknown","Veterans Memorial","Youth"    ];
    this.high = [
        //Print schools
		"Alcovy","East Side","Eastside","Henry County","Henry High ","Heritage","Houston County","Jasper","Jasper County School","Lakeside High","Lamar County","Loganville","M Persons High ","Mary Persons","MONROE","Newton","North Oconee","North Oconee High School","Ola","Putnam","Reassigned (Unknown)","Rockdale ","Rockdale County","Salem ","Social Circle High School","Stockbridge","Union Grove","Unknown","Veterans","Vetrans","Warner Robins"    ];
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
SchoolSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    
    if (sTextboxValue.length > 0){
        //convert value in textbox to lowercase
        var sTextboxValueLC = sTextboxValue.toLowerCase();
        //search for matching schools
		if(this.type==1) {
			schools = this.elementary;
		} else if(this.type==2) {
			schools = this.middle;
		} else {
			schools = this.high;
		}
        for (var i=0; i < schools.length; i++) { 
            //convert state name to lowercase
            var sSchoolLC = schools[i].toLowerCase();
            //compare the lowercase versions for case-insensitive comparison
            if (sSchoolLC.indexOf(sTextboxValueLC) == 0) {
                //add a suggestion using what's already in the textbox to begin it                
                aSuggestions.push(sTextboxValue + schools[i].substring(sTextboxValue.length));
            } 
        }
    }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};
