
function BxBlgComment (loggedin)
{
	this._loggedin = loggedin;
}

BxBlgComment.prototype.replyComment = function (id)
{
	if ('1' != aBxConfig['loggedin'])
	{
		showLoginForm();
		return false;
	}

	var eDiv = document.createElement('div');

	var sId = 'cmt' + id + 'reply';
    
    if ($(sId)) return;

	eDiv.id = sId;
	eDiv.style.textAlign = "center";
	eDiv.innerHTML = 'loading...';

	var eCmt = $('cmt' + id);
	eCmt.parentNode.insertBefore (eDiv, eCmt.nextSibling);

	var o = new BxContent ();

    var tmp_save = window._bx_force_server_xsl;
    window._bx_force_server_xsl = 1;

    o.replace (sId, aBxConfig['urlRoot'] + "blog/comment_reply/?id=" + id + '&date=' + (new Date()), aBxConfig['urlModuleXsl'] + 'comment_reply.xsl');

    window._bx_force_server_xsl = tmp_save;

/*	
	if (this._loggedin)
	{
		$('comment_parent_id').value = id;
		$('comment_text').focus();
	}
	else
	{
		showLoginForm();
	}
*/	
}

BxBlgComment.prototype.deleteComment = function (id)
{
	if (!this._confirm()) return false;

	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'ret');
		if ('remove_child' == ret)
		{
			alert('Remove child commnets first');
			return false;
		}
		else
		if ('1' == ret)
		{
			alert ('Comment deleted.');
			//$this.reload ();
			$('cmts').removeChild($('cmt'+id));
			return false;
		}

		alert ('Operation failed');
		return false;
	}	
	
	new BxXmlRequest (aBxConfig['urlRoot'] + "/blog/xml_comment_delete/?id=" + id, h, true);

	return false;
}

BxBlgComment.prototype._confirm = function ()
{
	return window.confirm ('Are you sure?');
}

BxBlgComment.prototype.reload = function ()
{
	document.location = document.location;
}
