/*
 良く使う関数
*/

/* for Older Safari */
if (!Object.hasOwnProperty) {
    Object.prototype.hasOwnProperty = function(it) {
        return (this[it] && !this.constructor.prototype[it]);
    }
}

var GLOBAL = this;
/*
function $(el){
	return typeof el == 'string' ? document.getElementById(el) : el;
}
*/
var _ = {};
$N = function (name, attr, childs) {
	var ret = document.createElement(name);
	for (k in attr) {
		if (!attr.hasOwnProperty(k)) continue;
		v = attr[k];
		(k == "class") ? (ret.className = v) :
		(k == "style") ? setStyle(ret,v) : ret.setAttribute(k, v);
	}
	var t = typeof clilds;
	(isString(childs))? ret.appendChild(document.createTextNode(childs)) :
	(isArray(childs)) ? foreach(childs,function(child){
		isString(child)
			? ret.appendChild(document.createTextNode(child))
			: ret.appendChild(child);
		})
	: null;
	return ret;
};
function $DF(){
	var df = document.createDocumentFragment();
	foreach(arguments,function(f){ df.appendChild(f) });
	return df;
}

function True(){return true}
function False(){return false}


Function.prototype.later = function(ms){
    var self = this;
    return function(){
        var args = arguments;
        var thisObject = this;
        var res = {
            complete: false,
            cancel: function(){clearTimeout(PID);},
            notify: function(){clearTimeout(PID);later_func()}
        };
        var later_func = function(){
            self.apply(thisObject,args);
            res.complete = true;
        };
        var PID = setTimeout(later_func,ms);
        return res;
    };
};


/* generic */
if(!Array.concat){
	(function(){
		var methods = "concat slice shift push unshift pop sort reverse".split(" ");
		foreach(methods,function(mn){
			Array[mn] = function(){
				var args = Array.from(arguments);
				var self = args.shift();
				return Array.prototype[mn].apply(self,args);
			}
		})
	})();
}

function keys(hash){
	var tmp = [];
	for(var key in hash){
		tmp.push(key)
	}
	return tmp;
}
function each(obj,callback){
	for(var i in obj){
		callback(obj[i],i)
	}
}
function foreach(array,callback){
	var len = array.length;
	for(var i=0;i<len;i++){
		callback(array[i],i,array)
	}
}
/* Perlのjoin、中の配列も含めて同じルールでjoinする  */
function join(){
	var args = Array.from(arguments);
	var sep = args.shift();
	var to_s = Array.prototype.toString;
	Array.prototype.toString = function(){return this.join(sep)}
	var res = args.join(sep);
	Array.prototype.toString = to_s;
	return res;
}

/*  */

function Arg(n){
	return function(){ return arguments[n] }
}
function This(){
	return function(){ return this }
}
// // 関数の結果に対してsend
// Function.prototype.send = function(method,args){
// 	var self = this;
// 	return function(){
// 		return send(self.apply(this,arguments),method,args)
// 	}
// };
// function send(self,method,args){
// 	if(isFunction(self[method]))
// 		return self[method].apply(self,args);
// 	else if(isFunction(self.method_missing))
// 		return self.method_missing(method,args)
// 	else
// 		return null
// }
// methodに別名を付ける
function alias(method){
	return function(){
		return this[method].apply(this,arguments)
	}
}

/*
 transform functions
*/
function sender(method){
	var args = Array.slice(arguments,1);
	return function(self){
		var ex_args = Array.from(arguments);
		return send(self,method,args.concat(ex_args))
	}
}
// thisに対してmethodを呼び出す関数を生成する
// methodは文字列もしくは関数
/*
 invoker(arg(1),)
*/
// function invoker(method){
// 	var args = Array.slice(arguments,1);
// 	if(isFunction(method)){
// 		return function(){
// 			var ex_args = Array.from(arguments);
// 			return method.apply(this,args.concat(ex_args))
// 		}
// 	} else {
// 		return function(){
// 			var ex_args = Array.from(arguments);
// 			return send(this,method,args.concat(ex_args))
// 		}
// 	}
// }
/*
 push : function(item){ return this.list.push(item) }
 -> push : delegator("list","push");
*/
function delegator(key,method){
	return function(){
		var self = this[key];
		return self[method].apply(self,arguments);
	}
}

