		// author:  Radu Mogos
		// email:   radu.mogos@openview.ro
		//
		// Prototype based rating class
		//
		var Rating = Class.create();
		Rating.prototype = 
		{
			initialize: function(el,innerEl,entryTypeValue,entryId,duplicates,rateURL) 
			{
			    this.duplicates = duplicates;
			    this.isRated = false;
				this.value = 0;
				this.rate = 0;
				this.max = 10;
				this.elementId = el;
				this.innerElem = innerEl;
				this.element = $(el);
				this.innerElem = $(innerEl);
				this.isRated = false;
				this.entryTypeValue = entryTypeValue;
				this.entryId = entryId; 
				this.rateURL = rateURL;
				
				this.draw();
			},
			
			clickStars: function(event) 
			{
		  		var el = Event.element(event);
		  			
				this.rate = parseInt(el.innerHTML * 2);
				if (isNaN(this.rate))
					this.rate = 0;	

				new Ajax.Request(this.rateURL,
				{
				    method:'get',
				    parameters: {entryTypeValue: this.entryTypeValue, entryId: this.entryId, rated: this.rate},
				    onSuccess: this.handleSuccess.bind(this),
				    onFailure: function()
				    { 
				      alert('Something went wrong...') 
				    },
				    onException: function(transport,exception)
				    {
				      alert(exception);
				    }
				  });
			},
			
			handleSuccess: function(ajaxReq)
			{
				 for(i in this.duplicates)
				 {
				 	if($(this.duplicates[i]))
				 		$(this.duplicates[i]).innerHTML = ajaxReq.responseText;
				 }
				 this.element.innerHTML = ajaxReq.responseText;
			},
			
			draw: function() 
			{
		  		if(!this.element)
			  		return;
			    	
		  		var starClass = Array('half',
						'one-star',
						'one-star-half',
						'two-stars',
						'two-stars-half',
						'three-stars',
						'three-stars-half',
						'four-stars',
						'four-stars-half',
						'five-stars');
				var percent = parseInt(this.value * 100 / this.max);
				var currently = this.value + '/' + this.max;
				var innerCode = '<li class="current-rating" style="width:' + percent + '%;">Currently ' + currently + ' Stars.</li>';
				var rating = 0;
			  	for (var i = 0; i < this.max; i++)
				{
				  rating += 0.5;
				  innerCode += '<li><a href="javascript:void(0)" title="' + rating + ' star out of 5" class="' + starClass[i] + '">' + rating + '</a></li>';
				}

				innerCode = '<ul class="star-rating">' + innerCode + '</ul>';

				this.innerElem.innerHTML = innerCode;				
			},
			
			setValue: function(newValue) 
			{
				this.value = newValue;
				this.draw();
			},
			
			setRate: function(newValue) 
			{
				this.rate = newValue;
			}
		}