// JavaScript Document

var ratedKeywords = new Array();	

function toggleStar(keyword, index, state)
{

	var starIndex = index;
	if (ratedKeywords[keyword] != null && ratedKeywords[keyword] > 0)
	{
		if (state == 'ON')
		{
			starIndex = ratedKeywords[keyword]-1;
		}
		else
		{
			return;
		}
	}
	var starImg = "/images/star_on.gif";
	if (state=='OFF')
	{
		starImg = "/images/star_off.gif";
	}
	switch(starIndex)
	{
		case 5:
			document.Star5.src = starImg;
		case 4:
			document.Star4.src = starImg;
		case 3:
			document.Star3.src = starImg;
		case 2:
			document.Star2.src = starImg;
		case 1:
			document.Star1.src = starImg;
	}
}

function recordRating(keyword, rating)
{
	if (ratedKeywords[keyword] != null && ratedKeywords[keyword] > 0)
	{
		return;
	}
	toggleStar(keyword,rating,'ON');
	document.getElementById('ratingText').innerHTML='Thank you!';
	ratedKeywords[keyword] = rating;
	var rateUrl = 'http://www.marcopoloarcade.com/includes/insertrating.php?rank='+rating+'&gameid='+keyword;		var req = null; 
	if(window.XMLHttpRequest) req = new XMLHttpRequest(); 
	else 
	if (window.ActiveXObject)  req = new ActiveXObject('Microsoft.XMLHTTP'); 
	req.onreadystatechange = function()
	{ 
		return;
	};
	req.open("GET", rateUrl, true);
	req.send(null);
}