function getter(attr){
	return function(self){return self[attr]}
}


/*
 detect
*/
function isString(obj){
	return (typeof obj == "string" || obj instanceof String) ? true : false
}
function isNumber(obj){
	return (typeof obj == "number" || obj instanceof Number) ? true : false;
}
function isElement(obj){
	return obj.nodeType ? true : false;
}
function isFunction(obj){
	return typeof obj == "function";
}
function isArray(obj){
	return obj instanceof Array;
}
function isRegExp(obj){
	return obj instanceof RegExp
}


function loadRaw(url){
	var req = new XMLHttpRequest;
	var res;
	req.open("GET",url,false);
	req.onload = function(){
		res = req.responseText;
	};
	req.send(null);
	return res;
}
function loadJson(url,callback){
	if(dev){
		if(!dummy[url]){return}
		var json = dummy[url].isString ? eval("("+dummy[url]+")") : dummy[url];
		callback(json);
		return;
	}
	var req = new XMLHttpRequest;
	req.open("GET",url,true);
	req.onload = function(){
		eval("var json ="+req.responseText);
		callback(json)
	};
	req.send(null)
}

/*
 className
*/
function hasClass(element,classname){
	element = $(element);
	var cl = element.className;
	var cls = cl.split(/\s+/);
	return cls.indexOf(classname) != -1;
}
function addClass(element,classname){
	element = $(element);
	var cl = element.className;
	if(!contain(cl,classname)){
		element.className += " " + classname;
	}
}
function removeClass(element,classname){
	element = $(element);
	var cl = element.className;
	var cls = cl.split(/\s+/);
	element.className = cls.remove(classname).join(" ");
}
function switchClass(element, classname){
	element = $(element);
	var cl = element.className;
	var tmp = classname.split("-");
	var ns = tmp[0];
	var cls = cl.split(/\s+/);
	var buf = [];
	cls.forEach(function(v){
		if(v.indexOf(ns+"-") != 0) buf.push(v)}
	);
	buf.push(classname);
	element.className = buf.join(" ");
}
function toggleClass(element, classname){
	element = $(element);
	hasClass(element, classname) ?
		removeClass(element, classname):
		addClass(element, classname);
}
/* 文字列が含まれているかの判別 */
function contain(self,other){
	if(isString(self) && isString(other)){
		return self.indexOf(other) != -1
	}
	if(isRegExp(other)){
		return other.test(self)
	}
}



/* DateTime */
function DateTime(time){
	this._date = time ? new Date(time) : new Date;
	this._update();
	this.toString = function(){ return [this.ymd(),this.hms()].join(" ")}
	this.valueOf  = function(){ return this._date - 0 };
}
DateTime.now = function(){
	return new DateTime;
};
DateTime.prototype = {
	_update : function(){
		var dt = this._date;
		this.year  = dt.getFullYear();
		this.month = this.mon  = dt.getMonth() + 1;
		this.day   = this.mday = this.day_of_month = dt.getDate();
		this.hour  = dt.getHours();
		this.minute = this.min = dt.getMinutes();
		this.second = this.sec = dt.getSeconds();
	},
	ymd : function(sep){
		sep = arguments.length ? sep : "/";
		return [this.year,this.month,this.day].invoke("zerofill",2).join(sep)
	},
	hms : function(sep){
		sep = arguments.length ? sep : ":";
		return [this.hour,this.minute,this.second].invoke("zerofill",2).join(sep)
	}
};


/* Math */
Math.rand = function(num){return Math.random() * num};



