Update index.html

moved js function to external file and moved script variables to the head