Majorly cleaned up javascript.

Added restart and play pause functionality.