/* 
// autoloader.js
// authour: Adam Chow -  adamchow2326@yahoo.com.au
// created date: 28/07/2011
// version: 1.2
// jQuery plugins:
//		$.fn.autoLoader
*/
(function(b){b.fn.autoLoader=function(d,h){return this.each(function(){function i(a){function m(e){e&&b.each(a.loadScript,function(){b.ajax({type:"GET",url:this,dataType:"script",cache:!0,success:function(){l++;if(l===j){f++;var c=a.complete;c&&b.isFunction(c)&&(h?k.push(c):c());if(g===f&&h){for(var c=0,e=k.length;c<e;c++)k[c]();b.isFunction(h)&&h()}g>f&&i(d[f])}}})})}var j=0,l=0,e=[];if(a.test)a.complete&&b.isFunction(a.complete)&&a.complete();else if(b.trim(a.loadScript)!=="")b.isArray(a.loadScript)? j=a.loadScript.length:(e.push(a.loadScript.toString()),a.loadScript=e,j=e.length),m(!0)}var g=0,f=0,k=[];if(d)if(b.isArray(d))g=d.length,g>f&&i(d[f]);else if(typeof d==="object")g=1,i(d);else throw Error("testCase is not in correct format.");})}})(jQuery);
