refactored javascript code for end of page ajax processing to my.js