function HoverRating(post, score)
{
	var i = 1;
	for (i = 1; i <= score; i++)
	{
		document.getElementById("post-" + post + "-score-" + i).src = "http://www.funnyfreak.net/images/ratings/star-on-final.gif";
	}
	var j;
	for (j = i; j <= 5; j++)
	{
		document.getElementById("post-" + post + "-score-" + j).src = "http://www.funnyfreak.net/images/ratings/star-off-final.gif";
	}
}

function HoverRatingOut(post, original)
{
	var i = 1;
	for (i = 1; i <= original; i++)
	{
		document.getElementById("post-" + post + "-score-" + i).src = "http://www.funnyfreak.net/images/ratings/star-on-final.gif";
	}
	var decimal = 100 + ((original - i)*100);
	if (decimal >= 12 && decimal < 38)
	{
		document.getElementById("post-" + post + "-score-" + i).src = "http://www.funnyfreak.net/images/ratings/star-one-quarter-final.gif";
		i++;
	}
	else if (decimal >= 37 && decimal < 63)
	{
		document.getElementById("post-" + post + "-score-" + i).src = "http://www.funnyfreak.net/images/ratings/star-one-half-final.gif";
		i++;
	}
	else if (decimal >= 63 && decimal < 87)
	{
		document.getElementById("post-" + post + "-score-" + i).src = "http://www.funnyfreak.net/images/ratings/star-three-quarter-final.gif";
		i++;
	}
	else if (decimal >= 87)
	{
		document.getElementById("post-" + post + "-score-" + i).src = "http://www.funnyfreak.net/images/ratings/star-on-final.gif";
		i++;
	}
	var j;
	for (j = i; j <= 5; j++)
	{
		document.getElementById("post-" + post + "-score-" + j).src = "http://www.funnyfreak.net/images/ratings/star-off-final.gif";
	}
}

function VoteRating(post, original, score)
{
	document.getElementById("post-" + post + "-message").innerHTML="<div class=\"Loading\">Voting...</div>";
	if (window.XMLHttpRequest) // code for IE7+, Firefox, Chrome, Opera, Safari
	{
		xmlhttp=new XMLHttpRequest();
	}
	else // code for IE6, IE5
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("post-" + post + "-message").innerHTML=xmlhttp.responseText;
			var i;
			for (i = 1; i <= 5; i++)
			{
				document.getElementById("post-" + post + "-score-" + i).onmouseover = function(){}
				document.getElementById("post-" + post + "-score-" + i).onmouseout = function(){}
				document.getElementById("post-" + post + "-score-" + i).onclick = function(){}
			}
			HoverRatingOut(post, original);
		}
	}
	xmlhttp.open("GET", "http://www.funnyfreak.net/vote.php?post=" + post + "&score=" + score,true);
	xmlhttp.send();
}

function AddFavorite(post)
{
	document.getElementById("post-" + post + "-message").innerHTML="<div class=\"Loading\">Adding to Favorites...</div>";
	if (window.XMLHttpRequest) // code for IE7+, Firefox, Chrome, Opera, Safari
	{
		xmlhttp=new XMLHttpRequest();
	}
	else // code for IE6, IE5
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("post-" + post + "-message").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET", "http://www.funnyfreak.net/favorite.php?post=" + post,true);
	xmlhttp.send();
}
