var blocked=0;

function update_stars(a) {
    if (blocked==1) return;
    for (i=1; i<=5; i++) {
        if (i<a || a==0) {
            document.getElementById('star_'+i).src = 'images/starGrey.jpg';
        } else {
            document.getElementById('star_'+i).src = 'images/starYellow.jpg';
        }
    }
}

function rate_article(a) {
    if (blocked==1){ alert('Du hast diesen Spruch bereits bewertet');return false;}
    var xmlHttp = null;
    if (typeof XMLHttpRequest != 'undefined') {xmlHttp = new XMLHttpRequest();}
    if (!xmlHttp) {try {xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");} catch(e) { try {xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {xmlHttp  = null;}}}
    if (xmlHttp) {
        xmlHttp.open('GET', 'rate.php?ID='+ID+'&points='+a, true);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                update_stars(6-a);
                blocked=1;
            }
        };
        xmlHttp.send(null);
    }

    return false;
}