pulled javascript out into own file.  Removed bug with having to click a button twice to send commands