var Rating = Class.create();

Rating.prototype =
{
	initialize: function(path_http)
	{
		this.ratings = new Array;
		this.path_http = path_http;
		this.counter = 0;
		var img_tag_start =  path_http + 'img/rating/';
	    this.rate_full		= img_tag_start  + 'rate_full.png';
	    this.rate_empty		= img_tag_start  + 'rate_empty.png';
	    this.rate_empty_over= img_tag_start  + 'rate_empty_over.png';
	    this.rate_full_over	= img_tag_start  + 'rate_empty.png';
	    this.rate_half		= img_tag_start  + 'rate_half.png';

	},
	getRating: 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(element);}});
	},
	setRating: function (key, mode, rating)
	{
		var uri = encodeURI(this.path_http + 'handler.ajax/' + mode + ',' +  key  + ',' + rating);
		var obj_temp = this;
		new Ajax.Request( uri , { onSuccess: function(t){}, onComplete: function(t) { obj_temp.getRating(key,'rating', 'ratingResult'); } });
	},
	mOverRating: function (id,index,rating) {
		var i;
		this.ratings[id] = rating;
		for (z=1; z<=5; z++) {
			i = $(id+"_"+z);
			im = (z <= index) ? this.rate_full_over : this.rate_empty_over;
			i.setAttribute("src",im);
		}
	},
	mOutRating: function(id,index) {
		var i;
		for (z=1; z<=5; z++) {
			i = $(id + "_" + z);
			im = (this.ratings[id] >= z) ? this.rate_full : this.rate_empty;
			i.setAttribute("src", im);
		}
	}
}

