Added Trails option and JS closure

Added a flag to show trails for the pendulum.  Also wrapped pendulum.js in a closure (can improve performance).