Migrate asynchronous functions to jQuery

Initial changes for jQuery support, retaining all other previous code
structure. Resource loading must be moved out of Graphics.