Index: /branches/release-32/default_templates/comment_detail.mtml
===================================================================
--- /branches/release-32/default_templates/comment_detail.mtml (revision 1350)
+++ /branches/release-32/default_templates/comment_detail.mtml (revision 1561)
@@ -3,5 +3,12 @@
         <div class="comment-header">
             <div class="asset-meta">
-                <span class="byline"><__trans phrase="By [_1] on [_2]" params='<span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span><MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty>%%<a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a>'></span>
+               <span class="byline">
+                   <__trans phrase="By"> <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span><MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty>
+                   <MTCommentParent>
+                   <__trans phrase="replied to"> <a href="#comment-<$MTCommentID$>"><MTCommentAuthor></a>
+                   </MTCommentParent>
+                   <__trans phrase="on"> <a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a>
+                   <MTIfCommentsAccepted> | <$MTCommentReplyLink$></MTIfCommentsAccepted>
+               </span>
             </div>
         </div>
Index: /branches/release-32/default_templates/comment_form.mtml
===================================================================
--- /branches/release-32/default_templates/comment_form.mtml (revision 1309)
+++ /branches/release-32/default_templates/comment_form.mtml (revision 1561)
@@ -17,4 +17,5 @@
             <input type="hidden" name="entry_id" value="<$MTEntryID$>" />
             <input type="hidden" name="__lang" value="<$MTBlogLanguage$>" />
+            <input type="hidden" name="parent_id" value="<MTIf name="comment_preview_template"><$MTCommentParentID$></MTIf>" id="comment-parent-id" />
             <div id="comments-open-data">
                 <div id="comment-form-name">
@@ -33,4 +34,8 @@
                     <label for="comment-bake-cookie"><input type="checkbox" id="comment-bake-cookie" name="bakecookie" onclick="if (!this.checked) forgetMe(document.comments_form)" value="1" />
                         <__trans phrase="Remember personal info?"></label>
+                </div>
+                <div id="comment-form-reply">
+                    <label for="comment-reply" id="comment-reply-label"><input type="checkbox" id="comment-reply" name="comment_reply" value="" onclick="setCommentParentID();" />
+                        <__trans phrase="Replying to"></label>
                 </div>
             </div>
Index: /branches/release-32/default_templates/javascript.mtml
===================================================================
--- /branches/release-32/default_templates/javascript.mtml (revision 1354)
+++ /branches/release-32/default_templates/javascript.mtml (revision 1561)
@@ -36,4 +36,5 @@
 
 function individualArchivesOnLoad(commenter_name) {
+    hideDocumentElement('comment-form-reply');
 <MTIfCommentsAccepted>
 <MTElse>
@@ -150,4 +151,42 @@
 </MTIfRegistrationAllowed>
 
+function replyComment(parent_id, author) {
+    showDocumentElement('comment-form-reply');
+    
+    var checkbox = document.getElementById('comment-reply');
+
+    // Clear the current label but NOT our checkbox!
+    var label = document.getElementById('comment-reply-label');
+    for(var i = 1; i < label.childNodes.length; i++) {
+        label.removeChild(label.childNodes[i]);
+    }
+    
+    // Populate label with new values
+    var reply_text = document.createTextNode(' <__trans phrase="Replying to"> ');
+    label.appendChild(reply_text);
+
+    var anchor = document.createElement('a');
+    anchor.setAttribute('href', '#comment-' + parent_id);
+    anchor.innerHTML = author;
+    label.appendChild(anchor);
+    
+    checkbox.value = parent_id; 
+    checkbox.setAttribute('checked', true);
+    checkbox.focus();
+    
+    setCommentParentID();
+}
+
+function setCommentParentID() {
+    var checkbox = document.getElementById('comment-reply');
+    var parent_id_field = document.getElementById('comment-parent-id');
+    var pid = 0;
+    
+    if(checkbox.checked == true)
+        pid = checkbox.value;
+    
+    parent_id_field.value = pid;
+}
+
 
 // Copyright (c) 1996-1997 Athenia Associates.
Index: /branches/release-32/lib/MT/Template/ContextHandlers.pm
===================================================================
--- /branches/release-32/lib/MT/Template/ContextHandlers.pm (revision 1554)
+++ /branches/release-32/lib/MT/Template/ContextHandlers.pm (revision 1561)
@@ -377,4 +377,6 @@
             CommentOrderNumber => \&_hdlr_comment_order_num,
             CommentDate => \&_hdlr_comment_date,
+            CommentParentID => \&_hdlr_comment_parent_id,
+            CommentReplyLink => \&_hdlr_comment_reply_link,
             CommentPreviewAuthor => \&_hdlr_comment_author,
             CommentPreviewIP => \&_hdlr_comment_ip,
@@ -5280,4 +5282,24 @@
 }
 
+sub _hdlr_comment_reply_link {
+    my($ctx, $args) = @_;
+    my $comment = $ctx->stash('comment') or
+        return  $ctx->_no_comment_error('MTCommentReplyLink');
+
+    my $label = $args->{label} || $args->{text} || MT->translate('Reply');
+    my $comment_author = MT::Util::encode_js($comment->author);
+
+    return sprintf(qq(<a title="%s" href="javascript:void(0);" onclick="replyComment(%d, '%s')">%s</a>),
+                   $label, $comment->id, $comment_author, $label);
+}
+
+sub _hdlr_comment_parent_id {
+    my $args = $_[1];
+    my $c = $_[0]->stash('comment')
+        or return $_[0]->_no_comment_error('MTCommentParentID');
+    my $id = $c->parent_id || 0;
+    $args && $args->{pad} ? (sprintf "%06d", $id) : $id;
+}
+
 sub _hdlr_comment_replies {
     my($ctx, $args, $cond) = @_;
Index: /branches/release-32/lib/MT/App/Comments.pm
===================================================================
--- /branches/release-32/lib/MT/App/Comments.pm (revision 1394)
+++ /branches/release-32/lib/MT/App/Comments.pm (revision 1561)
@@ -1269,5 +1269,5 @@
         # published for this entry
         my $parent_comment = MT::Comment->load( $parent_id );
-        if ($parent_comment && $parent_comment->entry_id == $entry->id) {
+        if ($parent_comment && $parent->is_published() && $parent_comment->entry_id == $entry->id) {
             $comment->parent_id( $parent_id );
         }
