	var mooForum = new Class({
		Implements:[Options,Events],
		options:{//set all the options here
			id_art: '',
			url: '/articles/ajax_response_article_comment.php'
		},
		
		initialize: function(element,options) {
			
			this.setOptions(options);
			this.el = $(element); if (!this.el) return;
			this.elid = element;
			this.del = $$(' .deletecomment');
			this.addcomment = $('creacommento');
			this.listcomment = $('forumcomment');
			this.view = $('forum_all');
			this.orderB = $('forum_order');
			this.form = $('formforum');
			
			this.forumslide = new Fx.Slide('addcomment',{ transition: Fx.Transitions.Quart.easeOut });
			this.forumslide.hide();
			
			this.del.each(function(item) {
				item.addEvent('click', function(){
					this.deleteComment(item.id,this.options.id_art,this.listcomment);
				}.bind(this));					   
			}.bind(this));
			
			this.addcomment.addEvent('click', function(e){
				e.stop();
				this.forumslide.slideIn();
			}.bind(this));
			
			this.view.addEvent('click', function(){
				var order = this.orderB.options[this.orderB.selectedIndex].value;							
				this.viewallComment(order, this.options.id_art,this.listcomment);
			}.bind(this));
			
			
			this.orderB.addEvent('change', function(){
				var order = this.orderB.options[this.orderB.selectedIndex].value;							
				this.changeOrder(order, this.options.id_art,this.listcomment);
			}.bind(this));
			
			this.form.addEvent('submit', function(e){
				e.stop();
				var val = $('user').get('value');
				var valc = $('commento').get('value');
				if (!val) {	$('user').highlight('#f00').focus(); return; }
				if (!valc){ $('commento').highlight('#f00').focus(); return; }
				this.sendContent(this.listcomment,this.options.id_art);
			}.bind(this));
		},
		
		deleteComment: function(id, id_art,el) {
			req = new Request({ method: 'post', url: this.options.url, 
				onSuccess: function(response) { 
					el.set('html', response);
				} 
			});
			req.send('action=delete&id=' + id + '&id_art=' + id_art );
		},
		
		viewallComment: function(order, id_art,el) {
			req = new Request({ method: 'post', url: this.options.url, 
				onSuccess: function(response) { 
					el.set('html', response);
				} 
			});
			req.send('order=' + order + '&limit=none&id_art=' + id_art );
		},
		
		changeOrder: function(order, id_art,el) {
			req = new Request({ method: 'post', url: this.options.url, 
				onSuccess: function(response) { 
					el.set('html', response);
				} 
			});
			req.send('order=' + order + '&id_art=' + id_art );
		},
		
		sendContent: function(el,id_art) {
			req = new Request({ method: 'post', url: this.options.url});
			var log = $('forumcomment').empty();
			this.form.set('send', { onComplete: function(response) { 
					log.set('html', response);
					$('user').set('value','');
					$('commento').set('value','');
					this.forumslide = new Fx.Slide('addcomment',{ transition: Fx.Transitions.Quart.easeOut });
					this.forumslide.hide();
				}
			});
			this.form.send();
		}
	});
