refactored javascript code for scroll to end of page event to my.js