function inspect(obj){
	return keys(obj).map(function(key){
		return key +" = "+obj[key] + "\n";
	})
}

/* JSON */
var JSON = {};
JSON.parse = function(str){
	try{
		var res = eval("(" + str + ")");
	} catch(e){
		// alert(inspect(e))
		return null;
	}
	return res;
}

// Array.toJSON = function(array){
// 	var i=0,len=array.length,json=[];
// 	for(;i<len;i++)
// 		json[i] = (array[i] != null) ? Object.toJSON(array[i]) : "null";
// 	return "[" + json.join(",") + "]";
// }
// Array.prototype.toJSON = function(){
// 	return Array.toJSON(this);
// }
// String.toJSON = function(string){
// 	return '"' +
// 		string.replace(/(\\|\")/g,"\\$1")
// 		.replace(/\n|\r|\t/g,function(){
// 			var a = arguments[0];
// 			return  (a == '\n') ? '\\n':
// 					(a == '\r') ? '\\r':
// 					(a == '\t') ? '\\t': ""
// 		}) + '"'
// }
// String.prototype.toJSON = function(){
// 	return String.toJSON(this)
// }
// Number.toJSON = function(number){
// 	return isFinite(number) ? String(number) : 'null'
// }
// Number.prototype.toJSON = function(){
// 	return Number.toJSON(this)
// }
// Boolean.prototype.toJSON = function(){return this}
// Function.prototype.toJSON = function(){return this}
// RegExp.prototype.toJSON = function(){return this}
// 
// // strict but slow
// String.prototype.toJSON = function(){
// 	var tmp = this.split("");
// 	for(var i=0;i<tmp.length;i++){
// 		var c = tmp[i];
// 		(c >= ' ') ?
// 			(c == '\\') ? (tmp[i] = '\\\\'):
// 			(c == '"')  ? (tmp[i] = '\\"' ): 0 :
// 		(tmp[i] = 
// 			(c == '\n') ? '\\n' :
// 			(c == '\r') ? '\\r' :
// 			(c == '\t') ? '\\t' :
// 			(c == '\b') ? '\\b' :
// 			(c == '\f') ? '\\f' :
// 			(c = c.charCodeAt(),('\\u00' + ((c>15)?1:0)+(c%16)))
// 		)
// 	}
// 	return '"' + tmp.join("") + '"';
// }
// Object.toJSON = function(obj){
// 	var json = [];
// 	if(typeof obj == 'undefined') return "null";
// 	if(obj == null) return "null";
// 	if(typeof obj.toJSON == 'function'){
// 		return obj.toJSON();
// 	}
// 	for(var i in obj){
// 		if(!obj.hasOwnProperty(i)) continue;
// 		if(typeof obj[i] == "function") continue;
// 		json.push(
// 			i.toJSON()+":"+((obj[i] != null)? Object.toJSON(obj[i]) : "null")
// 		)
// 	}
// 	return "{" + json.join(",") + "}";
// }

Object.toQuery = function(self){
	var buf = [];
	for(var key in self){
		var value = self[key];
		if(isFunction(value)) continue;
		buf.push(
			encodeURIComponent(key)+"="+
			encodeURIComponent(value)
		)
	}
	return buf.join("&");
}


/* CSS */
function parseCSS(text){
	var pairs = text.split(";");
	var res = {};
	pairs.forEach(function(pair){
		var tmp = pair.split(":");
		res[tmp[0].strip()] = tmp[1];
	});
	return res;
}
// cssセット、透明度、floatの互換性を取る
function setStyle(element,style){
	element = $(element);
	var es = element.style;
	if(isString(style)){
		es.cssText ? (es.cssText = style) : setStyle(element,parseCSS(style));
	} else {
		// objectの場合
		each(style,function(value,key){
			if(setStyle.hack.hasOwnProperty(key)){
				var tmp = setStyle.hack[key](key,value);
				key = tmp[0],value = tmp[1]
			}
			element.style[key.camelize()] = value
		});
	}
}
setStyle.hack = {
	opacity : function(key,value){
		return (
			(/MSIE/.test(navigator.userAgent))
				? ["filter" , 'alpha(opacity='+value*100+')']
				: [ key , value]
		)
	}
}



