// byteMyCode.com
// ©1998-2006  All Rights Reserved.

// Vote up
function voteSnippetUp(nSnippetID)
{
	httpGet("/ajax/vote/up/" + nSnippetID + "/", voteSnippetRes, null);
}

// Vote down
function voteSnippetDown(nSnippetID)
{
	httpGet("/ajax/vote/down/" + nSnippetID + "/", voteSnippetRes, null);
}

// Result function for voting a comment
voteSnippetRes = function(strString, cHTTP, cParam)
{
	// Declare variables
	var cItem = null;

	// Make sure request was valid
	if (cHTTP.readyState == 4)
	{
		// -- Validate
		if (cHTTP.responseText == null || cHTTP.responseText.length == 0)
		{
			alert("There was an error with that request.");
			return;
		}

		// -- Parse response
		var aRet = cHTTP.responseText.split("|");

		// -- Validate
		if (aRet.length != 3)
		{
			alert("There was an error with that request.");
			return;
		}
		if (aRet[0] == -1)
		{
			alert("There was an error with that request.");
			return;
		}

		// -- Get variables
		var nSnippetID = aRet[0];
		var nNewRanking = aRet[1];
		var nNewPoints = aRet[2];

		// Fade effect
		fadeSnippet(nSnippetID, nNewRanking);

		// Change member points
		updateMemberPoints(nNewPoints);
	}
}
