/**
 * Init Description Feedback
 * 
 * This method takes a single parameter: The descriptionID we are initializing feedback for.
 * The following HTML id components are expected to exist:
 * 1) no_description#ID#
 * 2) yes_description#ID#
 * 3) stats_feedback_description#ID#
 * 
 * where '#ID#' is to be replaced by the descriptionID number.
**/
function initDescriptionFeedback(id)
{
	var yes = $("yes_description" + id);
	var no = $("no_description" + id);

	yes.onclick = function(event)
	{
		// This is going to submit a yes vote to the web service
		var params = "descriptionID=" + id;
		params += "&userID=" + client.userID;
		params += "&cfToken=" + client.cfToken;
		params += "&feedback=1";
		ajax("POST", "/cfc/listings.cfc?method=addDescriptionFeedbackRPC", ajaxFinished, null, params);

		// Update the images
		yes.src = "/images/yesButton.gif";
		no.src = "/images/noButtonInactive.gif";
	}

	no.onclick = function(event)
	{
		// This is going to submit a no vote to the web service
		var params = "descriptionID=" + id;
		params += "&userID=" + client.userID;
		params += "&cfToken=" + client.cfToken;
		params += "&feedback=0";
		ajax("POST", "/cfc/listings.cfc?method=addDescriptionFeedbackRPC", ajaxFinished, null, params);

		// Update the images
		yes.src = "/images/yesButtonInactive.gif";
		no.src = "/images/noButton.gif";
	}

	function ajaxFinished(stats)
	{
		var x = stats.positivefeedbackcount;
		var y = stats.totalfeedbackcount;

		$("stats_feedback_description"+ id).innerHTML = x +" of "+ y +" found the following description helpful:";
	}
}

