function rate (rating, id) {
	try {
	    var ajax = new Ajax.Request( '/ajax/rating.php', {
	            method: 'post',
	            parameters: "id=" + id + "&rating=" + rating,
	            onLoading: function(request){}, 
	            onComplete: function(request) {
					msg = request.responseText;
					
					var box = document.getElementById('rating_'+id);
					var links = box.getElementsByTagName("a");
					var filled = box.getElementsByClassName("filled")[0];

					for(var i = 0; i < links.length; i++) {
						links[i].onclick = 'return false;';
						links[i].style.display = 'none';
					}
					filled.className = "voted";
					filled.style.width = parseInt(msg) + "%";

					if (msg == "already_voted")		{alert("You have already voted!");}
					else							{alert("Your vote has been recorded, thanks!");}
					
					
					var next = box.nextSibling;
					while (next.nodeType != 1) next = next.nextSibling;
					if (next.innerHTML == "(Not Rated)")
						next.innerHTML = "(1 Vote)";
					else {
						var numb = next.innerHTML.match(/\d+/);
						next.innerHTML = "(" + (parseInt(numb) + 1) + " Votes)";
					}
	            }
	        }
	    );  
	} catch(e){}
}
