var list_line = [];
var list_school  = [];

var AjaxSuggest = Suggest;

AjaxSuggest.Local.prototype._search = function(text){

	var element = (document.activeElement || window.getSelection().focusNode);

	if(element.id == 'station'){
		this.candidateList = suggest.getLines(text);
	}else{
		this.candidateList = suggest.getSchools(text);

	}

	var resultList = [];
		var temp;
		this.suggestIndexList = [];
		
		for (var i = 0, length = this.candidateList.length; i < length; i++) {
			if ((temp = this.isMatch(this.candidateList[i], text)) != null) {
				resultList.push(temp);
				this.suggestIndexList.push(i);
				
				if (this.dispMax != 0 && resultList.length >= this.dispMax) 
					break;
			}
		}
		return resultList;
}

// wondowのonloadイベントでSuggestを生成
var start = function(){
	if(document.getElementById('station')){
		new AjaxSuggest.Local("station", "station_suggest_rs", list_line);
	}
	if(document.getElementById('school')){
		new AjaxSuggest.Local("school", "school_suggest_rs", list_school);
	}
};
window.addEventListener ?
	window.addEventListener('load', start, false) :
	window.attachEvent('onload', start);