Replaced inline JavaScript in wrapper

See #3838

Not sure if media/mod_wrapper is a good location for shared scripts. Alternative?