var formHtml = '<form action="" method="post" id="answerForm">';
	formHtml += '<input type="hidden" name="parentId" id="answerParentId" value="0" />';
	formHtml += '<div>Текст комментария:<br/><textarea name="comment" rows="6" cols="40"></textarea></div>';
	formHtml += '<div><input type="submit" value="добавить комментарий"/></div></form>';

Comments = function ()  {
	this.currParentId = 0;
};

Comments.prototype.toggleForm = function( parentId, postId ) {
    if ( this.currParentId == parentId ) {
        $( '#frm-' + this.currParentId ).html("");
        this.currParentId = -1;
        return false;
    }
	if ( this.currParentId != 0 ) {
        $("#frm-" + this.currParentId).html("");
    }
	this.currParentId = parentId;
	$( '#frm-' + this.currParentId ).html( formHtml );
	$( '#answerForm' ).attr( "action", '/comments/add/?targetId='+ postId + '&targetType=POST' );
	$( '#answerParentId' ).val( parentId );
    return false;
};

var comments = new Comments();

