added implementation for AMD's define and require methods, including dependency chain detection and injection, define and wait queues and automatic script imports.