<?
    
require_once('include/functions/community_reply_overall_vote.php');

    
$_id = isset($_GET['i']) ? trim($_GET['i']) : null;
    
$_vote = isset($_GET['v']) ? trim($_GET['v']) : null;

    
$reply mysql_query("SELECT message_user_id FROM community_messages WHERE message_id = " sq($_id));
    if (
$reply mysql_fetch_array($reply))
    {
        if (
$reply['message_user_id'] != $GLOBALS['auth']['id'])
        {
            if (
$_vote == 'good')
            {
                
mysql_query("REPLACE INTO community_messages_rating SET message_id = " sq($_id) . ", user_id = '" $GLOBALS['auth']['id'] . "', vote = '1'");
            }
            elseif (
$_vote == 'bad')
            {
                
mysql_query("REPLACE INTO community_messages_rating SET message_id = " sq($_id) . ", user_id = '" $GLOBALS['auth']['id'] . "', vote = '-1'");
            }
        }
    }
    
    
$reply_overall_rating reply_overall_rating($_id);
    
    if (
$reply_overall_rating == 0)
    {
        echo 
'document.getElementById(\'r' $_id '\').innerHTML = \'Neutral [0]\';';
        echo 
'document.getElementById(\'i' $_id '\').style.display = \'block\';';
    }
    elseif (
$reply_overall_rating 0)
    {
        echo 
'document.getElementById(\'r' $_id '\').innerHTML = \'<span class="notice_good">Good [+' $reply_overall_rating ']</span>\';';
        echo 
'document.getElementById(\'i' $_id '\').style.display = \'block\';';
    }
    else
    {
        echo 
'document.getElementById(\'r' $_id '\').innerHTML = \'<span class="notice_error">Bad [-' $reply_overall_rating ']</span>\';';
        echo 
'document.getElementById(\'i' $_id '\').style.display = \'none\';';
    }
?>