$(document).ready(function(){
  
  $('.blogComments').each(function() {
    $(this).hide();
  });
  
  $('.commentcount').click(function(e) {
    
    
    
    e.preventDefault();
    
    var comments=$(this).parents('.commentSection').children('.blogComments');
    
    if(comments.is(':hidden')){
      comments.slideDown();
      $(this).children('.expandComments').children('span').html('Hide');
    }else{
      comments.slideUp();
      $(this).children('.expandComments').children('span').html('Show');
    }
    
  });

  $('.commentform').each(function() {
    var originalHeight=$(this).height();
    $(this).css('height','14px');
    var form=$(this);
    
    $(this).children('.leaveComment').click(function() {
      if(form.height() == originalHeight) {
        // Contract
        form.animate({ height: 14 + "px"},200);
      }else{
        // Expand
        form.animate({ height: originalHeight + "px"},200);
      }
    });
    
  });
  
});