function CommentRating()
{
    this.request = 'indexajax.php?action=CommentRating';
}

CommentRating.prototype.add = function(id, value) 
{
	var obj		    		= this;
	var argv		    	= arguments;
    
    $.ajax({
        'type'     : "post",
        'url'      : this.request + '&start=add',
        'data'     : { 
            'id'     : id,
            'value'  : value
        },
        'dataType' : "xml",
        'success'  : function(xml) {
            
            var ajaxResponseResult;
            var ajaxResponseErrors;
            
            $("response > result", xml).each (
                function()
                {
                    ajaxResponseResult = ($(this).text());
                }
            );
    
            $("response > errors", xml).each (
                function()
                {
                    ajaxResponseErrors = ($(this).text());
                }
            );
            
            if(ajaxResponseErrors == 1) 
            {
				new UserLogin().show(function(){argv.callee.apply(obj,argv)});
            }            
            else if(ajaxResponseErrors == 2) 
            {
            	alert("Tylko raz można ocenić komentarz");
            }            
            else
            {   
                $('#rating-' + id).html(ajaxResponseResult);
            }
        }
    });
}
