The X12 (version 5040) Implementation Guides have been posted to the CBP website: http://www.cbp.gov/xp/cgov/trade/automated/automated_systems/ams/
X12 (Version 5040) Implementation Guidelines