var StarRating = function(id, numStars, currentRating)
{
	var container = document.getElementById(id),
		stars = new Array(),
		self = this;
	
	var Star = function(n)
	{
		this.node = document.createElement("SPAN");		
		container.appendChild(this.node);
		
		this.rating = function(new_n)
		{
			this.node.className = (n > new_n) ? "star_blank" : "star_filled";			
		}
		
		this.rating(currentRating);
		
		this.node.onmouseover = function()	{	setRating(n);			}
		this.node.onmouseout = function()	{ 	setRating();			}
		this.node.onmouseup = function()	{ 	setRating(n, true);		}
	}
	
	var setRating = function(n, set)
	{
		if(isNaN(n)) n = currentRating;
		
		for(var i=0; i<stars.length; i++)
			stars[i].rating(n);
		
		if(set)
		{
			currentRating = n;
			self.onSetRating(currentRating);
		}
	}
	
	this.onSetRating = function(n)
	{
		
	}
	
	//--------------
	
	for(var i=0; i<numStars; i++)
		stars.push( new Star(i+1) );
}