﻿{
function InitVoto() {
    //voto recensioni    
    for (var h = 0; h < document.getElementsByTagName("a").length; h++) {
        if (document.getElementsByTagName("a")[h].getAttribute("rel", false) == "sel_voto") {
            var obj = document.getElementsByTagName("a")[h];
            addEvent(obj, 'click', SetVoto);
        }
    }
}
function InitVoto2() {
    //voto pagina utente
    for (var h = 0; h < document.getElementsByTagName("a").length; h++) {
        if (document.getElementsByTagName("a")[h].getAttribute("rel", false) == "sel_voto") {
            var obj = document.getElementsByTagName("a")[h];
            addEvent(obj, 'click', SetVoto2);
        }
    }
}

    
var votoEv;
var objReqVoto;
function SetVoto() {
    if (typeof window.event != 'undefined')
        votoEv = window.event.srcElement;
    else
        votoEv = this;

    objReqVoto = objHttp();
    objReqVoto.open('get', '/ajax/recensioni/voto.ashx?ia=' + votoEv.nextSibling.value + '&iu=' + votoEv.nextSibling.nextSibling.value + '&iuv=' + idusr + '&n=' + genRnd(), true);
    objReqVoto.onreadystatechange = CommentoVotato;
    objReqVoto.send(null);
}

function SetVoto2() {
    if (typeof window.event != 'undefined')
        votoEv = window.event.srcElement;
    else
        votoEv = this;

    objReqVoto = objHttp();
    objReqVoto.open('get', '/ajax/recensioni/voto.ashx?ia=' + votoEv.nextSibling.value + '&iu=' + idusr + '&iuv=' + votoEv.nextSibling.nextSibling.value + '&n=' + genRnd(), true);
    objReqVoto.onreadystatechange = CommentoVotato;
    objReqVoto.send(null);
}

function Log() {
    window.alert("Per poter votare devi effettuare il login con user e password che hai usato per registrarti su http://forum.spaziogames.it");
}

function CommentoVotato() {
    if (objReqVoto.readyState == 4 && objReqVoto.status == 200) {
        votoEv.style.backgroundImage = "url(/img/common/ok_bn.gif)";
        votoEv.title = "Hai già votato questo commento";
        if (parseInt(objReqVoto.responseText) > parseInt(votoEv.innerHTML.replace("&nbsp;", "")))
            votoEv.innerHTML = "&nbsp;" + objReqVoto.responseText;
        else
            window.alert("Hai già votato questo commento");
    }
}
}

