﻿    function OnVoteRes(result, cell)
    {
        if (cell.id.length > 1)
        {
            if ("1" == result)
            {
                var v = 1;
                if (cell.id.charAt(0) == 'D')
                    v = -1;
                    
                var sr_id = "SR" + cell.id.substr(1);    
                var dest_cell = document.getElementById(sr_id);
                if (dest_cell && !dest_cell.voted)
                {
                    dest_cell.voted = true;
                    
                    var currRating = dest_cell.innerHTML.length > 0 ? parseInt(dest_cell.innerHTML, 10) : 0;
                    if (isNaN(currRating))
                        currRating = 0;
                    var newRating = currRating + v;
                    dest_cell.innerHTML = (newRating != 0) ? newRating : "";
                    
                    
                    var imageup = document.getElementById("MI" + cell.id.substr(1));
                    if (imageup)
                    {
                        imageup.src = "/Images/tupg.gif";
                        imageup.title = "Вы уже проголосовали";
                    }
                }
            }
            else
            {
                alert("Ошибка при голосовании");
            }
        }
        else
        {
            alert("Либо вы уже голосовали, либо отключены cookies.");
        }
    }
   
    function Vote(v, id, cell)
    {
        if (cell.id.length > 1)
        {
            var sr_id = "SR" + cell.id.substr(1);    
            var dest_cell = document.getElementById(sr_id);
            if (dest_cell && ! dest_cell.voted)
            {
                IncRating(v + id, cell);
            }
        }
    }

var Comments = 
{
    _curr : null,
    
    replyBox : function(replyId, parentId) 
    {
        var newReply = document.getElementById(replyId);
        if (newReply && (newReply != this._curr)) 
        {
            var box = document.getElementById("add_comment");
            box.parentNode.removeChild(box);
            
            newReply.appendChild(box);
            
            var commented = document.getElementById("commented");
            commented.value = parentId;
        }
    }
};

/*
var Validate = 
{
    isEmpty : function(idBox) {
        
        if ()
    }
};
*/