/*
*/

// var Config = {}
// Task
/*
 並列してリクエストを投げる、
  - 完了したものからcompleteフラグを立てる
  - 監視者のupdateメソッドを呼び出す
 
 var task = new Task([loadConfig,func,func]);
 task.oncomplete = function(){
 	// complete !
 };
 task.exec();

 api["config/load"] = new API("/api/config/load").requester("post");
 new Task(loadconfig);
 API.prototype.toTask = function(){
  
 }
*/


Object.extend(Function.prototype,{
	/* TIMERS */
	_timeouts : [],
	_interals : [],
	do_later  : function(ms){
		this._intervals.push(setTimeout(this,ms));
		return this;
	},
	bg : function(ms){
		this._intervals.push(setInterval(this,ms));
		return this;
	},
	kill : function(){
		this._timeouts.forEach(function(pid){
			clearTimeout(pid)
		});
		this._intervals.forEach(function(pid){
			clearInterval(pid)
		})
	},
	/* TASK */
	observers : [],
	complete  : function(result){
		this.result_code = result;
		this.observers.invoke("update", this)
	},
	_changed  : false,
	changed   : function(state){
		return arguments.length ? (this._changed = state) : this._changed;
	},
	add_observer : function(observer){
		this.observers.push(observer)
		return this;
	}
})
function loadConfig(){
	var task = arguments.callee;
	var api = new API("/api/config/load");
	return api.post({},function(res){
		extend(Config,res);
		task.complete();
	});
}
function Task(tasks,callback){
	var self = this;
	this.tasks = tasks;
	tasks.map(function(v){
		return isFunction(v) ? v : send(v,"toTask")
	}).invoke("add_observer", this);
	if(callback){
		this.oncomplete = callback;
		this.exec();
	}
	return this;
}
Task.prototype = {
	isTask : true,
	exec : function(){
		this.tasks.invoke("call",null);
	},
	update : function(f){
		send(this,"onprogress");
		
	}
}


/*
 super 
*/
/*
 parent
  this.parent.update();
  this.parent.parent.update();
   -> parent(this,"update")
*/
function parent(obj, method, args){
	var p = obj.parent;
	while(p){
		send(p,method,args);
		p = obj.parent;
	}
}
/*
 invoke 別のクラスに処理を伝播させる
  invoke(this, "method_name", arguments);
*/
function invoke(obj, method, args){
	var o = obj.parent;
	for (;typeof(o) != 'undefined'; o = o.parent) {
		if (typeof(o[method]) == 'function') {
			return o[method].apply(obj, args);
		}
	}
	return false;
}
/*
 next たらいまわしにする。
  this.parent.childs
   next(this, "initialize");
  
*/
function next(obj, method, args){
	obj.parent.childs.invoke(method,args)
}

function childOf(element, ancestor){
	element = $(element), ancestor = $(ancestor);
    while (element = element.parentNode)
      if (element == ancestor) return true;
    return false;
}
function $ref(element){
}
String.prototype.op = function(){
	return new Function("a,b","return a"+this+"b");
}


// regexp marger
// 正規表現を複数行にわたって記述できるようにします。

RegExp.prototype.get_body = function(){
	var str = this.toString();
	return str.slice(1,str.lastIndexOf("/"));
};
RegExp.prototype.get_flags = function(){
		return [
			this.ignoreCase ? "i":"",
			this.global     ? "g":"",
			this.multiline  ? "m":""
		].join("");
};
RegExp.concat = function(){
	var args = Array.from(arguments);
	var buf = [];
	args.forEach(function(reg){
		buf.push(reg.get_body());
	});
	var flag = args[args.length-1].get_flags();
	return new RegExp(buf.join(""), flag);
}

