Refactored media metabox javascript to allow for n media metaboxes