// --------------------------------------------------------
/*
This is the function that should be modified to do whatever
the user wants to do with this rating mechanism.
*/
// --------------------------------------------------------
var clickRating = function(cid, rating, extra)
{
	alert(cid + " | " + rating);
}
// --------------------------------------------------------

var jetRatings = new Array();
var hoveringIndex = -1;
var hoveringRating = -1;


function jetRating_hover(x, n)
{
	if ( (hoveringIndex!=n) || (hoveringRating!=x) )
	{
		hoveringIndex = n;
		hoveringRating = x;
		jetRatings[n].draw(x);
	}
}


function jetRating_set(x, n)
{
	jetRatings[n].rating = x;
	jetRatings[n].draw(x);
	clickRating(jetRatings[n].container.id, x, jetRatings[n].extra);
}


function jetRating_leaveContainer(c)
{
	for (var i=0;i<jetRatings.length;i++)
	{
		if (jetRatings[i].container.id==c.id)
		{
			jetRating_hover(jetRatings[i].rating, i);
		}
	}
}


function jetRating(rating, max, container, extra)
{
	this.extra = null;
	if (!(extra)) { }
	else { this.extra = extra; }

	this.index = jetRatings.length;
	this.rating = rating;
	this.max = max;
	this.container = container;
	this.draw = function(x) {
		var html = "";
		for (var i=1;i<=max;i++)
		{
			var cn = "empty";
			if (x>=i) { cn = "filled"; }
			html += "<div class=\""+cn+"\" onmouseover=\"jetRating_hover("+i+", "+this.index+");\" onclick=\"jetRating_set("+i+", "+this.index+");\"></div>";
		}
		this.container.innerHTML = html;
	}
	this.container.className = "jetRating";
	this.container.onmouseout = function() {
		jetRating_leaveContainer(this);
	}
	this.draw(rating);
	jetRatings.push(this);
}









