var rules = { 
	'a.updateComments' : function(el){
		el.onclick = function(){
			Engine.doUpdateComments();
			return false;
		}
	},

	'input.isEmail' : function(el){
		el.onblur = function (){
			//alert(el.value);
			if(el.value.length < 6)
				Engine.setError(el);
			else
				Engine.setOK(el);
		}
	},
	
	'input.minLength' : function(el){
		el.onblur = function (){
			//alert(el.value);
			if(el.value.length < 5){
				Engine.setError(el);
			}else
				Engine.setOK(el);
			
		}
	},
	
	'#submitComment' : function(el){
		el.onclick = function(){Engine.doSubmitComment(escape($F('userComment')), 0);}
	},

	'#editOk' : function(el){
		el.onclick = function(){
			commentId = this.getAttributeNode("commentId").value;
			Engine.doChangeComment(commentId,escape($F('userCommentEdited')));
		}
	},

	'#replyOk' : function(el){
		el.onclick = function(){
			commentId = this.getAttributeNode("commentId").value;
			Engine.doSubmitComment(escape($F('userCommentReply')), commentId);
		}
	},

	'#editCancel' : function(el){
		el.onclick = function(){
      		if ($('editBox')) {
      			new Effect.Fade2($('editBox'), {duration: 1.0,
      				afterFinish: function callback(obj){
      					Engine.doUpdateComments();
      				}
      			});
      		}
			setTimeout("Engine.doUpdateComments()",800);
		}
	},

	'a.deleteComment' : function(el){
		if(el.onclick)
			return;
		Engine.log("Applying rule to " + el.toString());
		var target = el.href.substring(el.href.indexOf('?') + 1);
		el.href = "#"+target;
		el.onclick = function(){
			commentId = this.getAttributeNode("commentId").value;
			Engine.doDeleteComment(commentId);
		}
	},

	'a.replyToComment' : function(el){
		if(el.onclick)
			return;
		Engine.log("Applying rule to " + el.toString());
		var target = el.href.substring(el.href.indexOf('?') + 1);
		el.href = "#" + target;
		el.onclick = function(){
			commentId = this.getAttributeNode("commentId").value;
			Engine.doReplyToComment(commentId);

		}
	},

	'a.editComment' : function(el){
		if(el.onclick)
			return;
		Engine.log("Applying rule to " + el.toString());
		var target = el.href.substring(el.href.indexOf('?') + 1);
		el.href = "#"+target;
		el.onclick = function(){
			commentId = this.getAttributeNode("commentId").value;
			Engine.doEditComment(commentId);
		}
	},

	'a.refreshButton' : function(el){
		if(el.onclick)
			return;
		Engine.log("Applying rule to " + el.toString());
		var target = el.href.substring(el.href.indexOf('?') + 1);
		el.href = "#" + target;
		el.onclick = function(){
			Engine.doUpdateComments();
		}
	}

};
Behaviour.register(rules);