﻿
function colorLabel(){
    if ($obj('txt_min') != null) {
        addEvent($obj('txt_min'), 'click', DwTxt);
        addEvent($obj('txt_plus'), 'click', UpTxt);
        addEvent($obj('print'), 'click', Print);
    }
    $obj('articolo').style.fontSize = ReadCookie();
    if ($obj('tab_aggiornamento2') != null) $obj('tab_aggiornamento2').style.fontSize = $obj('articolo').style.fontSize;
    if ($obj('finale') != null) $obj('finale').style.fontSize = $obj('articolo').style.fontSize;
    

    var pu="p3"
    
    var qs=location.pathname.match(/(console.[^/]+)/);
    if(qs!=null)channelId=qs[1].replace("console_","");
    
    if(consoleOldGenIdExt.lastIndexOf(channelId)!=-1)    
    {
        switch(channel)
        {
            case 8:
                pu="ps2";
                break;
            case 9:
                pu="xbox";
                break;
            case 10:
                pu="cube";
                break;
            case 11:
                pu="psx";
                break;
            case 12:
                pu="n64";
                break;
            case 13:
                pu="gba";
                break;
            case 14:
                pu="dc";
                break;
            case 15:
                pu="saturn";
                break;
            case 16:
                pu="neogeo";
                break;
        }
    }else{
        if (document.referrer.lastIndexOf("top_videogames") != -1)
            pu = "p1";
        else if (document.referrer.lastIndexOf("live_arcade_x360") != -1 && channel==3)
            pu = "p12";
        else if (document.referrer.lastIndexOf("virtual_console_wii") != -1 && channel==4)
            pu = "p13";
        else if (document.referrer.lastIndexOf("playstation_store") != -1 && channel == 2)
            pu = "p11";
        else{
            if(typeof linkToolbar!="undefined")
            {
                switch (linkToolbar)
                {
                    case 0:
                        pu = "p3";
                        break;
                    case 1:
                        pu = "p5";
                        break;
                    case 2:
                        pu = "p4";
                        break;
                }
            }
        }
    }

    if($obj(pu)!=null)$obj(pu).style.fontWeight="bold";
}

function Print(){ 
    window.open('/recensioni_videogiochi/print.aspx?i='+idr,'PrintRecensioni','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=10,height=10,left=0,top=10000');
}

function salvaCommento() {
    if ($obj("commento2").value.length == 0) {
        window.alert("Il campo Commento è obbligatorio.");
        $obj("commento2").focus();
        return false;
    }
}

function like(post, iduser) {
    if (iduser == 0)
        window.alert("Per votare il Post occorre essere loggati.");
    else {
        objLike = objHttp();
        objLike.open('get', '/ajax/like.ashx?c=sg&p=' + post + '&i=' + iduser + '&n=' + genRnd(), true);
        objLike.onreadystatechange = function () {
            if (objLike.readyState == 4 && objLike.status == 200)
                if (objLike.responseText != "0")
                    $obj("num_like" + post).innerHTML = "<b>" + objLike.responseText + "</b>";
                else
                    window.alert("Hai gia' votato questo Post.");
        }
        objLike.send(null);
    }
}

function nolike(post, iduser) {
    if (iduser == 0)
        window.alert("Per votare il Post occorre essere loggati.");
    else {
        objNoLike = objHttp();
        objNoLike.open('get', '/ajax/no_like.ashx?c=sg&p=' + post + '&i=' + iduser + '&n=' + genRnd(), true);
        objNoLike.onreadystatechange = function () {
            if (objNoLike.readyState == 4 && objNoLike.status == 200)
                if (objNoLike.responseText != "0")
                    $obj("num_nolike" + post).innerHTML = "<b>" + objNoLike.responseText + "</b>";
                else
                    window.alert("Hai gia' votato questo Post.");
        }
        objNoLike.send(null);
    }
}

function quota(post, iduser, quotato) {
    if (iduser == 0)
        window.alert("Per quotare il Post occorre essere loggati.");
    else {
        if (quotato) {
            window.alert("Questo Post è già stato quotato.");
        } else {
            objQuota = objHttp();
            objQuota.open('get', '/ajax/quota.ashx?c=sg&p=' + post + '&n=' + genRnd(), true);
            objQuota.onreadystatechange = function () {
                if (objQuota.readyState == 4 && objQuota.status == 200) {
                    $obj("commento2").value = objQuota.responseText + "\n\n";
                    getStart($obj("commento2"));
                    $obj("commento2").focus();
                }
            }
            objQuota.send(null);
        }
    }
}

function getStart(el) {
    if (el.createTextRange) {
        var r = el.createTextRange();
        r.collapse(false);
        r.select();
    }
    el.focus();
}

function abuso(post, iduser) {
    if (iduser == 0)
        window.alert("Per segnalare un abuso occorre essere loggati.");
    else {
        if (window.confirm("Sei sicuro di voler segnalare questo Post?")) {
            objAbuso = objHttp();
            objAbuso.open('get', '/ajax/abuso.ashx?c=sg&p=' + post + '&i=' + iduser + '&n=' + genRnd(), true);
            objAbuso.onreadystatechange = function () {
                if (objAbuso.readyState == 4 && objAbuso.status == 200)
                    window.alert(objAbuso.responseText);
            }
            objAbuso.send(null);
        }
    }
}