Function.prototype.forEachArgs = function(){
	var f = this;
	return function(){
		var target = Array.from(arguments).flatten();
		if(!target.length) return;
		target.forEach(function(v){
			f(v)
		})
	}
};

/*
 Element Updater
*/
// function updater(label,callback){
// 	if(callback){
// 		updater.reg["_"+label] = callback;
// 	} else {
// 		return function(){
// 			update(label)
// 		}
// 	}
// }
// updater.reg = {};
// updater.get = function(label){
// 	return isFunction(updater.reg["_"+label]) ? updater.reg["_"+label] : function(){};
// }
// function update(label){
// 	if(isRegExp(label)){
// 		keys(updater.reg).filter(function(l){
// 			l = l.slice(1);
// 			return label.test(l)
// 		}).forEach(function(label){
// 			label = label.slice(1);
// 			updater.get(label).call($(label));
// 		})
// 	} else {
// 		return updater.get(label).call($(label));
// 	}
// }
// update = update.forEachArgs();


function centering(element,x,y){
	element = $(element);
	x = x || 0;
	y = y || 0;
	var w = element.offsetWidth;
	var h = element.offsetHeight;
	var bw = document.body.offsetWidth;
	var bh = document.body.offsetHeight;
	var top  = (bh/2) - (h/2) -y + "px";
	var left = (bw/2) - (w/2) -x + "px";
	setStyle(element,{
		top : top,
		left : left
	});
}

function centering_by_window(element,x,y){
	element = $(element);
	x = x || 0;
	y = y || 0;
	var w = element.offsetWidth;
	var h = element.offsetHeight;
	var ww = getWindowWidth();
	var wh = getWindowHeight();
        var page_scroll = getPageScroll();
	var top  = ((wh/2) - (h/2) - y) + page_scroll[1] + "px";
	var left = (ww/2) - (w/2) - x + "px";
	setStyle(element,{
		top : top,
		left : left
	});
}


function getWindowWidth(){
    if(window.innerWidth){
        return window.innerWidth;
    }
    if(document.documentElement && document.documentElement.clientWidth){
        return document.documentElement.clientWidth;
    }
    else if(document.body && document.body.clientWidth){
        return document.body.clientWidth;
    }
    return 0;
}

function getWindowHeight(){
    if(window.innerHeight) {
        return window.innerHeight;
    }
    if(document.documentElement && document.documentElement.clientHeight){
        return document.documentElement.clientHeight;
    }
    else if(document.body && document.body.clientHeight){
        return document.body.clientHeight;
    }
    return 0;
}


/* DOM  */
var DOM = {};
DOM.create = function(tag){
	return document.createElement(tag);
};
DOM.build = function(obj){
	
}
DOM.remove = function(el){
	el = $(el);
	el.parentNode.removeChild(el);
};
DOM.hide = function(el){
	$(el).style.display = "none";
};
DOM.show = function(el){
	$(el).style.display = "block";
}
DOM.clone = function(el){
	return el.cloneNode(true);
}
DOM.insert = function(p,el,point){
	//point.parentNode.parentNode.insertBefore(el,point);
	p.insertBefore(el,point);
	//$("right_body").insertBefore(el,point);
};
DOM.scrollTop = function(el){
	var element = $(el);
	return element.scrollTop;
};
DOM.move = function(el,x,y){
	el = $(el);
	setStyle(el,{
		left : x+"px",
		top  : y+"px"
	});
}

function redirect(url) {
    window.location = url;
}



//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/* error window */
function show_error(e) {
    if (e) {
        if (typeof(e) != 'string') {
            if(e.title) {
                $("error_title").innerHTML = e.title;
            }
            if(e.body) {
                $("error_body").innerHTML = e.body;
            }
        } else {
            $('error_body').innerHTML = e;
        }
    }
    var elem = $("error_window");
    elem.style.display = 'block';
    centering_by_window("error_window",0,50);
}

