
	var Rating =
	{
		last_rating : 3,
		stars : null,
		message : null,
		
		// --------------------------------------------------------------------------
		// Highlights rating stars by count
		set : function( count )
		// --------------------------------------------------------------------------
		{
			if( Rating.stars )
			{
				for( var i = 1; i <= 5; i++ )
				{
					if( i <= count )
					{
						$(Rating.stars[i-1]).addClass( 'hover' );
					}
					else
					{
						$(Rating.stars[i-1]).removeClass( 'hover' );
					}
				}
			}
		},
		
		// --------------------------------------------------------------------------
		// Initializes the rating
		initialize : function( rating_value )
		// --------------------------------------------------------------------------
		{
			Rating.last_rating = rating_value;
			
			var rating = $('.rating .stars');
			if( rating.length > 0 )
			{
				rating = $(rating[0]);
				
				Rating.stars = rating.children('IMG');
				Rating.message = $( $('.rating .rating-message')[0] );
				
				Rating.set( Rating.last_rating );
				Rating.stars.each( function( index )
				{
					$(this).hover
					(
						function() { Rating.set( index + 1 ); },
						function() { Rating.set( Rating.last_rating ); }
					);
				});
			}
		},
		
		// --------------------------------------------------------------------------
		rate : function( url, stars, data )
		// --------------------------------------------------------------------------
		{
			Rating.last_rating = stars;
			Rating.set( stars );
			Rating.message.html( 'Thank you for rating.' );
			
			$.post( url, { d: data }, function( response_data )
			{
				// console.log( response_data );
			});
			
			return false;
		}
	};
