var timer = new Array();

function vote(id, votingBarPrefix)
{
	ids = id.split("_");

	if (votingBarPrefix != '')
	{
		postId = ids[1];
		estimation = ids[2];
	}
	else
	{
		ids = id.split("_");
		postId = ids[0];
		estimation = ids[1];
	}

	clearTimeout(timer[postId]);

	for (i = 1; i <= maxEstimation; i++)
	{
		imgId = votingBarPrefix + postId + "_" + i;

		var imgDest = document.getElementById(imgId);
		var imgSrc = nonActiveImage;
		imgDest.setAttribute("src", imgSrc);
	}

	for (i = 1; i <= estimation; i++)
	{
		imgId = votingBarPrefix + postId + "_" + i;

		var imgDest = document.getElementById(imgId);
		var imgSrc = activeImage;
		imgDest.setAttribute("src", imgSrc);
	}
}

function outOfVote(id, votingBarPrefix)
{
	ids = id.split("_");

	if (votingBarPrefix != '')
		id = id.split("_")[1];
	else
		id = id.split("_")[0];

	clearTimeout(timer[id]);
	timer[id] = setTimeout("resetVote("+id+", '"+votingBarPrefix+"');", 1000);
}

function resetVote(id, votingBarPrefix)
{
	//show original
	postId = id;
	estimation = Votes[votingBarPrefix + postId];

	i = 1;
	for ( ; i <= estimation; i++)
	{
		imgId = votingBarPrefix + postId + "_" + i;

		var imgDest = document.getElementById(imgId);
		var imgSrc = "/Templates/Geda/Images/color_smile.gif";
		imgDest.setAttribute("src", imgSrc);
	}
	for ( ; i <= 5; i++)
	{
		imgId = votingBarPrefix + postId + "_" + i;

		var imgDest = document.getElementById(imgId);
		var imgSrc = "/Templates/Geda/Images/grey_smile.gif";
		imgDest.setAttribute("src", imgSrc);
	}
}
