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

    
$_value = isset($_GET['v']) ? trim($_GET['v']) : null;
    
    if (
mysql_num_rows(mysql_query("SELECT * FROM images WHERE id = '" $_id "'")))
    {
        if (
$_value == 1)
        {
            echo 
"document.getElementById('vote_holder').innerHTML = 'You Voted: <span class=\"good\">Good</span>';";
            
mysql_query("REPLACE INTO images_rating SET posted_on = NOW(), user_id = '" $GLOBALS['auth']['id'] . "', vote = '1', image_id = '" $_id "'");
        }
        else if (
$_value == 0)
        {
            echo 
"document.getElementById('vote_holder').innerHTML = 'You Voted: <span class=\"error\">Bad</span>';";
            
mysql_query("REPLACE INTO images_rating SET posted_on = NOW(), user_id = '" $GLOBALS['auth']['id'] . "', vote = '-1', image_id = '" $_id "'");
        }
    }
    echo 
"document.getElementById('v_rating').innerHTML = '" image_overall_rating($_id) . "';";
?>