
function VoteFile(vote, file)
{
	new Ajax.Request ('/ajax/Voting.php', {method: 'post',parameters:  'id=' + file + '&vote=' + vote,onSuccess: PostVoting, onFailure: DoFail});
}

function PostVoting(response)
{
    
   
    reply = response.responseText;
    

    if (reply)
    {
        regExpString = "<status>(.+?)<\/status>";

        var myRegExp = new RegExp(regExpString, "g");

        var status = myRegExp.exec(reply);
        var answer = status[1];
     
        //alert(answer);
        
	    if (answer == 2)
	    {
		    alert('You already voted this article');
	    }
	    else
	    {
		    if(answer == 1)
		    {
			    alert('Your vote has been registered succesfully.');
			    location.reload(true);
		    }
	    }
    }
}

function DoFail()
{
	
}



