var IDComment;
var oneVote;
var success;
function votecommentagree(idcomment,errorText,successText)
{
    IDComment = idcomment;
    oneVote = errorText;
    success = successText;
	var deferred = dojo.xhrPost({
        url: "/iritzia/bozkatu/adoz/",
        content: {
			"IDComment":idcomment
		},
        handleAs: "text",
        timeout: 5000, //Time in milliseconds
        handle: handleIritizaResponse
	});
}

function votecommentdisagree(idcomment,errorText,successText)
{
    IDComment = idcomment;
    oneVote = errorText;
    success = successText;
	var deferred = dojo.xhrPost({
        url: "/iritzia/bozkatu/desados/",
        content: {
			"IDComment":idcomment
		},
        handleAs: "text",
        timeout: 5000, //Time in milliseconds
        handle: handleIritizaResponse
	});
}

function provocationAdvice(idcomment,errorText,successText)
{
    IDComment = idcomment;
    oneVote = errorText;
    success = successText;
	var deferred = dojo.xhrPost({
        url: "/iritzia/bozkatu/provocationadviced/",
        content: {
			"IDComment":idcomment
		},
        handleAs: "text",
        timeout: 5000, //Time in milliseconds
        handle: handleIritizaResponse
	});
}

function handleIritizaResponse (response, ioArgs){
    //This function handles the response.
    //Inside this function, the "this" variable
    //will be the object used as the argument to the dojo.xhrGet() call.
    if(response instanceof Error){
            if(response.dojoType == "cancel"){
                    //The request was canceled by some other JavaScript code.
                    console.debug("Request canceled.");
            }else if(response.dojoType == "timeout"){
                    //The request took over 5 seconds to complete.
                    console.debug("Request timed out.");
            }else{
                    //Some other error happened.
                    console.error(response);
            }
            alert('Error');
    }else{
            //Success.Since original call wanted the response handled
            //as text (handleAs: "text"), response will be a text string.
            console.debug("Successful server response: " + response);
           
            //ioArgs is an object with some useful properties on it.
            //For instance, for XMLHttpRequest calls, ioArgs.xhr is the
            //XMLHttpRequest that was used for the call.
            console.debug("HTTP status code: ", ioArgs.xhr);
            if(response == "")
            {
                alert('Error');
                dojo.byId("detalles-opinion-"+IDComment).innerHTML = previousComments
            }
            else if(response == "oneVotePerSession")
            {
                dojo.byId("detalles-opinion-"+IDComment).innerHTML = oneVote;
            }
            else if(response == "success")
            {
                dojo.byId("detalles-opinion-"+IDComment).innerHTML = success;
            }
    }
    //If you think there could be other callback handlers registered with this deferred, then
    //return response to propagate the same response to other callback handlers. Otherwise,
    //the error callbacks may be called in the success case.
    return response;
}