Pulled out the javascript into a separate file

Pulled out the javascript into a separate file