// コメントの投稿
var CommentLog = Class.create();
CommentLog.prototype = {
	initialize: function(
		parent_tab,
		listbox_id,
		next_button_id,
		prev_button_id,
		num_of_list
	) {
		this.parent_tab = parent_tab;
		this.listboxObj = $(listbox_id);
		//this.next_buttonObj = $(next_button_id);
		//this.prev_buttonObj = $(prev_button_id);
		this.num_of_list = num_of_list;
	},
	// コメント履歴を表示する 
	// point は 開始位置
	open: function(point) {
	},
	// コメントを再取得する
	// point は 開始位置
	get: function(parent_id,point){
		this.point = point;
		var url = './ajax/getComment.php';
		var pars = '';
		pars += 'parent_id=' + parent_id;
		pars += '&point=' + point;
		pars += '&parent_tab=0';
		pars += '&num_of_list=' + this.num_of_list;
		var myAjax = new Ajax.Updater(
			{success: 'comment_list'}, 
			url, 
			{
				method: 'post', 
				parameters: pars, 
				onFailure: this.reportError,
				onComplete: this.postAdd,
				evalScripts: true
			});
	},
	postAdd: function(request){
	},
	reportError: function(request) {
		alert('ごめんなさい、書き込みできませんでした。2度やってだめなら今日は多分無理です。');
	},
	openWindow: function(evt){
		var child = Event.element(evt);
		if(child.id.indexOf('getComment') > -1){
			var object_name = child.id.split('.');
			this.parent_id = object_name[1];
			this.get(this.parent_id,0);
			this.listboxObj.style.left = Event.pointerX(evt) - 50  + 'px';
			this.listboxObj.style.top  = Event.pointerY(evt) - 10 + 'px';
			this.visibleB(this.listboxObj);
		}
	},
	closeWindow: function(){ 
		this.disable(this.listboxObj); 
	},
	next: function(){
		this.point += this.num_of_list;
		this.get(this.parent_id,this.point);
	},
	prev: function(){
		if(this.point > 0){ 
			this.point -= this.num_of_list;
			this.get(this.parent_id,this.point);
		}
	},
	disable: function(obj){ obj.style.display = 'none'; },
	visibleB: function(obj){ obj.style.display = 'block'; },
	visibleI: function(obj){ obj.style.display = 'inline'; }
};	

