
var LinkCommentEditor = Class.create({
	initialize: function(trigger, editor) {
		this.anchor = self.document.location.hash.substring(1)
		this.trigger = $(trigger);
		this.editor = $(editor) || $(this.trigger.rev);
		this.cancel = this.editor.select('a.cancel')[0];
		this.setup();
	},
	setup: function(){
		if (this.anchor == "add-comment" && this.trigger.className.include('go-to-this-add-comment'))
		{
			this.editor.addClassName('edit-mode');
		}
		this.trigger.observe('click', function(event){
			this.editor.addClassName('edit-mode');
			event.stop();
		}.bind(this));
		this.cancel.observe('click', function(event){
			this.editor.removeClassName('edit-mode');
			event.stop();
		}.bind(this));
	}
});

/* ---------------------------------------------------------------- */

document.observe("dom:loaded", function(){
	if($$('a[rel="comment"]').length > 0){
		$$('a[rel="comment"]').each(function(el, i){
			new CommentEditor(el, el.rev);
		});
	}
});