calcSrc = function(x, y)
{
	return "http://proboards.gamingmedley.com/images/red-star-" + ((x % 2) ? "left" : "right") + "-half" + (((!y) || (parseFloat(y) < x / 2)) ? "-fade" : "") + ".gif";
}
document.write("<strong>Rate This Game:<\/strong>&nbsp; <span id=\"flash-games-rating\"><em>Loading...<\/em><\/span>");
var ratingSpan = document.getElementById("flash-games-rating");
ratingSpan.removeChild(ratingSpan.firstChild);
for (var x = 1; x < 11; x++)
{
	var star = document.createElement("img");
	star.setAttribute("alt", (x / 2).toString());
	star.setAttribute("src", calcSrc(x, readCookie("rating[" + game + ']')));
	star.setAttribute("title", (x / 2).toString() + " Star" + ((x != 2) ? "s" : ""));
	star.onclick = function()
	{
		setCookie("rating[" + game + ']', this.alt);
		Ajax("POST", "rating.php", "game=" + game + "&rating=" + this.alt, function()
			{
				if (http.readyState == 1)
					ratingSpan.innerHTML = "<tt>Rating...<\/tt>";
				else if (http.readyState == 4)
				{
					ratingSpan.innerHTML = "<tt>R a t e d<\/tt>";

					// Error Handler
					if (http.responseText)
						alert(http.responseText);
				}
			}
		);
	}
	star.onmouseout = function()
	{
		var stars = ratingSpan.getElementsByTagName("img");
		for (var omo = 0; omo < 10; omo++)
			stars[omo].setAttribute("src", calcSrc(omo + 1, readCookie("rating[" + game + ']')));
	}
	star.onmouseover = function()
	{
		var stars = ratingSpan.getElementsByTagName("img");
		for (var omo = 0; omo < 10; omo++)
			stars[omo].setAttribute("src", calcSrc(omo + 1, this.getAttribute("alt")));
	}
	star.style.cursor = "pointer";
	ratingSpan.appendChild(star);
}