﻿function bind_activityfeed_event() {
    
    // write comment link event
    $('.aActivityFeedWriteComment').live('click', function() {
        $(this).next().show();
        $(this).hide();
        $(this).next().focus();
        $(this).next().val('');
    });

    $('.txtActivityFeedComment').focus(function() {
        //alert('hi');
        $(this).val('');
        $(this).css('color', '#999999');
    });

    $('.txtActivityFeedComment').blur(function() {
        $(this).css('color', '#cccccc');
        $(this).val('Write a comment...');
    });


    $('.txtActivityFeedComment').bind('keypress', function(event) {
        if (event.keyCode == '13') {
            //alert('hi');
            if (typeof (WebService) != "undefined") {
                trackingid = parseInt($(this).next().text());
                $('#spanProgress_' + trackingid).show();
                WebService.WriteActivityComment(trackingid, $(this).val(), OnWriteCommentSuccess, OnWriteCommentFail);
                $(this).val('');
            }

            return false;
        }
        else {
        }
    });

    
    $('.aActivityFeedCommentCount').each(function() {
        //alert($(this).find('.count').text());
        var cnt = parseInt($(this).find('.count').text());
        if (cnt <= 0)
            $(this).hide();
        else
            $(this).show();
    });
}
