Refactored the inline javascript for scrolling into a seperate file