cancelReplyLink = null;
parentID = null

$(function() {
        $("#greeting").greet();
        form = $("#commentform");
        $.fn.movabletype.fetchUser();
        user = $.fn.movabletype.getUser();

        cancelReplyLink = $("#cancel-comment-reply-link");
        parentID = $("#comment-parent-id");

        cancelReplyLink.click(function() {
                parentID.val('');
                $(this).hide();
        });

        $("div.reply a").each(function () {
                $(this).click(function() {
                        cancelReplyLink.css('display', 'inline');
                        parentIdAttr = $(this).closest('div.commentContainer').attr('id');
                        parentID.val(parentIdAttr.substring('comment-'.length, parentIdAttr.length));
                        return false;
                });
        });

        form.submit(function() {
                $("#armor", this).val(mt.blog.comments.armor);
                return true;
        });
        form.onauthchange(function(evt, user) {
                if (user.is_authenticated)
                {
                        $("#field-author", form).val(user.name);
                        $("#field-email", form).val(user.email);
                        $("#field-url", form).val(user.url);
                        $("#author-info", form).hide();
                }
        });
});


