//var votes = Array();

    var type;
    var id;
    var sign;
    var request;
    var prvCol;
    try {request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = false; }}}

function vote (_id, _type, _sign){
  //  votes.push(this);
    type  = _type;
    id    = _id;
    sign  = _sign;

    var url = "votemashina.php"; 
    request.open("POST", url, true);
    request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    request.onreadystatechange = pa;
    request.send( "id=" + encodeURIComponent(   id   ) + "&type=" + encodeURIComponent(  type  ) + "&sign=" + encodeURIComponent(  sign  ) );
    prvCol = document.getElementById("RT_" + type + "_" + id).style.background;
    document.getElementById("RT_" + type + "_" + id).style.background = "#EEEEEE";
}

function pa(vtlnk){
    //alert("id is " + vtlnk);
    if (request.readyState == 4 && request.status == 200){
        var response = request.responseText;
        if (response != "bad"){
            var stcl = "rzero";
            if ( Number(response) != 0 ) stcl = ( Number(response) > 0 )?"rplus":"rminus";
            document.getElementById("RT_" + type + "_" + id).className = stcl;
            document.getElementById("RT_" + type + "_" + id).innerHTML = response;
            document.getElementById("RT_" + type + "_" + id).style.background = prvCol;
        } else {
            document.getElementById("RT_" + type + "_" + id).style.background = prvCol;
            alert('У вас недостаточно очков, чтобы проголосовать, либо ваш аккаунт не активирован.');
        }
    }
}


function doVote(_id, _type, _sign){
    vote(_id, _type, _sign);
}
