Altered method used for detecting AMD...also added check for CommonJS loading.

Used https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js as reference.