Use wp_localize_script, AmazonJS should work in footer.
Fixed media-uppload