Event.observe(window, 'load', function() {
	var markerSearchSuggestion = new MarkerSearchSuggestion(
									'markerSearchFormName', 
									'markerSearchActionForm', 
									'markerSearchFormType', 
									'markerSearchFormChrId', 
									'markerSearchKeywordSuggestion', 
									'h3', 
									'Marker Search Keyword Suggestion Result', 
									'detail_view', 
									'../images/suggestionLoading.gif', 
									'../images/suggestionNext.gif', 
									'../images/suggestionPrev.gif', 
									'markerSearchKeywordSuggestion', 
									'post');
});

var MarkerSearchSuggestion = Class.create();
Object.extend(MarkerSearchSuggestion.prototype, Suggestion.prototype);
Object.extend(MarkerSearchSuggestion.prototype, {
	// コンストラクタ (オーバーライド)
	initialize: function(inputId, formId, markerSearchFormType, markerSearchFormChrId, suggestionId, suggestionTitleTag, suggestionTitle, suggestionInsertionId, suggestionLoadingImg, suggestionNextImg, suggestionPreviousImg, actionName, requestMethod) {
		// ユーザー設定項目
		// キーワード推測を行うinputタグのid
		this.inputId = inputId;
		// キーワード推測を行うformタグのid
		this.formId = formId;
		// マーカータイプのselectタグのid
		this.markerSearchFormType = markerSearchFormType;
		// 染色体番号のinputタグのid
		this.markerSearchFormChrId = markerSearchFormChrId;
		// 候補キーワードリストの外側を覆うid
		this.suggestionId = suggestionId;
		// 候補キーワードリストのタイトルのタグ (pタグは不可)
		this.suggestionTitleTag = suggestionTitleTag;
		// 候補キーワードリストのタイトル
		this.suggestionTitle = suggestionTitle;
		// 候補キーワードリストをDOMツリーに挿入する時のid
		this.suggestionInsertionId = suggestionInsertionId;
		// 候補キーワードリストのnow loading...画像ファイルのパス
		this.suggestionLoadingImg = suggestionLoadingImg;
		// 候補キーワードリストのnext...画像ファイルのパス
		this.suggestionNextImg = suggestionNextImg;
		// 候補キーワードリストのprevious...画像ファイルのパス
		this.suggestionPreviousImg = suggestionPreviousImg;
		// AJAXアクション名
		this.actionName = actionName;
		// リクエストを送信する方法
		this.requestMethod = requestMethod;
		
		this.processInitialize();
	},
	
	// パラメーターを作成します。 (オーバーライド)
	createParameter: function(inputString) {
		var markerSearchFormType = $F(this.markerSearchFormType);
		var markerSearchFormChrId = $F(this.markerSearchFormChrId);
	
		var param = new String;
		param += "action=" + this.actionName;
		param += "&name=" + encodeURIComponent(inputString);
		param += "&type=" + markerSearchFormType;
		param += "&chromosomeId=" + markerSearchFormChrId;
		
		return param;
	},
	
	// 候補キーワードリストの位置をブラウザごとに微調整を行います。 (オーバーライド)
	adjustSuggestion: function(left, top, width) {
		if (this.client.isWinOS && this.client.isIE) {
			left -= 1; top -= 1; width -= 0;
			
		} else if (this.client.isWinOS && this.client.isFirefox) {
			left += 0; top -= 1; width -= 3;
			
		} else if (this.client.isWinOS && this.client.isSafari) {
			left += 1; top += 1; width -= 2;
			
		} else if (this.client.isWinOS && this.client.isOpera) {
			left += 0; top -= 1; width -= 3;
			
		}  else if (this.client.isMacOS && this.client.isFirefox) {
			left += 0; top += 0; width -= 2;
			
		} else if (this.client.isMacOS && this.client.isSafari) {
			left += 1; top += 2; width -= 2;
			
		} else if (this.client.isLinuxOS && this.client.isFirefox) {
			left += 0; top -= 1; width -= 2;
		}
		
		return '{left: ' + left + ', top: ' + top + ', width: '+ width +'}';
	}
});