$(function() {
	var default_closed_height = 50;
	
	var conversation = {
		set_expend_event_handler: function(){
			$('.conversation-open-close-box').click(function(){
				var innerheight = 0;
				$(this).parent().find('.expand p').each(function(){
					innerheight+=$(this).outerHeight();
				});
				var container = $(this).parent().find('.expand');
				if(container.height() == default_closed_height){
					container.css({overflow:''});
					container.animate({ 
						height: innerheight
					}, 500 );
					$(this).find('a').attr('title','Close the box');
					$(this).find('a img').attr('alt','Close the box');
					$(this).find('a img').attr('src','./images/conversation-close-box.gif');
				}
				else{
					container.css({overflow:'hidden'});
					container.animate({ 
						height: default_closed_height
					}, 500 );
					$(this).find('a').attr('title','Open the box');
					$(this).find('a img').attr('alt','Open the box');
					$(this).find('a img').attr('src','./images/conversation-expand-box.gif');
				}
				
				return false;
			});
		}
	};
	
	conversation.set_expend_event_handler();
	$('.conversation-open-close-box').parent().find('.expand').css({height:'50px', overflow:'hidden'});
	$('.conversation-open-close-box').css('visibility','visible');
});