Rewrote some of the javascript concerned with margin classes and titles
according to DRY principle.

Made buttons display properly in sidebar.
TextInfo button now works, others don't atm.