﻿function comment_reply(commentId)
{
    // write the reply form and show it
    
    $("#comment"+commentId+" > div > .replyPlaceHolder").empty();
    $("#comment"+commentId+" > div > .replyPlaceHolder").append(reply_form_html(commentId));
    
    // slide down the form, then focus the text area
    $("#comment"+commentId+" > div > .replyPlaceHolder > .replyForm").slideDown("slow", function () {  setTimeout( function() { $("#textArea"+commentId)[0].focus();}, 200) } );
    
    document.getElementById("textArea"+commentId).focus();
    
    // 
    $("#comment"+commentId+" > div > div > .replyButton").fadeOut();
   
}

function reply_form_html(commentId)
{
    // function send_reply defined in UploadCommentPanel.ascx

    return '<div class="replyForm" style="display:none;"><table class="Table"><tr><td>Name:</td><td><input type="text" id="inputName' + commentId + '" /></td></tr><tr><td>Email: </td><td><input type="text" id="inputEmail' + commentId + '" /></td></tr><tr><td>Comment:</td><td><textarea class="commenttextarea" id="textArea' + commentId + '"></textarea></td></tr></table><div style="padding:5px;"><div class="right"><a href="javascript:cancel_reply(' +
    commentId+');">cancel</a>&nbsp;<a href="javascript:send_reply('+
    commentId+');">add reply</a></div><br class="clearer"/></div></div>';
}

function cancel_reply(commentId)
{
    $("#comment"+commentId+" > div > .replyPlaceHolder > .replyForm").slideUp();
    $("#comment"+commentId+" > div > div > .replyButton").fadeIn();
}