Moved JS code to separate file.  Trying to decouple functionality from test page.  Not working yet.