 $(document).ready(
		function(){ 

			/* hide comments on page load */
	    	$(".comment_is_child").css('display','none');
	    	 
			 $("a")
			   .filter(".collapse-comment")
			     .click(function(event){
			    	 event.preventDefault();
			    	 
				    var $id = $(this).attr("id");
			    	if(!$(this).hasClass('hide_all')) {
			    		
			    		$(this).addClass('hide_all');
				    	$(".comment-parent-is-"+$id).css('display', 'block');
			    	}
			    	else {
			    		$(this).removeClass('hide_all');
			    		hide_my_children($id);
			    	}
			     })
			   .end()

			.filter(".collapse-all-descendants")
			     .click(function(event){
			    	 event.preventDefault();

			    	var $topid =  $(this).attr("top_one_id");
			    	$('#'+$topid).removeClass('hide_all');
			   		hide_my_children($topid);
			     })
			   .end()
	
			 .filter(".show-all-comments")
			     .click(function(event){
			    	 event.preventDefault();
    	 
					 var $my = $(this).attr("id");
					 var $mid = $my.substr(2);
				 
					 show_my_children($mid);
					 
					 
					 /*
					 $('div.top_one_id_is_'+$mid).each(function vv(){	 
						 $(this).css('display', 'block');
						 
						 var $ty = $(this).attr('id');
						 var $r= $ty.substr(1);
						 $('#'+$r).addClass('hide_all');
					 })
					 
					 */
			     })
			   .end()   
			   			   
			   
		function hide_my_children($id){
				 //hide direct children
				 $(".comment-parent-is-"+$id).css('display', 'none');

				 var $my = $(".comment-parent-is-"+$id).attr("id");
				 var $mid = $my.substr(1);

				 $('#'+$mid).removeClass('hide_all');
				 	hide_my_children($mid);
		}
			 
	function show_my_children($id){
		$('div.comment-parent-is-'+$id).each(function bvbv(){
			$(this).css('display', 'block');
			 $('#'+$id).addClass('hide_all');
			 
			 var $my = $(this).attr("id");
			 var $mid = $my.substr(1);
			 
			 var $ty = $(this).attr('id');
			 var $r= $ty.substr(1);
			 $('#'+$r).addClass('hide_all');
			 
			 show_my_children($mid);
			 
			 
			
		})
		
		
	}
	}
 );