var error_message = {};
error_message.busy = {
    title : "データの受信に失敗しました",
    body : "<p>サーバーが混雑している可能性があります。<br>しばらく時間をおいてから再度アクセスしてください。</p>"
};
function print_error(t){
    var e = error_message[t];
    if(e){
    	$("error_title").innerHTML = e.title;
    	$("error_body").innerHTML =  e.body;
    }
}


function doBlindDown(key) {
    new Effect.BlindDown(key, { duration: 0.3 });
}

function doBlindUp(key) {
    new Effect.BlindUp(key, { duration: 0.3 });
}

function doToggle(on, off) {
    new Element.toggle(on, off);
}

function ToggleClassName(id, class1, class2) {
    var item = $(id);

    if ( Element.hasClassName(item, class1) ) {
        Element.removeClassName( item, class1 );
        Element.addClassName( item, class2 );
        return;
    }
    if ( Element.hasClassName(item, class2) ) {
        Element.removeClassName( item, class2 );
        Element.addClassName( item, class1 );
        return;
    }
}

function html_filter(string) {
//    return string.toString().escapeHTML();
   return string.replace(/&/g, '&amp;')
   .replace(/</g, '&lt;')
   .replace(/>/g, '&gt;')
   .replace(/\"/g, '&quot;');
}

function nl2br_filter(string) {
    return string.toString().replace(/(\r\n|\n|\r)/g, "<br>$1");
}

function GetRandom(max) {
    return (Math.floor( Math.random() * max )) + 1;
}

function getElementsByClassName(tag, className) {
    var elements = document.getElementsByTagName(tag);
    var resultElements = new Array();
    var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
    for(var i = 0; i < elements.length; i++) {
        var el = elements[i];
        if(re.test(el['className']))
            resultElements.push(el);
    }
    return resultElements;
}

function replaceClassName(el, oldClassName, newClassName) {
    if(oldClassName == newClassName)
        return false;
    var classNames = el.className.split(' ');
    var newClassNames = new Array();
    var hasOld = false;
    for(var i = 0; i < classNames.length; i++) {
        if(classNames[i] == oldClassName) {
            newClassNames.push(newClassName);
            hasOld = true;
        }
        else
            newClassNames.push(classNames[i]);
    }
    if(!hasOld)
        newClassNames.push(newClassName)
    el.className = newClassNames.join(' ');
}

/* create XMLHttpRequest */
function createXhr() {
    if(window.ActiveXObject){
        try {
            return new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                return new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                return null
            }
        }
    } else if(window.XMLHttpRequest){
        return new XMLHttpRequest();
    } else {
        return null
    }
}


function getUrl(url, callback, scope) {
    var xhr = createXhr();
    if(!xhr) {
        callback(null);
        return;
    }
    xhr.open('GET', url, true);
    xhr.onreadystatechange = function() {
        if(xhr.readyState == 4) {
            if(xhr.status >= 200 && xhr.status < 300){
                if(!scope)
                    callback(xhr);
                else
                    callback.apply(scope, [xhr]);
            }
        }
    };
    xhr.send(null);
}

var CommentPager = function() {
  this.initialize.apply(this, arguments);
}
CommentPager.prototype = {
  initialize: function(args) {
    this.current = 1;
    this.button = args.button;
    this.id = args.id;
    this.total_pages = args.total_pages;
  },
  next_page: function() {
    return this.current + 1;
  },
  next_comment: function() {
    if (this.current < this.total_pages) {
      var query = [
        "ranking_id=" + this.id,
        "p=" + this.next_page()
      ].join("&");
      getUrl("/api/ranking_comments/list?" + query, this.add_comment.bind(this));
    }
  },
  add_comment: function(xhr) {
    $("rankingComment").innerHTML += xhr.responseText;
    this.current++;
    if (this.current >= this.total_pages) {
      this.disable_button();
    }
  },
  disable_button: function() {
    document.getElementById(this.button).style.display = "none";
  }
}

