var WORKING = false;
var LoadedComments = {};
var HomeComments = Class.create();
HomeComments.prototype = {
	initialize: function(elem, bmId){
		this.elem = elem;
		this.bmId = bmId;
		if(LoadedComments[bmId]){
			this.completeLoad();
			return;
		}
		new Ajax.Updater(this.elem, '/ajx/', {
			method: 'post',
			parameters: $H({
				f: 'getCommentsHTML',
				id: this.bmId
				}).toQueryString(),
			onComplete: this.completeLoad.bind(this),
			onException: function(){ WORKING=false; $('cmAjxLoading' + this.bmId).style.display='none'; alert("We could not load comments for that entry. Please try again in a few minutes."); }.bind(this)
			});
	},
	completeLoad: function(req, json){
		LoadedComments[this.bmId] = true;
		Effect.SlideDown(this.elem, {
			afterFinish: function(){ $('cmAjxLoading' + this.bmId).style.display='none'; WORKING=false; }.bind(this)
			});	
	}
};
