
function changeUseful(cid, answer)
{
	sendHTTPRequest(usefulResponse, "ajax/update_series_comment.php?c=" + cid + "&a="+answer);
}

function usefulResponse(request)
{
	var resp = request.responseText;
	
	var colonPos = resp.indexOf(':');
	if (!colonPos || colonPos == -1)
	{
		return;
	}
	var cid = resp.substring(0,colonPos);

	var response = resp.substring(colonPos+1);

	var elem = document.getElementById('series_comment_' + cid);

	document.getElementById('series_comment_' + cid).innerHTML = "";

	if (response == 2)
	{
		elem.innerHTML = "<em>Was this comment useful?</em>&nbsp;&nbsp;<a href='javascript:changeUseful(" + cid + ",1)' class='comment_useful-yes'>Yes&nbsp;<img src='images/tickmark-ghost.png' alt='tickmark' /></a>&nbsp;&nbsp;<a href='javascript:changeUseful(" + cid + ",0)' class='comment_useful-no'>No&nbsp;<img src='images/xmark-ghost.png' alt='xmark' /></a>&nbsp;&nbsp;&nbsp;&nbsp;{$reportedHtml}";
	}
	else
	{
		var indicator = response.substring(0,1);
		var result = response.substring(1);

		elem.innerHTML = "";

		if (result == 1)
		{
			elem.innerHTML = "<em>You found this comment useful.</em>&nbsp;<img src='images/tickmark.png' alt='tickmark' />";
		}
		else
		{
			elem.innerHTML = "<em>You didn't find this comment useful.</em>&nbsp;<img src='images/xmark.png' alt='xmark' />";
		}

		if (indicator == 'u')
		{
			elem.innerHTML += "&nbsp;&nbsp;<a href='javascript:changeUseful(" + cid  + ",2)'><em>Undo</em></a>";
		}
	}
}
