

function BxBlgVote (iEntryId, iVote, iPlace)
{
	var $this = this;

    this.updateVoteCount = function (i)
    {        
        var s = 'blg_count_vote_' + (i > 0 ? 'positive' : 'negative');
        var e = $(s);        
        if (!e) return;
        var ii = parseInt(e.innerHTML);
        ii += 1;
        e.innerHTML = ii;
    }

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'ret');
		
		if ('err' == ret)
		{
			alert ('Voting error');
		}
		else
		if ('login' == ret)
		{
			showLoginForm();
		}
		else
		if ('dup' == ret)
		{
			alert ('Duplicate vote');
		}
		else
		{
            $this.updateVoteCount(iVote);
			$('entry_vote_' + iEntryId).innerHTML = ret;
		}

		return false;
	}	
	
	var sAction = 'xml_vote';
	if ('comment' == iPlace)
		sAction = 'xml_vote_comment';

	new BxXmlRequest (aBxConfig['urlRoot'] + aBxConfig['moduleUri'] + sAction + "/?id=" + iEntryId + '&vote=' + iVote + '&place=' + iPlace + '&date=' + (new Date()), h, true);

	return false;
}

