added a new javascript file

Removed javascript from html file, and added it to a new script.js file,
and added comments that explains the code