jquery to hide or show comments if no comments not working
<p>i have a status update system in which when a user updates a status people can comment. But the problem is when i click on reply the comment box opens and closes on its own even without giving time to write anything .</p>

<p>there is one code which check when we do a status update and if there is comments (which obviously wont be as we just updated the status it would just hide the commentbox ). and it is somehow effecting the opening of any other clicked comment box . when i remove <code>var t = setTimeout("BpActivityReply()", 325);</code> this line the comment box opens fine but when a new status update it pre opens which should not happen. can anyone suggest where i am wrong</p>

<pre><code> if (typeof jq == "function") {
jq("#content").ajaxComplete(function (evt, request, settings) {

    var t = setTimeout("BpActivityReply()", 325);
});
jq("div.activity").click(function (event) {
    var target = jq(event.target);
    if (target.hasClass("acomment-reply") || target.parent().hasClass("acomment-reply")) {
        BpActivityReply();
        if (target.parent().hasClass("acomment-reply")) {
            target = target.parent();
        }
        var id = target.attr("id");
        ids = id.split("-");
        var form = jq("#ac-form-" + ids[2]);
        form.parents(".activity-replies").slideDown(200);
        return false;
    }
});
jq(document).keydown(function (e) {
    e = e || window.event;
    if (e.target) {
        element = e.target;
    } else {
        if (e.srcElement) {
            element = e.srcElement;
        }
    }
    if (element.nodeType == 3) {
        element = element.parentNode;
    }
    if (e.ctrlKey == true || e.altKey == true || e.metaKey == true) {
        return;
    }
    var keyCode = (e.keyCode) ? e.keyCode : e.which;
    if (keyCode == 27) {
        if (element.tagName == "TEXTAREA") {
            if (jq(element).hasClass("ac-input")) {
                formContainer = jq(element).parent().parent().parents(".activity-replies");
            }
            if (formContainer.find("ul").length &lt;= 0) {
                formContainer.slideUp(200);
            }
        }
    }
});
BpActivityReply();
 }





function BpActivityReply() {
    jQuery(".activity-replies").each(function () {
        hasComments = jQuery(this).find("ul").first().children("li:visible");
        if (hasComments.length &lt;= 0) {
            jQuery(this).css("display", "none");
        } else {
            jQuery(this).slideDown(200);
        }
    }); 
</code></pre>
