
function voteStory(iStoryId)
{
	if (iStoryId > 0)
	{
		$('Processing').show( );
		
		var sUrl    = "ajax/today/save-story-vote.php"; 
		var sParams = ("StoryId=" + iStoryId);
	
		new Ajax.Request(sUrl, { method:'post', parameters:sParams, onFailure:_showError, onSuccess:_voteStory });
	}
	
	else
		alert("Invalid Rating Request.");
} 

function _voteStory(sResponse)
{
	if (sResponse.status == 200 && sResponse.statusText == "OK")
	{
		var sParams = sResponse.responseText.split('|-|');
		
		if (sParams[0] == "OK")
		{
			var iStoryId = sParams[1];
			var sVotes   = sParams[2];
			var sMessage = sParams[3];
			
			$('Votes' + iStoryId).innerHTML = sVotes;
			
			$('Votes' + iStoryId).setStyle({ cursor:'default' });
			$('Votes' + iStoryId).onclick = function( ) { return false; };
			
			$('UserMessage').innerHTML = sMessage;
			$('UserMessage').show( );
			
			setTimeout( function( ) { $('UserMessage').hide( ); }, 3000);
		}
			
		else
			_showError(sParams[1]);
			
		$('Processing').hide( );
	}
	
	else
		_showError( );
}
