Update index.htm

moved some JS code from HTM file to standalone JS file