var Comment = Class.create();

Comment.prototype =
{
	initialize: function(path_http)
	{
		this.path_http = path_http;
	},

	getComment: function (key, mode,element)
	{
		var uri = encodeURI(this.path_http + 'handler.ajax/' + mode + ',' +  key );
		$(element).update(this.small_loader);
		new Ajax.Request(
			uri ,
			{
        		onSuccess: function(t)
            	{
					$(element).innerHTML = t.responseText;

					new Effect.Appear(key);
            	},
				onFailure: function(t){alert(t.status);},
				onError: function(t){alert('Error');},
				onComplete: function(t){}
			}
		);
	},
	setComment: function (key, mode, rating) {
		var uri = encodeURI(this.path_http + 'handler.ajax/' + mode + ',' +  key  + ',' + rating);
		var obj_temp = this;
		new Ajax.Request(uri ,{onComplete: function(t){obj_temp.getComment(key,'rating', 'ratingResult');}});
	},
	enterComment: function (key , element , form)
	{
		var mode= 'comment';
		var ser = $(form).serialize();
		var uri = this.path_http + 'handler.ajax/' + mode + ',' +  key;
		new Ajax.Request(
			uri ,
			{
				method: 'post',
				postBody: ser,
        		onSuccess: function(t){},
				onFailure: function(t){				},
				onError: function(t){alert('Error');},
				onComplete: function(t)
				{
					$(element).innerHTML = t.responseText;
				}
			}
		);
		return false;
	}
}