Replaced resize.js (Resize Events) with custom alternative (new code) integrated into pe-ap.js to resolve #974 and reduce the number of http transfers.

* Also reduced the number of $('html'), $(document) and $(window) calls (cached in variables for reuse).