﻿//Muestra Oculta el submenu de votos inadecuados
function MostrarOcultarInadecuados(commentUniqueId)
{
    var lstInadecuados = $get('lstInadecuados_' + commentUniqueId);
    
    if(lstInadecuados.style.display == 'none')
        lstInadecuados.style.display = 'block';
    else
        lstInadecuados.style.display = 'none';
}

//Vota un comentario como inadecuado
function ReportComment(commentUniqueId, razon)
{
    //razon: 1 Ofensivo, 2 Spam, 3 Otros
    Terra.Portal.AjaxServices.CommentsService.ReportComment(itemUrl, commentUniqueId, razon, OnCommentReported, OnCommentReportedError);
    MostrarOcultarInadecuados(commentUniqueId);
    
    //Disable button, change style
    var btnInadecuados = $get('btnInadecuados_' + commentUniqueId);
    btnInadecuados.href = "javascript:void(0)";
    $get('btnRecommendComment_' + commentUniqueId).href = "javascript:void(0)";
    
    var strInadecuado = '';
    if(razon == 1)
        strInadecuado = 'Ofensivo';
    else if(razon == 2)
        strInadecuado = 'Spam';
    else if(razon == 3)
        strInadecuado = 'Otros';
    btnInadecuados.innerHTML = strInadecuado;    
    btnInadecuados.className = 'inadecuado_des';
}

//Vota un comentario como recomendado
function RecommendComment(commentId)
{
   Terra.Portal.AjaxServices.CommentsService.RecommendComment(itemUrl, commentId, OnCommentRecommended, OnCommentRecommendedError);
    
    //Disable button, change style
    var btnRecomendar = $get('btnRecommendComment_' + commentId);
    btnRecomendar.href = "javascript:void(0)";
    
    
    var lstInadecuados = $get('lstInadecuados_' + commentId);
    
    if (lstInadecuados.style.display == 'block')
    {
        MostrarOcultarInadecuados(commentId);
    }
    
    $get('btnInadecuados_' + commentId).href = "javascript:void(0)";
   
    btnRecomendar.className = 'recomendar_des';
}

function OnCommentRecommended()
{
    //OK
}

function OnCommentRecommendedError(error)
{
    ShowCommentsError(error);
}

function OnCommentReported()
{
    //OK
}

function OnCommentReportedError(error)
{
    ShowCommentsError(error);
}

function ShowCommentsError(error)
{
    var stackTrace = error.get_stackTrace();
    var message = error.get_message();
    var statusCode = error.get_statusCode();
    var exceptionType = error.get_exceptionType();
    var timedout = error.get_timedOut();
   
    // Display the error.    
    strError = 
        "Stack Trace: " +  stackTrace + "<br/>" +
        "Service Error: " + message + "<br/>" +
        "Status Code: " + statusCode + "<br/>" +
        "Exception Type: " + exceptionType + "<br/>" +
        "Timedout: " + timedout;
    
    //alert(strError);
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();