Moved javascript code from a HTML file