refactored javascript in pages and modified handlers to support messaging