var http;
if (navigator.appName == "Microsoft Internet Explorer")
{
    http = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
    http = new XMLHttpRequest();
}

function vote(v) 
{
    document.getElementById('v' + Math.abs(v)).innerHTML = '...';
    http.open('get', 'http://' + window.location.hostname + '/links/vote.php?js=1&vote=' + v);
    http.onreadystatechange = function() { handleResponse(v); };
    http.send(null);
}

function handleResponse(id) 
{
    if (http.readyState == 4)
    {
        var currentScore = document.getElementById('s' + Math.abs(id)).innerHTML;
        document.getElementById('s' + Math.abs(id)).innerHTML = ((id > 0) ? ++currentScore : --currentScore);
        document.getElementById('v' + Math.abs(id)).innerHTML = http.responseText;
    }
}


