This is a template for creating boxes that automatically collapse. But it is a rather complicated template.