]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/yui/build/yuiloader/yuiloader.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / yui / build / yuiloader / yuiloader.js
1 /*
2 Copyright (c) 2011, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 2.9.0
6 */
7 /**
8  * The YAHOO object is the single global object used by YUI Library.  It
9  * contains utility function for setting up namespaces, inheritance, and
10  * logging.  YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces
11  * created automatically for and used by the library.
12  * @module yahoo
13  * @title  YAHOO Global
14  */
15
16 /**
17  * YAHOO_config is not included as part of the library.  Instead it is an
18  * object that can be defined by the implementer immediately before
19  * including the YUI library.  The properties included in this object
20  * will be used to configure global properties needed as soon as the
21  * library begins to load.
22  * @class YAHOO_config
23  * @static
24  */
25
26 /**
27  * A reference to a function that will be executed every time a YAHOO module
28  * is loaded.  As parameter, this function will receive the version
29  * information for the module. See <a href="YAHOO.env.html#getVersion">
30  * YAHOO.env.getVersion</a> for the description of the version data structure.
31  * @property listener
32  * @type Function
33  * @static
34  * @default undefined
35  */
36
37 /**
38  * Set to true if the library will be dynamically loaded after window.onload.
39  * Defaults to false
40  * @property injecting
41  * @type boolean
42  * @static
43  * @default undefined
44  */
45
46 /**
47  * Instructs the yuiloader component to dynamically load yui components and
48  * their dependencies.  See the yuiloader documentation for more information
49  * about dynamic loading
50  * @property load
51  * @static
52  * @default undefined
53  * @see yuiloader
54  */
55
56 /**
57  * Forces the use of the supplied locale where applicable in the library
58  * @property locale
59  * @type string
60  * @static
61  * @default undefined
62  */
63
64 if (typeof YAHOO == "undefined" || !YAHOO) {
65     /**
66      * The YAHOO global namespace object.  If YAHOO is already defined, the
67      * existing YAHOO object will not be overwritten so that defined
68      * namespaces are preserved.
69      * @class YAHOO
70      * @static
71      */
72     var YAHOO = {};
73 }
74
75 /**
76  * Returns the namespace specified and creates it if it doesn't exist
77  * <pre>
78  * YAHOO.namespace("property.package");
79  * YAHOO.namespace("YAHOO.property.package");
80  * </pre>
81  * Either of the above would create YAHOO.property, then
82  * YAHOO.property.package
83  *
84  * Be careful when naming packages. Reserved words may work in some browsers
85  * and not others. For instance, the following will fail in Safari:
86  * <pre>
87  * YAHOO.namespace("really.long.nested.namespace");
88  * </pre>
89  * This fails because "long" is a future reserved word in ECMAScript
90  *
91  * For implementation code that uses YUI, do not create your components
92  * in the namespaces defined by YUI (
93  * <code>YAHOO.util</code>,
94  * <code>YAHOO.widget</code>,
95  * <code>YAHOO.lang</code>,
96  * <code>YAHOO.tool</code>,
97  * <code>YAHOO.example</code>,
98  * <code>YAHOO.env</code>) -- create your own namespace (e.g., 'companyname').
99  *
100  * @method namespace
101  * @static
102  * @param  {String*} arguments 1-n namespaces to create
103  * @return {Object}  A reference to the last namespace object created
104  */
105 YAHOO.namespace = function() {
106     var a=arguments, o=null, i, j, d;
107     for (i=0; i<a.length; i=i+1) {
108         d=(""+a[i]).split(".");
109         o=YAHOO;
110
111         // YAHOO is implied, so it is ignored if it is included
112         for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) {
113             o[d[j]]=o[d[j]] || {};
114             o=o[d[j]];
115         }
116     }
117
118     return o;
119 };
120
121 /**
122  * Uses YAHOO.widget.Logger to output a log message, if the widget is
123  * available.
124  * Note: LogReader adds the message, category, and source to the DOM as HTML.
125  *
126  * @method log
127  * @static
128  * @param  {HTML}  msg  The message to log.
129  * @param  {HTML}  cat  The log category for the message.  Default
130  *                        categories are "info", "warn", "error", time".
131  *                        Custom categories can be used as well. (opt)
132  * @param  {HTML}  src  The source of the the message (opt)
133  * @return {Boolean}      True if the log operation was successful.
134  */
135 YAHOO.log = function(msg, cat, src) {
136     var l=YAHOO.widget.Logger;
137     if(l && l.log) {
138         return l.log(msg, cat, src);
139     } else {
140         return false;
141     }
142 };
143
144 /**
145  * Registers a module with the YAHOO object
146  * @method register
147  * @static
148  * @param {String}   name    the name of the module (event, slider, etc)
149  * @param {Function} mainClass a reference to class in the module.  This
150  *                             class will be tagged with the version info
151  *                             so that it will be possible to identify the
152  *                             version that is in use when multiple versions
153  *                             have loaded
154  * @param {Object}   data      metadata object for the module.  Currently it
155  *                             is expected to contain a "version" property
156  *                             and a "build" property at minimum.
157  */
158 YAHOO.register = function(name, mainClass, data) {
159     var mods = YAHOO.env.modules, m, v, b, ls, i;
160
161     if (!mods[name]) {
162         mods[name] = {
163             versions:[],
164             builds:[]
165         };
166     }
167
168     m  = mods[name];
169     v  = data.version;
170     b  = data.build;
171     ls = YAHOO.env.listeners;
172
173     m.name = name;
174     m.version = v;
175     m.build = b;
176     m.versions.push(v);
177     m.builds.push(b);
178     m.mainClass = mainClass;
179
180     // fire the module load listeners
181     for (i=0;i<ls.length;i=i+1) {
182         ls[i](m);
183     }
184     // label the main class
185     if (mainClass) {
186         mainClass.VERSION = v;
187         mainClass.BUILD = b;
188     } else {
189         YAHOO.log("mainClass is undefined for module " + name, "warn");
190     }
191 };
192
193 /**
194  * YAHOO.env is used to keep track of what is known about the YUI library and
195  * the browsing environment
196  * @class YAHOO.env
197  * @static
198  */
199 YAHOO.env = YAHOO.env || {
200
201     /**
202      * Keeps the version info for all YUI modules that have reported themselves
203      * @property modules
204      * @type Object[]
205      */
206     modules: [],
207
208     /**
209      * List of functions that should be executed every time a YUI module
210      * reports itself.
211      * @property listeners
212      * @type Function[]
213      */
214     listeners: []
215 };
216
217 /**
218  * Returns the version data for the specified module:
219  *      <dl>
220  *      <dt>name:</dt>      <dd>The name of the module</dd>
221  *      <dt>version:</dt>   <dd>The version in use</dd>
222  *      <dt>build:</dt>     <dd>The build number in use</dd>
223  *      <dt>versions:</dt>  <dd>All versions that were registered</dd>
224  *      <dt>builds:</dt>    <dd>All builds that were registered.</dd>
225  *      <dt>mainClass:</dt> <dd>An object that was was stamped with the
226  *                 current version and build. If
227  *                 mainClass.VERSION != version or mainClass.BUILD != build,
228  *                 multiple versions of pieces of the library have been
229  *                 loaded, potentially causing issues.</dd>
230  *       </dl>
231  *
232  * @method getVersion
233  * @static
234  * @param {String}  name the name of the module (event, slider, etc)
235  * @return {Object} The version info
236  */
237 YAHOO.env.getVersion = function(name) {
238     return YAHOO.env.modules[name] || null;
239 };
240
241 /**
242  * Do not fork for a browser if it can be avoided.  Use feature detection when
243  * you can.  Use the user agent as a last resort.  YAHOO.env.ua stores a version
244  * number for the browser engine, 0 otherwise.  This value may or may not map
245  * to the version number of the browser using the engine.  The value is
246  * presented as a float so that it can easily be used for boolean evaluation
247  * as well as for looking for a particular range of versions.  Because of this,
248  * some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9
249  * reports 1.8).
250  * @class YAHOO.env.ua
251  * @static
252  */
253
254 /**
255  * parses a user agent string (or looks for one in navigator to parse if
256  * not supplied).
257  * @method parseUA
258  * @since 2.9.0
259  * @static
260  */
261 YAHOO.env.parseUA = function(agent) {
262
263         var numberify = function(s) {
264             var c = 0;
265             return parseFloat(s.replace(/\./g, function() {
266                 return (c++ == 1) ? '' : '.';
267             }));
268         },
269
270         nav = navigator,
271
272         o = {
273
274         /**
275          * Internet Explorer version number or 0.  Example: 6
276          * @property ie
277          * @type float
278          * @static
279          */
280         ie: 0,
281
282         /**
283          * Opera version number or 0.  Example: 9.2
284          * @property opera
285          * @type float
286          * @static
287          */
288         opera: 0,
289
290         /**
291          * Gecko engine revision number.  Will evaluate to 1 if Gecko
292          * is detected but the revision could not be found. Other browsers
293          * will be 0.  Example: 1.8
294          * <pre>
295          * Firefox 1.0.0.4: 1.7.8   <-- Reports 1.7
296          * Firefox 1.5.0.9: 1.8.0.9 <-- 1.8
297          * Firefox 2.0.0.3: 1.8.1.3 <-- 1.81
298          * Firefox 3.0   <-- 1.9
299          * Firefox 3.5   <-- 1.91
300          * </pre>
301          * @property gecko
302          * @type float
303          * @static
304          */
305         gecko: 0,
306
307         /**
308          * AppleWebKit version.  KHTML browsers that are not WebKit browsers
309          * will evaluate to 1, other browsers 0.  Example: 418.9
310          * <pre>
311          * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
312          *                                   latest available for Mac OSX 10.3.
313          * Safari 2.0.2:         416     <-- hasOwnProperty introduced
314          * Safari 2.0.4:         418     <-- preventDefault fixed
315          * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
316          *                                   different versions of webkit
317          * Safari 2.0.4 (419.3): 419     <-- Tiger installations that have been
318          *                                   updated, but not updated
319          *                                   to the latest patch.
320          * Webkit 212 nightly:   522+    <-- Safari 3.0 precursor (with native
321          * SVG and many major issues fixed).
322          * Safari 3.0.4 (523.12) 523.12  <-- First Tiger release - automatic
323          * update from 2.x via the 10.4.11 OS patch.
324          * Webkit nightly 1/2008:525+    <-- Supports DOMContentLoaded event.
325          *                                   yahoo.com user agent hack removed.
326          * </pre>
327          * http://en.wikipedia.org/wiki/Safari_version_history
328          * @property webkit
329          * @type float
330          * @static
331          */
332         webkit: 0,
333
334         /**
335          * Chrome will be detected as webkit, but this property will also
336          * be populated with the Chrome version number
337          * @property chrome
338          * @type float
339          * @static
340          */
341         chrome: 0,
342
343         /**
344          * The mobile property will be set to a string containing any relevant
345          * user agent information when a modern mobile browser is detected.
346          * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
347          * devices with the WebKit-based browser, and Opera Mini.
348          * @property mobile
349          * @type string
350          * @static
351          */
352         mobile: null,
353
354         /**
355          * Adobe AIR version number or 0.  Only populated if webkit is detected.
356          * Example: 1.0
357          * @property air
358          * @type float
359          */
360         air: 0,
361         /**
362          * Detects Apple iPad's OS version
363          * @property ipad
364          * @type float
365          * @static
366          */
367         ipad: 0,
368         /**
369          * Detects Apple iPhone's OS version
370          * @property iphone
371          * @type float
372          * @static
373          */
374         iphone: 0,
375         /**
376          * Detects Apples iPod's OS version
377          * @property ipod
378          * @type float
379          * @static
380          */
381         ipod: 0,
382         /**
383          * General truthy check for iPad, iPhone or iPod
384          * @property ios
385          * @type float
386          * @static
387          */
388         ios: null,
389         /**
390          * Detects Googles Android OS version
391          * @property android
392          * @type float
393          * @static
394          */
395         android: 0,
396         /**
397          * Detects Palms WebOS version
398          * @property webos
399          * @type float
400          * @static
401          */
402         webos: 0,
403
404         /**
405          * Google Caja version number or 0.
406          * @property caja
407          * @type float
408          */
409         caja: nav && nav.cajaVersion,
410
411         /**
412          * Set to true if the page appears to be in SSL
413          * @property secure
414          * @type boolean
415          * @static
416          */
417         secure: false,
418
419         /**
420          * The operating system.  Currently only detecting windows or macintosh
421          * @property os
422          * @type string
423          * @static
424          */
425         os: null
426
427     },
428
429     ua = agent || (navigator && navigator.userAgent),
430
431     loc = window && window.location,
432
433     href = loc && loc.href,
434
435     m;
436
437     o.secure = href && (href.toLowerCase().indexOf("https") === 0);
438
439     if (ua) {
440
441         if ((/windows|win32/i).test(ua)) {
442             o.os = 'windows';
443         } else if ((/macintosh/i).test(ua)) {
444             o.os = 'macintosh';
445         } else if ((/rhino/i).test(ua)) {
446             o.os = 'rhino';
447         }
448
449         // Modern KHTML browsers should qualify as Safari X-Grade
450         if ((/KHTML/).test(ua)) {
451             o.webkit = 1;
452         }
453         // Modern WebKit browsers are at least X-Grade
454         m = ua.match(/AppleWebKit\/([^\s]*)/);
455         if (m && m[1]) {
456             o.webkit = numberify(m[1]);
457
458             // Mobile browser check
459             if (/ Mobile\//.test(ua)) {
460                 o.mobile = 'Apple'; // iPhone or iPod Touch
461
462                 m = ua.match(/OS ([^\s]*)/);
463                 if (m && m[1]) {
464                     m = numberify(m[1].replace('_', '.'));
465                 }
466                 o.ios = m;
467                 o.ipad = o.ipod = o.iphone = 0;
468
469                 m = ua.match(/iPad|iPod|iPhone/);
470                 if (m && m[0]) {
471                     o[m[0].toLowerCase()] = o.ios;
472                 }
473             } else {
474                 m = ua.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/);
475                 if (m) {
476                     // Nokia N-series, Android, webOS, ex: NokiaN95
477                     o.mobile = m[0];
478                 }
479                 if (/webOS/.test(ua)) {
480                     o.mobile = 'WebOS';
481                     m = ua.match(/webOS\/([^\s]*);/);
482                     if (m && m[1]) {
483                         o.webos = numberify(m[1]);
484                     }
485                 }
486                 if (/ Android/.test(ua)) {
487                     o.mobile = 'Android';
488                     m = ua.match(/Android ([^\s]*);/);
489                     if (m && m[1]) {
490                         o.android = numberify(m[1]);
491                     }
492
493                 }
494             }
495
496             m = ua.match(/Chrome\/([^\s]*)/);
497             if (m && m[1]) {
498                 o.chrome = numberify(m[1]); // Chrome
499             } else {
500                 m = ua.match(/AdobeAIR\/([^\s]*)/);
501                 if (m) {
502                     o.air = m[0]; // Adobe AIR 1.0 or better
503                 }
504             }
505         }
506
507         if (!o.webkit) { // not webkit
508 // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
509             m = ua.match(/Opera[\s\/]([^\s]*)/);
510             if (m && m[1]) {
511                 o.opera = numberify(m[1]);
512                 m = ua.match(/Version\/([^\s]*)/);
513                 if (m && m[1]) {
514                     o.opera = numberify(m[1]); // opera 10+
515                 }
516                 m = ua.match(/Opera Mini[^;]*/);
517                 if (m) {
518                     o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
519                 }
520             } else { // not opera or webkit
521                 m = ua.match(/MSIE\s([^;]*)/);
522                 if (m && m[1]) {
523                     o.ie = numberify(m[1]);
524                 } else { // not opera, webkit, or ie
525                     m = ua.match(/Gecko\/([^\s]*)/);
526                     if (m) {
527                         o.gecko = 1; // Gecko detected, look for revision
528                         m = ua.match(/rv:([^\s\)]*)/);
529                         if (m && m[1]) {
530                             o.gecko = numberify(m[1]);
531                         }
532                     }
533                 }
534             }
535         }
536     }
537
538     return o;
539 };
540
541 YAHOO.env.ua = YAHOO.env.parseUA();
542
543 /*
544  * Initializes the global by creating the default namespaces and applying
545  * any new configuration information that is detected.  This is the setup
546  * for env.
547  * @method init
548  * @static
549  * @private
550  */
551 (function() {
552     YAHOO.namespace("util", "widget", "example");
553     /*global YAHOO_config*/
554     if ("undefined" !== typeof YAHOO_config) {
555         var l=YAHOO_config.listener, ls=YAHOO.env.listeners,unique=true, i;
556         if (l) {
557             // if YAHOO is loaded multiple times we need to check to see if
558             // this is a new config object.  If it is, add the new component
559             // load listener to the stack
560             for (i=0; i<ls.length; i++) {
561                 if (ls[i] == l) {
562                     unique = false;
563                     break;
564                 }
565             }
566
567             if (unique) {
568                 ls.push(l);
569             }
570         }
571     }
572 })();
573 /**
574  * Provides the language utilites and extensions used by the library
575  * @class YAHOO.lang
576  */
577 YAHOO.lang = YAHOO.lang || {};
578
579 (function() {
580
581
582 var L = YAHOO.lang,
583
584     OP = Object.prototype,
585     ARRAY_TOSTRING = '[object Array]',
586     FUNCTION_TOSTRING = '[object Function]',
587     OBJECT_TOSTRING = '[object Object]',
588     NOTHING = [],
589
590     HTML_CHARS = {
591         '&': '&amp;',
592         '<': '&lt;',
593         '>': '&gt;',
594         '"': '&quot;',
595         "'": '&#x27;',
596         '/': '&#x2F;',
597         '`': '&#x60;'
598     },
599
600     // ADD = ["toString", "valueOf", "hasOwnProperty"],
601     ADD = ["toString", "valueOf"],
602
603     OB = {
604
605     /**
606      * Determines wheather or not the provided object is an array.
607      * @method isArray
608      * @param {any} o The object being testing
609      * @return {boolean} the result
610      */
611     isArray: function(o) {
612         return OP.toString.apply(o) === ARRAY_TOSTRING;
613     },
614
615     /**
616      * Determines whether or not the provided object is a boolean
617      * @method isBoolean
618      * @param {any} o The object being testing
619      * @return {boolean} the result
620      */
621     isBoolean: function(o) {
622         return typeof o === 'boolean';
623     },
624
625     /**
626      * Determines whether or not the provided object is a function.
627      * Note: Internet Explorer thinks certain functions are objects:
628      *
629      * var obj = document.createElement("object");
630      * YAHOO.lang.isFunction(obj.getAttribute) // reports false in IE
631      *
632      * var input = document.createElement("input"); // append to body
633      * YAHOO.lang.isFunction(input.focus) // reports false in IE
634      *
635      * You will have to implement additional tests if these functions
636      * matter to you.
637      *
638      * @method isFunction
639      * @param {any} o The object being testing
640      * @return {boolean} the result
641      */
642     isFunction: function(o) {
643         return (typeof o === 'function') || OP.toString.apply(o) === FUNCTION_TOSTRING;
644     },
645
646     /**
647      * Determines whether or not the provided object is null
648      * @method isNull
649      * @param {any} o The object being testing
650      * @return {boolean} the result
651      */
652     isNull: function(o) {
653         return o === null;
654     },
655
656     /**
657      * Determines whether or not the provided object is a legal number
658      * @method isNumber
659      * @param {any} o The object being testing
660      * @return {boolean} the result
661      */
662     isNumber: function(o) {
663         return typeof o === 'number' && isFinite(o);
664     },
665
666     /**
667      * Determines whether or not the provided object is of type object
668      * or function
669      * @method isObject
670      * @param {any} o The object being testing
671      * @return {boolean} the result
672      */
673     isObject: function(o) {
674 return (o && (typeof o === 'object' || L.isFunction(o))) || false;
675     },
676
677     /**
678      * Determines whether or not the provided object is a string
679      * @method isString
680      * @param {any} o The object being testing
681      * @return {boolean} the result
682      */
683     isString: function(o) {
684         return typeof o === 'string';
685     },
686
687     /**
688      * Determines whether or not the provided object is undefined
689      * @method isUndefined
690      * @param {any} o The object being testing
691      * @return {boolean} the result
692      */
693     isUndefined: function(o) {
694         return typeof o === 'undefined';
695     },
696
697
698     /**
699      * IE will not enumerate native functions in a derived object even if the
700      * function was overridden.  This is a workaround for specific functions
701      * we care about on the Object prototype.
702      * @property _IEEnumFix
703      * @param {Function} r  the object to receive the augmentation
704      * @param {Function} s  the object that supplies the properties to augment
705      * @static
706      * @private
707      */
708     _IEEnumFix: (YAHOO.env.ua.ie) ? function(r, s) {
709             var i, fname, f;
710             for (i=0;i<ADD.length;i=i+1) {
711
712                 fname = ADD[i];
713                 f = s[fname];
714
715                 if (L.isFunction(f) && f!=OP[fname]) {
716                     r[fname]=f;
717                 }
718             }
719     } : function(){},
720
721     /**
722      * <p>
723      * Returns a copy of the specified string with special HTML characters
724      * escaped. The following characters will be converted to their
725      * corresponding character entities:
726      * <code>&amp; &lt; &gt; &quot; &#x27; &#x2F; &#x60;</code>
727      * </p>
728      *
729      * <p>
730      * This implementation is based on the
731      * <a href="http://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet">OWASP
732      * HTML escaping recommendations</a>. In addition to the characters
733      * in the OWASP recommendation, we also escape the <code>&#x60;</code>
734      * character, since IE interprets it as an attribute delimiter when used in
735      * innerHTML.
736      * </p>
737      *
738      * @method escapeHTML
739      * @param {String} html String to escape.
740      * @return {String} Escaped string.
741      * @static
742      * @since 2.9.0
743      */
744     escapeHTML: function (html) {
745         return html.replace(/[&<>"'\/`]/g, function (match) {
746             return HTML_CHARS[match];
747         });
748     },
749
750     /**
751      * Utility to set up the prototype, constructor and superclass properties to
752      * support an inheritance strategy that can chain constructors and methods.
753      * Static members will not be inherited.
754      *
755      * @method extend
756      * @static
757      * @param {Function} subc   the object to modify
758      * @param {Function} superc the object to inherit
759      * @param {Object} overrides  additional properties/methods to add to the
760      *                              subclass prototype.  These will override the
761      *                              matching items obtained from the superclass
762      *                              if present.
763      */
764     extend: function(subc, superc, overrides) {
765         if (!superc||!subc) {
766             throw new Error("extend failed, please check that " +
767                             "all dependencies are included.");
768         }
769         var F = function() {}, i;
770         F.prototype=superc.prototype;
771         subc.prototype=new F();
772         subc.prototype.constructor=subc;
773         subc.superclass=superc.prototype;
774         if (superc.prototype.constructor == OP.constructor) {
775             superc.prototype.constructor=superc;
776         }
777
778         if (overrides) {
779             for (i in overrides) {
780                 if (L.hasOwnProperty(overrides, i)) {
781                     subc.prototype[i]=overrides[i];
782                 }
783             }
784
785             L._IEEnumFix(subc.prototype, overrides);
786         }
787     },
788
789     /**
790      * Applies all properties in the supplier to the receiver if the
791      * receiver does not have these properties yet.  Optionally, one or
792      * more methods/properties can be specified (as additional
793      * parameters).  This option will overwrite the property if receiver
794      * has it already.  If true is passed as the third parameter, all
795      * properties will be applied and _will_ overwrite properties in
796      * the receiver.
797      *
798      * @method augmentObject
799      * @static
800      * @since 2.3.0
801      * @param {Function} r  the object to receive the augmentation
802      * @param {Function} s  the object that supplies the properties to augment
803      * @param {String*|boolean}  arguments zero or more properties methods
804      *        to augment the receiver with.  If none specified, everything
805      *        in the supplier will be used unless it would
806      *        overwrite an existing property in the receiver. If true
807      *        is specified as the third parameter, all properties will
808      *        be applied and will overwrite an existing property in
809      *        the receiver
810      */
811     augmentObject: function(r, s) {
812         if (!s||!r) {
813             throw new Error("Absorb failed, verify dependencies.");
814         }
815         var a=arguments, i, p, overrideList=a[2];
816         if (overrideList && overrideList!==true) { // only absorb the specified properties
817             for (i=2; i<a.length; i=i+1) {
818                 r[a[i]] = s[a[i]];
819             }
820         } else { // take everything, overwriting only if the third parameter is true
821             for (p in s) {
822                 if (overrideList || !(p in r)) {
823                     r[p] = s[p];
824                 }
825             }
826
827             L._IEEnumFix(r, s);
828         }
829
830         return r;
831     },
832
833     /**
834      * Same as YAHOO.lang.augmentObject, except it only applies prototype properties
835      * @see YAHOO.lang.augmentObject
836      * @method augmentProto
837      * @static
838      * @param {Function} r  the object to receive the augmentation
839      * @param {Function} s  the object that supplies the properties to augment
840      * @param {String*|boolean}  arguments zero or more properties methods
841      *        to augment the receiver with.  If none specified, everything
842      *        in the supplier will be used unless it would overwrite an existing
843      *        property in the receiver.  if true is specified as the third
844      *        parameter, all properties will be applied and will overwrite an
845      *        existing property in the receiver
846      */
847     augmentProto: function(r, s) {
848         if (!s||!r) {
849             throw new Error("Augment failed, verify dependencies.");
850         }
851         //var a=[].concat(arguments);
852         var a=[r.prototype,s.prototype], i;
853         for (i=2;i<arguments.length;i=i+1) {
854             a.push(arguments[i]);
855         }
856         L.augmentObject.apply(this, a);
857
858         return r;
859     },
860
861
862     /**
863      * Returns a simple string representation of the object or array.
864      * Other types of objects will be returned unprocessed.  Arrays
865      * are expected to be indexed.  Use object notation for
866      * associative arrays.
867      * @method dump
868      * @since 2.3.0
869      * @param o {Object} The object to dump
870      * @param d {int} How deep to recurse child objects, default 3
871      * @return {String} the dump result
872      */
873     dump: function(o, d) {
874         var i,len,s=[],OBJ="{...}",FUN="f(){...}",
875             COMMA=', ', ARROW=' => ';
876
877         // Cast non-objects to string
878         // Skip dates because the std toString is what we want
879         // Skip HTMLElement-like objects because trying to dump
880         // an element will cause an unhandled exception in FF 2.x
881         if (!L.isObject(o)) {
882             return o + "";
883         } else if (o instanceof Date || ("nodeType" in o && "tagName" in o)) {
884             return o;
885         } else if  (L.isFunction(o)) {
886             return FUN;
887         }
888
889         // dig into child objects the depth specifed. Default 3
890         d = (L.isNumber(d)) ? d : 3;
891
892         // arrays [1, 2, 3]
893         if (L.isArray(o)) {
894             s.push("[");
895             for (i=0,len=o.length;i<len;i=i+1) {
896                 if (L.isObject(o[i])) {
897                     s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
898                 } else {
899                     s.push(o[i]);
900                 }
901                 s.push(COMMA);
902             }
903             if (s.length > 1) {
904                 s.pop();
905             }
906             s.push("]");
907         // objects {k1 => v1, k2 => v2}
908         } else {
909             s.push("{");
910             for (i in o) {
911                 if (L.hasOwnProperty(o, i)) {
912                     s.push(i + ARROW);
913                     if (L.isObject(o[i])) {
914                         s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
915                     } else {
916                         s.push(o[i]);
917                     }
918                     s.push(COMMA);
919                 }
920             }
921             if (s.length > 1) {
922                 s.pop();
923             }
924             s.push("}");
925         }
926
927         return s.join("");
928     },
929
930     /**
931      * Does variable substitution on a string. It scans through the string
932      * looking for expressions enclosed in { } braces. If an expression
933      * is found, it is used a key on the object.  If there is a space in
934      * the key, the first word is used for the key and the rest is provided
935      * to an optional function to be used to programatically determine the
936      * value (the extra information might be used for this decision). If
937      * the value for the key in the object, or what is returned from the
938      * function has a string value, number value, or object value, it is
939      * substituted for the bracket expression and it repeats.  If this
940      * value is an object, it uses the Object's toString() if this has
941      * been overridden, otherwise it does a shallow dump of the key/value
942      * pairs.
943      *
944      * By specifying the recurse option, the string is rescanned after
945      * every replacement, allowing for nested template substitutions.
946      * The side effect of this option is that curly braces in the
947      * replacement content must be encoded.
948      *
949      * @method substitute
950      * @since 2.3.0
951      * @param s {String} The string that will be modified.
952      * @param o {Object} An object containing the replacement values
953      * @param f {Function} An optional function that can be used to
954      *                     process each match.  It receives the key,
955      *                     value, and any extra metadata included with
956      *                     the key inside of the braces.
957      * @param recurse {boolean} default true - if not false, the replaced
958      * string will be rescanned so that nested substitutions are possible.
959      * @return {String} the substituted string
960      */
961     substitute: function (s, o, f, recurse) {
962         var i, j, k, key, v, meta, saved=[], token, lidx=s.length,
963             DUMP='dump', SPACE=' ', LBRACE='{', RBRACE='}',
964             dump, objstr;
965
966         for (;;) {
967             i = s.lastIndexOf(LBRACE, lidx);
968             if (i < 0) {
969                 break;
970             }
971             j = s.indexOf(RBRACE, i);
972             if (i + 1 > j) {
973                 break;
974             }
975
976             //Extract key and meta info
977             token = s.substring(i + 1, j);
978             key = token;
979             meta = null;
980             k = key.indexOf(SPACE);
981             if (k > -1) {
982                 meta = key.substring(k + 1);
983                 key = key.substring(0, k);
984             }
985
986             // lookup the value
987             v = o[key];
988
989             // if a substitution function was provided, execute it
990             if (f) {
991                 v = f(key, v, meta);
992             }
993
994             if (L.isObject(v)) {
995                 if (L.isArray(v)) {
996                     v = L.dump(v, parseInt(meta, 10));
997                 } else {
998                     meta = meta || "";
999
1000                     // look for the keyword 'dump', if found force obj dump
1001                     dump = meta.indexOf(DUMP);
1002                     if (dump > -1) {
1003                         meta = meta.substring(4);
1004                     }
1005
1006                     objstr = v.toString();
1007
1008                     // use the toString if it is not the Object toString
1009                     // and the 'dump' meta info was not found
1010                     if (objstr === OBJECT_TOSTRING || dump > -1) {
1011                         v = L.dump(v, parseInt(meta, 10));
1012                     } else {
1013                         v = objstr;
1014                     }
1015                 }
1016             } else if (!L.isString(v) && !L.isNumber(v)) {
1017                 // This {block} has no replace string. Save it for later.
1018                 v = "~-" + saved.length + "-~";
1019                 saved[saved.length] = token;
1020
1021                 // break;
1022             }
1023
1024             s = s.substring(0, i) + v + s.substring(j + 1);
1025
1026             if (recurse === false) {
1027                 lidx = i-1;
1028             }
1029
1030         }
1031
1032         // restore saved {block}s
1033         for (i=saved.length-1; i>=0; i=i-1) {
1034             s = s.replace(new RegExp("~-" + i + "-~"), "{"  + saved[i] + "}", "g");
1035         }
1036
1037         return s;
1038     },
1039
1040
1041     /**
1042      * Returns a string without any leading or trailing whitespace.  If
1043      * the input is not a string, the input will be returned untouched.
1044      * @method trim
1045      * @since 2.3.0
1046      * @param s {string} the string to trim
1047      * @return {string} the trimmed string
1048      */
1049     trim: function(s){
1050         try {
1051             return s.replace(/^\s+|\s+$/g, "");
1052         } catch(e) {
1053             return s;
1054         }
1055     },
1056
1057     /**
1058      * Returns a new object containing all of the properties of
1059      * all the supplied objects.  The properties from later objects
1060      * will overwrite those in earlier objects.
1061      * @method merge
1062      * @since 2.3.0
1063      * @param arguments {Object*} the objects to merge
1064      * @return the new merged object
1065      */
1066     merge: function() {
1067         var o={}, a=arguments, l=a.length, i;
1068         for (i=0; i<l; i=i+1) {
1069             L.augmentObject(o, a[i], true);
1070         }
1071         return o;
1072     },
1073
1074     /**
1075      * Executes the supplied function in the context of the supplied
1076      * object 'when' milliseconds later.  Executes the function a
1077      * single time unless periodic is set to true.
1078      * @method later
1079      * @since 2.4.0
1080      * @param when {int} the number of milliseconds to wait until the fn
1081      * is executed
1082      * @param o the context object
1083      * @param fn {Function|String} the function to execute or the name of
1084      * the method in the 'o' object to execute
1085      * @param data [Array] data that is provided to the function.  This accepts
1086      * either a single item or an array.  If an array is provided, the
1087      * function is executed with one parameter for each array item.  If
1088      * you need to pass a single array parameter, it needs to be wrapped in
1089      * an array [myarray]
1090      * @param periodic {boolean} if true, executes continuously at supplied
1091      * interval until canceled
1092      * @return a timer object. Call the cancel() method on this object to
1093      * stop the timer.
1094      */
1095     later: function(when, o, fn, data, periodic) {
1096         when = when || 0;
1097         o = o || {};
1098         var m=fn, d=data, f, r;
1099
1100         if (L.isString(fn)) {
1101             m = o[fn];
1102         }
1103
1104         if (!m) {
1105             throw new TypeError("method undefined");
1106         }
1107
1108         if (!L.isUndefined(data) && !L.isArray(d)) {
1109             d = [data];
1110         }
1111
1112         f = function() {
1113             m.apply(o, d || NOTHING);
1114         };
1115
1116         r = (periodic) ? setInterval(f, when) : setTimeout(f, when);
1117
1118         return {
1119             interval: periodic,
1120             cancel: function() {
1121                 if (this.interval) {
1122                     clearInterval(r);
1123                 } else {
1124                     clearTimeout(r);
1125                 }
1126             }
1127         };
1128     },
1129
1130     /**
1131      * A convenience method for detecting a legitimate non-null value.
1132      * Returns false for null/undefined/NaN, true for other values,
1133      * including 0/false/''
1134      * @method isValue
1135      * @since 2.3.0
1136      * @param o {any} the item to test
1137      * @return {boolean} true if it is not null/undefined/NaN || false
1138      */
1139     isValue: function(o) {
1140         // return (o || o === false || o === 0 || o === ''); // Infinity fails
1141 return (L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o));
1142     }
1143
1144 };
1145
1146 /**
1147  * Determines whether or not the property was added
1148  * to the object instance.  Returns false if the property is not present
1149  * in the object, or was inherited from the prototype.
1150  * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x.
1151  * There is a discrepancy between YAHOO.lang.hasOwnProperty and
1152  * Object.prototype.hasOwnProperty when the property is a primitive added to
1153  * both the instance AND prototype with the same value:
1154  * <pre>
1155  * var A = function() {};
1156  * A.prototype.foo = 'foo';
1157  * var a = new A();
1158  * a.foo = 'foo';
1159  * alert(a.hasOwnProperty('foo')); // true
1160  * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback
1161  * </pre>
1162  * @method hasOwnProperty
1163  * @param {any} o The object being testing
1164  * @param prop {string} the name of the property to test
1165  * @return {boolean} the result
1166  */
1167 L.hasOwnProperty = (OP.hasOwnProperty) ?
1168     function(o, prop) {
1169         return o && o.hasOwnProperty && o.hasOwnProperty(prop);
1170     } : function(o, prop) {
1171         return !L.isUndefined(o[prop]) &&
1172                 o.constructor.prototype[prop] !== o[prop];
1173     };
1174
1175 // new lang wins
1176 OB.augmentObject(L, OB, true);
1177
1178 /*
1179  * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a>
1180  * @class YAHOO.util.Lang
1181  */
1182 YAHOO.util.Lang = L;
1183
1184 /**
1185  * Same as YAHOO.lang.augmentObject, except it only applies prototype
1186  * properties.  This is an alias for augmentProto.
1187  * @see YAHOO.lang.augmentObject
1188  * @method augment
1189  * @static
1190  * @param {Function} r  the object to receive the augmentation
1191  * @param {Function} s  the object that supplies the properties to augment
1192  * @param {String*|boolean}  arguments zero or more properties methods to
1193  *        augment the receiver with.  If none specified, everything
1194  *        in the supplier will be used unless it would
1195  *        overwrite an existing property in the receiver.  if true
1196  *        is specified as the third parameter, all properties will
1197  *        be applied and will overwrite an existing property in
1198  *        the receiver
1199  */
1200 L.augment = L.augmentProto;
1201
1202 /**
1203  * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a>
1204  * @for YAHOO
1205  * @method augment
1206  * @static
1207  * @param {Function} r  the object to receive the augmentation
1208  * @param {Function} s  the object that supplies the properties to augment
1209  * @param {String*}  arguments zero or more properties methods to
1210  *        augment the receiver with.  If none specified, everything
1211  *        in the supplier will be used unless it would
1212  *        overwrite an existing property in the receiver
1213  */
1214 YAHOO.augment = L.augmentProto;
1215
1216 /**
1217  * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a>
1218  * @method extend
1219  * @static
1220  * @param {Function} subc   the object to modify
1221  * @param {Function} superc the object to inherit
1222  * @param {Object} overrides  additional properties/methods to add to the
1223  *        subclass prototype.  These will override the
1224  *        matching items obtained from the superclass if present.
1225  */
1226 YAHOO.extend = L.extend;
1227
1228 })();
1229 YAHOO.register("yahoo", YAHOO, {version: "2.9.0", build: "2800"});
1230 /**
1231  * Provides a mechanism to fetch remote resources and
1232  * insert them into a document
1233  * This utility can fetch JavaScript and CSS files, inserting script
1234  * tags for script and link tags for CSS.  Note, this
1235  * is done via the normal browser mechanisms for inserting
1236  * these resources and making the content available to
1237  * code that would access it.  Be careful when retreiving
1238  * remote resources.  Only use this utility to fetch
1239  * files from sites you trust.
1240  *
1241  * @module get
1242  * @requires yahoo
1243  */
1244
1245 /**
1246  * Fetches and inserts one or more script or link nodes into the document.
1247  * This utility can fetch JavaScript and CSS files, inserting script
1248  * tags for script and link tags for CSS.  Note, this
1249  * is done via the normal browser mechanisms for inserting
1250  * these resources and making the content available to
1251  * code that would access it.  Be careful when retreiving
1252  * remote resources.  Only use this utility to fetch
1253  * files from sites you trust.
1254  *
1255  * @namespace YAHOO.util
1256  * @class YAHOO.util.Get
1257  */
1258 YAHOO.util.Get = function() {
1259
1260     /**
1261      * hash of queues to manage multiple requests
1262      * @property queues
1263      * @private
1264      */
1265     var queues={},
1266
1267     /**
1268      * queue index used to generate transaction ids
1269      * @property qidx
1270      * @type int
1271      * @private
1272      */
1273         qidx=0,
1274
1275     /**
1276      * node index used to generate unique node ids
1277      * @property nidx
1278      * @type int
1279      * @private
1280      */
1281         nidx=0,
1282
1283     /**
1284      * interal property used to prevent multiple simultaneous purge
1285      * processes
1286      * @property purging
1287      * @type boolean
1288      * @private
1289      */
1290         _purging=false,
1291
1292         ua=YAHOO.env.ua,
1293
1294         lang=YAHOO.lang,
1295
1296     _fail,
1297     _purge,
1298     _track,
1299
1300     /**
1301      * Generates an HTML element, this is not appended to a document
1302      * @method _node
1303      * @param type {string} the type of element
1304      * @param attr {string} the attributes
1305      * @param win {Window} optional window to create the element in
1306      * @return {HTMLElement} the generated node
1307      * @private
1308      */
1309     _node = function(type, attr, win) {
1310         var w = win || window, d=w.document, n=d.createElement(type), i;
1311
1312         for (i in attr) {
1313             if (attr.hasOwnProperty(i)) {
1314                 n.setAttribute(i, attr[i]);
1315             }
1316         }
1317
1318         return n;
1319     },
1320
1321     /**
1322      * Generates a link node
1323      * @method _linkNode
1324      * @param url {string} the url for the css file
1325      * @param win {Window} optional window to create the node in
1326      * @return {HTMLElement} the generated node
1327      * @private
1328      */
1329     _linkNode = function(url, win, attributes) {
1330
1331         var o = {
1332             id:   "yui__dyn_" + (nidx++),
1333             type: "text/css",
1334             rel:  "stylesheet",
1335             href: url
1336         };
1337
1338         if (attributes) {
1339             lang.augmentObject(o, attributes);
1340         }
1341
1342         return _node("link", o, win);
1343     },
1344
1345     /**
1346      * Generates a script node
1347      * @method _scriptNode
1348      * @param url {string} the url for the script file
1349      * @param win {Window} optional window to create the node in
1350      * @return {HTMLElement} the generated node
1351      * @private
1352      */
1353     _scriptNode = function(url, win, attributes) {
1354         var o = {
1355             id:   "yui__dyn_" + (nidx++),
1356             type: "text/javascript",
1357             src:  url
1358         };
1359
1360         if (attributes) {
1361             lang.augmentObject(o, attributes);
1362         }
1363
1364         return _node("script", o, win);
1365     },
1366
1367     /**
1368      * Returns the data payload for callback functions
1369      * @method _returnData
1370      * @private
1371      */
1372     _returnData = function(q, msg) {
1373         return {
1374                 tId: q.tId,
1375                 win: q.win,
1376                 data: q.data,
1377                 nodes: q.nodes,
1378                 msg: msg,
1379                 purge: function() {
1380                     _purge(this.tId);
1381                 }
1382             };
1383     },
1384
1385     _get = function(nId, tId) {
1386         var q = queues[tId],
1387             n = (lang.isString(nId)) ? q.win.document.getElementById(nId) : nId;
1388         if (!n) {
1389             _fail(tId, "target node not found: " + nId);
1390         }
1391
1392         return n;
1393     },
1394
1395
1396     /**
1397      * The request is complete, so executing the requester's callback
1398      * @method _finish
1399      * @param id {string} the id of the request
1400      * @private
1401      */
1402     _finish = function(id) {
1403         YAHOO.log("Finishing transaction " + id);
1404         var q = queues[id], msg, context;
1405         q.finished = true;
1406
1407         if (q.aborted) {
1408             msg = "transaction " + id + " was aborted";
1409             _fail(id, msg);
1410             return;
1411         }
1412
1413         // execute success callback
1414         if (q.onSuccess) {
1415             context = q.scope || q.win;
1416             q.onSuccess.call(context, _returnData(q));
1417         }
1418     },
1419
1420     /**
1421      * Timeout detected
1422      * @method _timeout
1423      * @param id {string} the id of the request
1424      * @private
1425      */
1426     _timeout = function(id) {
1427         YAHOO.log("Timeout " + id, "info", "get");
1428         var q = queues[id], context;
1429         if (q.onTimeout) {
1430             context = q.scope || q;
1431             q.onTimeout.call(context, _returnData(q));
1432         }
1433     },
1434
1435     /**
1436      * Loads the next item for a given request
1437      * @method _next
1438      * @param id {string} the id of the request
1439      * @param loaded {string} the url that was just loaded, if any
1440      * @private
1441      */
1442     _next = function(id, loaded) {
1443
1444         YAHOO.log("_next: " + id + ", loaded: " + loaded, "info", "Get");
1445
1446         var q = queues[id], w=q.win, d=w.document, h=d.getElementsByTagName("head")[0],
1447             n, msg, url, s, extra;
1448
1449         if (q.timer) {
1450             // Y.log('cancel timer');
1451             q.timer.cancel();
1452         }
1453
1454         if (q.aborted) {
1455             msg = "transaction " + id + " was aborted";
1456             _fail(id, msg);
1457             return;
1458         }
1459
1460         if (loaded) {
1461             q.url.shift();
1462             if (q.varName) {
1463                 q.varName.shift();
1464             }
1465         } else {
1466             // This is the first pass: make sure the url is an array
1467             q.url = (lang.isString(q.url)) ? [q.url] : q.url;
1468             if (q.varName) {
1469                 q.varName = (lang.isString(q.varName)) ? [q.varName] : q.varName;
1470             }
1471         }
1472
1473
1474         if (q.url.length === 0) {
1475             // Safari 2.x workaround - There is no way to know when
1476             // a script is ready in versions of Safari prior to 3.x.
1477             // Adding an extra node reduces the problem, but doesn't
1478             // eliminate it completely because the browser executes
1479             // them asynchronously.
1480             if (q.type === "script" && ua.webkit && ua.webkit < 420 &&
1481                     !q.finalpass && !q.varName) {
1482                 // Add another script node.  This does not guarantee that the
1483                 // scripts will execute in order, but it does appear to fix the
1484                 // problem on fast connections more effectively than using an
1485                 // arbitrary timeout.  It is possible that the browser does
1486                 // block subsequent script execution in this case for a limited
1487                 // time.
1488                 extra = _scriptNode(null, q.win, q.attributes);
1489                 extra.innerHTML='YAHOO.util.Get._finalize("' + id + '");';
1490                 q.nodes.push(extra); h.appendChild(extra);
1491
1492             } else {
1493                 _finish(id);
1494             }
1495
1496             return;
1497         }
1498
1499
1500         url = q.url[0];
1501
1502         // if the url is undefined, this is probably a trailing comma problem in IE
1503         if (!url) {
1504             q.url.shift();
1505             YAHOO.log('skipping empty url');
1506             return _next(id);
1507         }
1508
1509         YAHOO.log("attempting to load " + url, "info", "Get");
1510
1511         if (q.timeout) {
1512             // Y.log('create timer');
1513             q.timer = lang.later(q.timeout, q, _timeout, id);
1514         }
1515
1516         if (q.type === "script") {
1517             n = _scriptNode(url, w, q.attributes);
1518         } else {
1519             n = _linkNode(url, w, q.attributes);
1520         }
1521
1522         // track this node's load progress
1523         _track(q.type, n, id, url, w, q.url.length);
1524
1525         // add the node to the queue so we can return it to the user supplied callback
1526         q.nodes.push(n);
1527
1528         // add it to the head or insert it before 'insertBefore'
1529         if (q.insertBefore) {
1530             s = _get(q.insertBefore, id);
1531             if (s) {
1532                 s.parentNode.insertBefore(n, s);
1533             }
1534         } else {
1535             h.appendChild(n);
1536         }
1537
1538         YAHOO.log("Appending node: " + url, "info", "Get");
1539
1540         // FireFox does not support the onload event for link nodes, so there is
1541         // no way to make the css requests synchronous. This means that the css
1542         // rules in multiple files could be applied out of order in this browser
1543         // if a later request returns before an earlier one.  Safari too.
1544         if ((ua.webkit || ua.gecko) && q.type === "css") {
1545             _next(id, url);
1546         }
1547     },
1548
1549     /**
1550      * Removes processed queues and corresponding nodes
1551      * @method _autoPurge
1552      * @private
1553      */
1554     _autoPurge = function() {
1555
1556         if (_purging) {
1557             return;
1558         }
1559
1560         _purging = true;
1561
1562         var i, q;
1563
1564         for (i in queues) {
1565             if (queues.hasOwnProperty(i)) {
1566                 q = queues[i];
1567                 if (q.autopurge && q.finished) {
1568                     _purge(q.tId);
1569                     delete queues[i];
1570                 }
1571             }
1572         }
1573
1574         _purging = false;
1575     },
1576
1577     /**
1578      * Saves the state for the request and begins loading
1579      * the requested urls
1580      * @method queue
1581      * @param type {string} the type of node to insert
1582      * @param url {string} the url to load
1583      * @param opts the hash of options for this request
1584      * @private
1585      */
1586     _queue = function(type, url, opts) {
1587
1588         var id = "q" + (qidx++), q;
1589         opts = opts || {};
1590
1591         if (qidx % YAHOO.util.Get.PURGE_THRESH === 0) {
1592             _autoPurge();
1593         }
1594
1595         queues[id] = lang.merge(opts, {
1596             tId: id,
1597             type: type,
1598             url: url,
1599             finished: false,
1600             aborted: false,
1601             nodes: []
1602         });
1603
1604         q = queues[id];
1605         q.win = q.win || window;
1606         q.scope = q.scope || q.win;
1607         q.autopurge = ("autopurge" in q) ? q.autopurge :
1608                       (type === "script") ? true : false;
1609
1610         q.attributes = q.attributes || {};
1611         q.attributes.charset = opts.charset || q.attributes.charset || 'utf-8';
1612
1613         lang.later(0, q, _next, id);
1614
1615         return {
1616             tId: id
1617         };
1618     };
1619
1620     /**
1621      * Detects when a node has been loaded.  In the case of
1622      * script nodes, this does not guarantee that contained
1623      * script is ready to use.
1624      * @method _track
1625      * @param type {string} the type of node to track
1626      * @param n {HTMLElement} the node to track
1627      * @param id {string} the id of the request
1628      * @param url {string} the url that is being loaded
1629      * @param win {Window} the targeted window
1630      * @param qlength the number of remaining items in the queue,
1631      * including this one
1632      * @param trackfn {Function} function to execute when finished
1633      * the default is _next
1634      * @private
1635      */
1636     _track = function(type, n, id, url, win, qlength, trackfn) {
1637         var f = trackfn || _next, rs, q, a, freq, w, l, i, msg;
1638
1639         // IE supports the readystatechange event for script and css nodes
1640         if (ua.ie) {
1641             n.onreadystatechange = function() {
1642                 rs = this.readyState;
1643                 if ("loaded" === rs || "complete" === rs) {
1644                     YAHOO.log(id + " onload " + url, "info", "Get");
1645                     n.onreadystatechange = null;
1646                     f(id, url);
1647                 }
1648             };
1649
1650         // webkit prior to 3.x is problemmatic
1651         } else if (ua.webkit) {
1652
1653             if (type === "script") {
1654
1655                 // Safari 3.x supports the load event for script nodes (DOM2)
1656                 if (ua.webkit >= 420) {
1657
1658                     n.addEventListener("load", function() {
1659                         YAHOO.log(id + " DOM2 onload " + url, "info", "Get");
1660                         f(id, url);
1661                     });
1662
1663                 // Nothing can be done with Safari < 3.x except to pause and hope
1664                 // for the best, particularly after last script is inserted. The
1665                 // scripts will always execute in the order they arrive, not
1666                 // necessarily the order in which they were inserted.  To support
1667                 // script nodes with complete reliability in these browsers, script
1668                 // nodes either need to invoke a function in the window once they
1669                 // are loaded or the implementer needs to provide a well-known
1670                 // property that the utility can poll for.
1671                 } else {
1672                     // Poll for the existence of the named variable, if it
1673                     // was supplied.
1674                     q = queues[id];
1675                     if (q.varName) {
1676                         freq = YAHOO.util.Get.POLL_FREQ;
1677                         YAHOO.log("Polling for " + q.varName[0]);
1678                         q.maxattempts = YAHOO.util.Get.TIMEOUT/freq;
1679                         q.attempts = 0;
1680                         q._cache = q.varName[0].split(".");
1681                         q.timer = lang.later(freq, q, function(o) {
1682                             a = this._cache;
1683                             l = a.length;
1684                             w = this.win;
1685                             for (i=0; i<l; i=i+1) {
1686                                 w = w[a[i]];
1687                                 if (!w) {
1688                                     // if we have exausted our attempts, give up
1689                                     this.attempts++;
1690                                     if (this.attempts++ > this.maxattempts) {
1691                                         msg = "Over retry limit, giving up";
1692                                         q.timer.cancel();
1693                                         _fail(id, msg);
1694                                     } else {
1695                                         YAHOO.log(a[i] + " failed, retrying");
1696                                     }
1697                                     return;
1698                                 }
1699                             }
1700
1701                             YAHOO.log("Safari poll complete");
1702
1703                             q.timer.cancel();
1704                             f(id, url);
1705
1706                         }, null, true);
1707                     } else {
1708                         lang.later(YAHOO.util.Get.POLL_FREQ, null, f, [id, url]);
1709                     }
1710                 }
1711             }
1712
1713         // FireFox and Opera support onload (but not DOM2 in FF) handlers for
1714         // script nodes.  Opera, but not FF, supports the onload event for link
1715         // nodes.
1716         } else {
1717             n.onload = function() {
1718                 YAHOO.log(id + " onload " + url, "info", "Get");
1719                 f(id, url);
1720             };
1721         }
1722     };
1723
1724     /*
1725      * The request failed, execute fail handler with whatever
1726      * was accomplished.  There isn't a failure case at the
1727      * moment unless you count aborted transactions
1728      * @method _fail
1729      * @param id {string} the id of the request
1730      * @private
1731      */
1732     _fail = function(id, msg) {
1733         YAHOO.log("get failure: " + msg, "warn", "Get");
1734         var q = queues[id], context;
1735         // execute failure callback
1736         if (q.onFailure) {
1737             context = q.scope || q.win;
1738             q.onFailure.call(context, _returnData(q, msg));
1739         }
1740     };
1741
1742     /**
1743      * Removes the nodes for the specified queue
1744      * @method _purge
1745      * @private
1746      */
1747     _purge = function(tId) {
1748         if (queues[tId]) {
1749
1750             var q     = queues[tId],
1751                 nodes = q.nodes,
1752                 l     = nodes.length,
1753                 d     = q.win.document,
1754                 h     = d.getElementsByTagName("head")[0],
1755                 sib, i, node, attr;
1756
1757             if (q.insertBefore) {
1758                 sib = _get(q.insertBefore, tId);
1759                 if (sib) {
1760                     h = sib.parentNode;
1761                 }
1762             }
1763
1764             for (i=0; i<l; i=i+1) {
1765                 node = nodes[i];
1766                 if (node.clearAttributes) {
1767                     node.clearAttributes();
1768                 } else {
1769                     for (attr in node) {
1770                         if (node.hasOwnProperty(attr)) {
1771                             delete node[attr];
1772                         }
1773                     }
1774                 }
1775
1776                 h.removeChild(node);
1777             }
1778
1779             q.nodes = [];
1780         }
1781     };
1782
1783
1784     return {
1785
1786         /**
1787          * The default poll freqency in ms, when needed
1788          * @property POLL_FREQ
1789          * @static
1790          * @type int
1791          * @default 10
1792          */
1793         POLL_FREQ: 10,
1794
1795         /**
1796          * The number of request required before an automatic purge.
1797          * property PURGE_THRESH
1798          * @static
1799          * @type int
1800          * @default 20
1801          */
1802         PURGE_THRESH: 20,
1803
1804         /**
1805          * The length time to poll for varName when loading a script in
1806          * Safari 2.x before the transaction fails.
1807          * property TIMEOUT
1808          * @static
1809          * @type int
1810          * @default 2000
1811          */
1812         TIMEOUT: 2000,
1813
1814         /**
1815          * Called by the the helper for detecting script load in Safari
1816          * @method _finalize
1817          * @param id {string} the transaction id
1818          * @private
1819          */
1820         _finalize: function(id) {
1821             YAHOO.log(id + " finalized ", "info", "Get");
1822             lang.later(0, null, _finish, id);
1823         },
1824
1825         /**
1826          * Abort a transaction
1827          * @method abort
1828          * @param {string|object} either the tId or the object returned from
1829          * script() or css()
1830          */
1831         abort: function(o) {
1832             var id = (lang.isString(o)) ? o : o.tId,
1833                 q = queues[id];
1834             if (q) {
1835                 YAHOO.log("Aborting " + id, "info", "Get");
1836                 q.aborted = true;
1837             }
1838         },
1839
1840         /**
1841          * Fetches and inserts one or more script nodes into the head
1842          * of the current document or the document in a specified window.
1843          *
1844          * @method script
1845          * @static
1846          * @param url {string|string[]} the url or urls to the script(s)
1847          * @param opts {object} Options:
1848          * <dl>
1849          * <dt>onSuccess</dt>
1850          * <dd>
1851          * callback to execute when the script(s) are finished loading
1852          * The callback receives an object back with the following
1853          * data:
1854          * <dl>
1855          * <dt>win</dt>
1856          * <dd>the window the script(s) were inserted into</dd>
1857          * <dt>data</dt>
1858          * <dd>the data object passed in when the request was made</dd>
1859          * <dt>nodes</dt>
1860          * <dd>An array containing references to the nodes that were
1861          * inserted</dd>
1862          * <dt>purge</dt>
1863          * <dd>A function that, when executed, will remove the nodes
1864          * that were inserted</dd>
1865          * <dt>
1866          * </dl>
1867          * </dd>
1868          * <dt>onFailure</dt>
1869          * <dd>
1870          * callback to execute when the script load operation fails
1871          * The callback receives an object back with the following
1872          * data:
1873          * <dl>
1874          * <dt>win</dt>
1875          * <dd>the window the script(s) were inserted into</dd>
1876          * <dt>data</dt>
1877          * <dd>the data object passed in when the request was made</dd>
1878          * <dt>nodes</dt>
1879          * <dd>An array containing references to the nodes that were
1880          * inserted successfully</dd>
1881          * <dt>purge</dt>
1882          * <dd>A function that, when executed, will remove any nodes
1883          * that were inserted</dd>
1884          * <dt>
1885          * </dl>
1886          * </dd>
1887          * <dt>onTimeout</dt>
1888          * <dd>
1889          * callback to execute when a timeout occurs.
1890          * The callback receives an object back with the following
1891          * data:
1892          * <dl>
1893          * <dt>win</dt>
1894          * <dd>the window the script(s) were inserted into</dd>
1895          * <dt>data</dt>
1896          * <dd>the data object passed in when the request was made</dd>
1897          * <dt>nodes</dt>
1898          * <dd>An array containing references to the nodes that were
1899          * inserted</dd>
1900          * <dt>purge</dt>
1901          * <dd>A function that, when executed, will remove the nodes
1902          * that were inserted</dd>
1903          * <dt>
1904          * </dl>
1905          * </dd>
1906          * <dt>scope</dt>
1907          * <dd>the execution context for the callbacks</dd>
1908          * <dt>win</dt>
1909          * <dd>a window other than the one the utility occupies</dd>
1910          * <dt>autopurge</dt>
1911          * <dd>
1912          * setting to true will let the utilities cleanup routine purge
1913          * the script once loaded
1914          * </dd>
1915          * <dt>data</dt>
1916          * <dd>
1917          * data that is supplied to the callback when the script(s) are
1918          * loaded.
1919          * </dd>
1920          * <dt>varName</dt>
1921          * <dd>
1922          * variable that should be available when a script is finished
1923          * loading.  Used to help Safari 2.x and below with script load
1924          * detection.  The type of this property should match what was
1925          * passed into the url parameter: if loading a single url, a
1926          * string can be supplied.  If loading multiple scripts, you
1927          * must supply an array that contains the variable name for
1928          * each script.
1929          * </dd>
1930          * <dt>insertBefore</dt>
1931          * <dd>node or node id that will become the new node's nextSibling</dd>
1932          * </dl>
1933          * <dt>charset</dt>
1934          * <dd>Node charset, deprecated, use 'attributes'</dd>
1935          * <dt>attributes</dt>
1936          * <dd>A hash of attributes to apply to dynamic nodes.</dd>
1937          * <dt>timeout</dt>
1938          * <dd>Number of milliseconds to wait before aborting and firing the timeout event</dd>
1939          * <pre>
1940          * // assumes yahoo, dom, and event are already on the page
1941          * &nbsp;&nbsp;YAHOO.util.Get.script(
1942          * &nbsp;&nbsp;["http://yui.yahooapis.com/2.7.0/build/dragdrop/dragdrop-min.js",
1943          * &nbsp;&nbsp;&nbsp;"http://yui.yahooapis.com/2.7.0/build/animation/animation-min.js"], &#123;
1944          * &nbsp;&nbsp;&nbsp;&nbsp;onSuccess: function(o) &#123;
1945          * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;YAHOO.log(o.data); // foo
1946          * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new YAHOO.util.DDProxy("dd1"); // also new o.reference("dd1"); would work
1947          * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.log("won't cause error because YAHOO is the scope");
1948          * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.log(o.nodes.length === 2) // true
1949          * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// o.purge(); // optionally remove the script nodes immediately
1950          * &nbsp;&nbsp;&nbsp;&nbsp;&#125;,
1951          * &nbsp;&nbsp;&nbsp;&nbsp;onFailure: function(o) &#123;
1952          * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;YAHOO.log("transaction failed");
1953          * &nbsp;&nbsp;&nbsp;&nbsp;&#125;,
1954          * &nbsp;&nbsp;&nbsp;&nbsp;data: "foo",
1955          * &nbsp;&nbsp;&nbsp;&nbsp;timeout: 10000, // 10 second timeout
1956          * &nbsp;&nbsp;&nbsp;&nbsp;scope: YAHOO,
1957          * &nbsp;&nbsp;&nbsp;&nbsp;// win: otherframe // target another window/frame
1958          * &nbsp;&nbsp;&nbsp;&nbsp;autopurge: true // allow the utility to choose when to remove the nodes
1959          * &nbsp;&nbsp;&#125;);
1960          * </pre>
1961          * @return {tId: string} an object containing info about the transaction
1962          */
1963         script: function(url, opts) { return _queue("script", url, opts); },
1964
1965         /**
1966          * Fetches and inserts one or more css link nodes into the
1967          * head of the current document or the document in a specified
1968          * window.
1969          * @method css
1970          * @static
1971          * @param url {string} the url or urls to the css file(s)
1972          * @param opts Options:
1973          * <dl>
1974          * <dt>onSuccess</dt>
1975          * <dd>
1976          * callback to execute when the css file(s) are finished loading
1977          * The callback receives an object back with the following
1978          * data:
1979          * <dl>win</dl>
1980          * <dd>the window the link nodes(s) were inserted into</dd>
1981          * <dt>data</dt>
1982          * <dd>the data object passed in when the request was made</dd>
1983          * <dt>nodes</dt>
1984          * <dd>An array containing references to the nodes that were
1985          * inserted</dd>
1986          * <dt>purge</dt>
1987          * <dd>A function that, when executed, will remove the nodes
1988          * that were inserted</dd>
1989          * <dt>
1990          * </dl>
1991          * </dd>
1992          * <dt>scope</dt>
1993          * <dd>the execution context for the callbacks</dd>
1994          * <dt>win</dt>
1995          * <dd>a window other than the one the utility occupies</dd>
1996          * <dt>data</dt>
1997          * <dd>
1998          * data that is supplied to the callbacks when the nodes(s) are
1999          * loaded.
2000          * </dd>
2001          * <dt>insertBefore</dt>
2002          * <dd>node or node id that will become the new node's nextSibling</dd>
2003          * <dt>charset</dt>
2004          * <dd>Node charset, deprecated, use 'attributes'</dd>
2005          * <dt>attributes</dt>
2006          * <dd>A hash of attributes to apply to dynamic nodes.</dd>
2007          * </dl>
2008          * <pre>
2009          *      YAHOO.util.Get.css("http://yui.yahooapis.com/2.7.0/build/menu/assets/skins/sam/menu.css");
2010          * </pre>
2011          * <pre>
2012          *      YAHOO.util.Get.css(["http://yui.yahooapis.com/2.7.0/build/menu/assets/skins/sam/menu.css",
2013          *                          "http://yui.yahooapis.com/2.7.0/build/logger/assets/skins/sam/logger.css"]);
2014          * </pre>
2015          * @return {tId: string} an object containing info about the transaction
2016          */
2017         css: function(url, opts) {
2018             return _queue("css", url, opts);
2019         }
2020     };
2021 }();
2022
2023 YAHOO.register("get", YAHOO.util.Get, {version: "2.9.0", build: "2800"});
2024 /*jslint evil: true, strict: false, regexp: false*/
2025
2026 /**
2027  * Provides dynamic loading for the YUI library.  It includes the dependency
2028  * info for the library, and will automatically pull in dependencies for
2029  * the modules requested.  It supports rollup files (such as utilities.js
2030  * and yahoo-dom-event.js), and will automatically use these when
2031  * appropriate in order to minimize the number of http connections
2032  * required to load all of the dependencies.
2033  *
2034  * @module yuiloader
2035  * @namespace YAHOO.util
2036  */
2037
2038 /**
2039  * YUILoader provides dynamic loading for YUI.
2040  * @class YAHOO.util.YUILoader
2041  * @todo
2042  *      version management, automatic sandboxing
2043  */
2044 (function() {
2045
2046     var Y = YAHOO,
2047         util = Y.util,
2048         lang = Y.lang,
2049         env = Y.env,
2050         PROV = "_provides",
2051         SUPER = "_supersedes",
2052         REQ = "expanded",
2053         AFTER = "_after",
2054         VERSION = "2.9.0";
2055
2056     // version hack for cdn testing
2057     // if (/VERSION/.test(VERSION)) {
2058         // VERSION = "2.8.2";
2059     // }
2060
2061     var YUI = {
2062
2063         dupsAllowed: {'yahoo': true, 'get': true},
2064
2065         /*
2066          * The library metadata for the current release  The is the default
2067          * value for YAHOO.util.YUILoader.moduleInfo
2068          * @property YUIInfo
2069          * @static
2070          */
2071         info: {
2072
2073     // 'root': '2.5.2/build/',
2074     // 'base': 'http://yui.yahooapis.com/2.5.2/build/',
2075
2076     'root': VERSION + '/build/',
2077     'base': 'http://yui.yahooapis.com/' + VERSION + '/build/',
2078
2079     'comboBase': 'http://yui.yahooapis.com/combo?',
2080
2081     'skin': {
2082         'defaultSkin': 'sam',
2083         'base': 'assets/skins/',
2084         'path': 'skin.css',
2085         'after': ['reset', 'fonts', 'grids', 'base'],
2086         'rollup': 3
2087     },
2088
2089     dupsAllowed: ['yahoo', 'get'],
2090
2091     'moduleInfo': {
2092
2093         'animation': {
2094             'type': 'js',
2095             'path': 'animation/animation-min.js',
2096             'requires': ['dom', 'event']
2097         },
2098
2099         'autocomplete': {
2100             'type': 'js',
2101             'path': 'autocomplete/autocomplete-min.js',
2102             'requires': ['dom', 'event', 'datasource'],
2103             'optional': ['connection', 'animation'],
2104             'skinnable': true
2105         },
2106
2107         'base': {
2108             'type': 'css',
2109             'path': 'base/base-min.css',
2110             'after': ['reset', 'fonts', 'grids']
2111         },
2112
2113         'button': {
2114             'type': 'js',
2115             'path': 'button/button-min.js',
2116             'requires': ['element'],
2117             'optional': ['menu'],
2118             'skinnable': true
2119         },
2120
2121         'calendar': {
2122             'type': 'js',
2123             'path': 'calendar/calendar-min.js',
2124             'requires': ['event', 'dom'],
2125             supersedes: ['datemath'],
2126             'skinnable': true
2127         },
2128
2129         'carousel': {
2130             'type': 'js',
2131             'path': 'carousel/carousel-min.js',
2132             'requires': ['element'],
2133             'optional': ['animation'],
2134             'skinnable': true
2135         },
2136
2137         'charts': {
2138             'type': 'js',
2139             'path': 'charts/charts-min.js',
2140             'requires': ['element', 'json', 'datasource', 'swf']
2141         },
2142
2143         'colorpicker': {
2144             'type': 'js',
2145             'path': 'colorpicker/colorpicker-min.js',
2146             'requires': ['slider', 'element'],
2147             'optional': ['animation'],
2148             'skinnable': true
2149         },
2150
2151         'connection': {
2152             'type': 'js',
2153             'path': 'connection/connection-min.js',
2154             'requires': ['event'],
2155             'supersedes': ['connectioncore']
2156         },
2157
2158         'connectioncore': {
2159             'type': 'js',
2160             'path': 'connection/connection_core-min.js',
2161             'requires': ['event'],
2162             'pkg': 'connection'
2163         },
2164
2165         'container': {
2166             'type': 'js',
2167             'path': 'container/container-min.js',
2168             'requires': ['dom', 'event'],
2169             // button is also optional, but this creates a circular
2170             // dependency when loadOptional is specified.  button
2171             // optionally includes menu, menu requires container.
2172             'optional': ['dragdrop', 'animation', 'connection'],
2173             'supersedes': ['containercore'],
2174             'skinnable': true
2175         },
2176
2177         'containercore': {
2178             'type': 'js',
2179             'path': 'container/container_core-min.js',
2180             'requires': ['dom', 'event'],
2181             'pkg': 'container'
2182         },
2183
2184         'cookie': {
2185             'type': 'js',
2186             'path': 'cookie/cookie-min.js',
2187             'requires': ['yahoo']
2188         },
2189
2190         'datasource': {
2191             'type': 'js',
2192             'path': 'datasource/datasource-min.js',
2193             'requires': ['event'],
2194             'optional': ['connection']
2195         },
2196
2197         'datatable': {
2198             'type': 'js',
2199             'path': 'datatable/datatable-min.js',
2200             'requires': ['element', 'datasource'],
2201             'optional': ['calendar', 'dragdrop', 'paginator'],
2202             'skinnable': true
2203         },
2204
2205         datemath: {
2206             'type': 'js',
2207             'path': 'datemath/datemath-min.js',
2208             'requires': ['yahoo']
2209         },
2210
2211         'dom': {
2212             'type': 'js',
2213             'path': 'dom/dom-min.js',
2214             'requires': ['yahoo']
2215         },
2216
2217         'dragdrop': {
2218             'type': 'js',
2219             'path': 'dragdrop/dragdrop-min.js',
2220             'requires': ['dom', 'event']
2221         },
2222
2223         'editor': {
2224             'type': 'js',
2225             'path': 'editor/editor-min.js',
2226             'requires': ['menu', 'element', 'button'],
2227             'optional': ['animation', 'dragdrop'],
2228             'supersedes': ['simpleeditor'],
2229             'skinnable': true
2230         },
2231
2232         'element': {
2233             'type': 'js',
2234             'path': 'element/element-min.js',
2235             'requires': ['dom', 'event'],
2236             'optional': ['event-mouseenter', 'event-delegate']
2237         },
2238
2239         'element-delegate': {
2240             'type': 'js',
2241             'path': 'element-delegate/element-delegate-min.js',
2242             'requires': ['element']
2243         },
2244
2245         'event': {
2246             'type': 'js',
2247             'path': 'event/event-min.js',
2248             'requires': ['yahoo']
2249         },
2250
2251         'event-simulate': {
2252             'type': 'js',
2253             'path': 'event-simulate/event-simulate-min.js',
2254             'requires': ['event']
2255         },
2256
2257         'event-delegate': {
2258             'type': 'js',
2259             'path': 'event-delegate/event-delegate-min.js',
2260             'requires': ['event'],
2261             'optional': ['selector']
2262         },
2263
2264         'event-mouseenter': {
2265             'type': 'js',
2266             'path': 'event-mouseenter/event-mouseenter-min.js',
2267             'requires': ['dom', 'event']
2268         },
2269
2270         'fonts': {
2271             'type': 'css',
2272             'path': 'fonts/fonts-min.css'
2273         },
2274
2275         'get': {
2276             'type': 'js',
2277             'path': 'get/get-min.js',
2278             'requires': ['yahoo']
2279         },
2280
2281         'grids': {
2282             'type': 'css',
2283             'path': 'grids/grids-min.css',
2284             'requires': ['fonts'],
2285             'optional': ['reset']
2286         },
2287
2288         'history': {
2289             'type': 'js',
2290             'path': 'history/history-min.js',
2291             'requires': ['event']
2292         },
2293
2294          'imagecropper': {
2295              'type': 'js',
2296              'path': 'imagecropper/imagecropper-min.js',
2297              'requires': ['dragdrop', 'element', 'resize'],
2298              'skinnable': true
2299          },
2300
2301          'imageloader': {
2302             'type': 'js',
2303             'path': 'imageloader/imageloader-min.js',
2304             'requires': ['event', 'dom']
2305          },
2306
2307          'json': {
2308             'type': 'js',
2309             'path': 'json/json-min.js',
2310             'requires': ['yahoo']
2311          },
2312
2313          'layout': {
2314              'type': 'js',
2315              'path': 'layout/layout-min.js',
2316              'requires': ['element'],
2317              'optional': ['animation', 'dragdrop', 'resize', 'selector'],
2318              'skinnable': true
2319          },
2320
2321         'logger': {
2322             'type': 'js',
2323             'path': 'logger/logger-min.js',
2324             'requires': ['event', 'dom'],
2325             'optional': ['dragdrop'],
2326             'skinnable': true
2327         },
2328
2329         'menu': {
2330             'type': 'js',
2331             'path': 'menu/menu-min.js',
2332             'requires': ['containercore'],
2333             'skinnable': true
2334         },
2335
2336         'paginator': {
2337             'type': 'js',
2338             'path': 'paginator/paginator-min.js',
2339             'requires': ['element'],
2340             'skinnable': true
2341         },
2342
2343         'profiler': {
2344             'type': 'js',
2345             'path': 'profiler/profiler-min.js',
2346             'requires': ['yahoo']
2347         },
2348
2349
2350         'profilerviewer': {
2351             'type': 'js',
2352             'path': 'profilerviewer/profilerviewer-min.js',
2353             'requires': ['profiler', 'yuiloader', 'element'],
2354             'skinnable': true
2355         },
2356
2357         'progressbar': {
2358             'type': 'js',
2359             'path': 'progressbar/progressbar-min.js',
2360             'requires': ['element'],
2361             'optional': ['animation'],
2362             'skinnable': true
2363         },
2364
2365         'reset': {
2366             'type': 'css',
2367             'path': 'reset/reset-min.css'
2368         },
2369
2370         'reset-fonts-grids': {
2371             'type': 'css',
2372             'path': 'reset-fonts-grids/reset-fonts-grids.css',
2373             'supersedes': ['reset', 'fonts', 'grids', 'reset-fonts'],
2374             'rollup': 4
2375         },
2376
2377         'reset-fonts': {
2378             'type': 'css',
2379             'path': 'reset-fonts/reset-fonts.css',
2380             'supersedes': ['reset', 'fonts'],
2381             'rollup': 2
2382         },
2383
2384          'resize': {
2385              'type': 'js',
2386              'path': 'resize/resize-min.js',
2387              'requires': ['dragdrop', 'element'],
2388              'optional': ['animation'],
2389              'skinnable': true
2390          },
2391
2392         'selector': {
2393             'type': 'js',
2394             'path': 'selector/selector-min.js',
2395             'requires': ['yahoo', 'dom']
2396         },
2397
2398         'simpleeditor': {
2399             'type': 'js',
2400             'path': 'editor/simpleeditor-min.js',
2401             'requires': ['element'],
2402             'optional': ['containercore', 'menu', 'button', 'animation', 'dragdrop'],
2403             'skinnable': true,
2404             'pkg': 'editor'
2405         },
2406
2407         'slider': {
2408             'type': 'js',
2409             'path': 'slider/slider-min.js',
2410             'requires': ['dragdrop'],
2411             'optional': ['animation'],
2412             'skinnable': true
2413         },
2414
2415         'storage': {
2416             'type': 'js',
2417             'path': 'storage/storage-min.js',
2418             'requires': ['yahoo', 'event', 'cookie'],
2419             'optional': ['swfstore']
2420         },
2421
2422          'stylesheet': {
2423             'type': 'js',
2424             'path': 'stylesheet/stylesheet-min.js',
2425             'requires': ['yahoo']
2426          },
2427
2428         'swf': {
2429             'type': 'js',
2430             'path': 'swf/swf-min.js',
2431             'requires': ['element'],
2432             'supersedes': ['swfdetect']
2433         },
2434
2435         'swfdetect': {
2436             'type': 'js',
2437             'path': 'swfdetect/swfdetect-min.js',
2438             'requires': ['yahoo']
2439         },
2440
2441         'swfstore': {
2442             'type': 'js',
2443             'path': 'swfstore/swfstore-min.js',
2444             'requires': ['element', 'cookie', 'swf']
2445         },
2446
2447         'tabview': {
2448             'type': 'js',
2449             'path': 'tabview/tabview-min.js',
2450             'requires': ['element'],
2451             'optional': ['connection'],
2452             'skinnable': true
2453         },
2454
2455         'treeview': {
2456             'type': 'js',
2457             'path': 'treeview/treeview-min.js',
2458             'requires': ['event', 'dom'],
2459             'optional': ['json', 'animation', 'calendar'],
2460             'skinnable': true
2461         },
2462
2463         'uploader': {
2464             'type': 'js',
2465             'path': 'uploader/uploader-min.js',
2466             'requires': ['element']
2467         },
2468
2469         'utilities': {
2470             'type': 'js',
2471             'path': 'utilities/utilities.js',
2472             'supersedes': ['yahoo', 'event', 'dragdrop', 'animation', 'dom', 'connection', 'element', 'yahoo-dom-event', 'get', 'yuiloader', 'yuiloader-dom-event'],
2473             'rollup': 8
2474         },
2475
2476         'yahoo': {
2477             'type': 'js',
2478             'path': 'yahoo/yahoo-min.js'
2479         },
2480
2481         'yahoo-dom-event': {
2482             'type': 'js',
2483             'path': 'yahoo-dom-event/yahoo-dom-event.js',
2484             'supersedes': ['yahoo', 'event', 'dom'],
2485             'rollup': 3
2486         },
2487
2488         'yuiloader': {
2489             'type': 'js',
2490             'path': 'yuiloader/yuiloader-min.js',
2491             'supersedes': ['yahoo', 'get']
2492         },
2493
2494         'yuiloader-dom-event': {
2495             'type': 'js',
2496             'path': 'yuiloader-dom-event/yuiloader-dom-event.js',
2497             'supersedes': ['yahoo', 'dom', 'event', 'get', 'yuiloader', 'yahoo-dom-event'],
2498             'rollup': 5
2499         },
2500
2501         'yuitest': {
2502             'type': 'js',
2503             'path': 'yuitest/yuitest-min.js',
2504             'requires': ['logger'],
2505             'optional': ['event-simulate'],
2506             'skinnable': true
2507         }
2508     }
2509 },
2510         ObjectUtil: {
2511             appendArray: function(o, a) {
2512                 if (a) {
2513                     for (var i=0; i<a.length; i=i+1) {
2514                         o[a[i]] = true;
2515                     }
2516                 }
2517             },
2518
2519             keys: function(o, ordered) {
2520                 var a=[], i;
2521                 for (i in o) {
2522                     if (lang.hasOwnProperty(o, i)) {
2523                         a.push(i);
2524                     }
2525                 }
2526
2527                 return a;
2528             }
2529         },
2530
2531         ArrayUtil: {
2532
2533             appendArray: function(a1, a2) {
2534                 Array.prototype.push.apply(a1, a2);
2535                 /*
2536                 for (var i=0; i<a2.length; i=i+1) {
2537                     a1.push(a2[i]);
2538                 }
2539                 */
2540             },
2541
2542             indexOf: function(a, val) {
2543                 for (var i=0; i<a.length; i=i+1) {
2544                     if (a[i] === val) {
2545                         return i;
2546                     }
2547                 }
2548
2549                 return -1;
2550             },
2551
2552             toObject: function(a) {
2553                 var o = {};
2554                 for (var i=0; i<a.length; i=i+1) {
2555                     o[a[i]] = true;
2556                 }
2557
2558                 return o;
2559             },
2560
2561             /*
2562              * Returns a unique array.  Does not maintain order, which is fine
2563              * for this application, and performs better than it would if it
2564              * did.
2565              */
2566             uniq: function(a) {
2567                 return YUI.ObjectUtil.keys(YUI.ArrayUtil.toObject(a));
2568             }
2569         }
2570     };
2571
2572     YAHOO.util.YUILoader = function(o) {
2573
2574         /**
2575          * Internal callback to handle multiple internal insert() calls
2576          * so that css is inserted prior to js
2577          * @property _internalCallback
2578          * @private
2579          */
2580         this._internalCallback = null;
2581
2582         /**
2583          * Use the YAHOO environment listener to detect script load.  This
2584          * is only switched on for Safari 2.x and below.
2585          * @property _useYahooListener
2586          * @private
2587          */
2588         this._useYahooListener = false;
2589
2590         /**
2591          * Callback that will be executed when the loader is finished
2592          * with an insert
2593          * @method onSuccess
2594          * @type function
2595          */
2596         this.onSuccess = null;
2597
2598         /**
2599          * Callback that will be executed if there is a failure
2600          * @method onFailure
2601          * @type function
2602          */
2603         this.onFailure = Y.log;
2604
2605         /**
2606          * Callback that will be executed each time a new module is loaded
2607          * @method onProgress
2608          * @type function
2609          */
2610         this.onProgress = null;
2611
2612         /**
2613          * Callback that will be executed if a timeout occurs
2614          * @method onTimeout
2615          * @type function
2616          */
2617         this.onTimeout = null;
2618
2619         /**
2620          * The execution scope for all callbacks
2621          * @property scope
2622          * @default this
2623          */
2624         this.scope = this;
2625
2626         /**
2627          * Data that is passed to all callbacks
2628          * @property data
2629          */
2630         this.data = null;
2631
2632         /**
2633          * Node reference or id where new nodes should be inserted before
2634          * @property insertBefore
2635          * @type string|HTMLElement
2636          */
2637         this.insertBefore = null;
2638
2639         /**
2640          * The charset attribute for inserted nodes
2641          * @property charset
2642          * @type string
2643          * @default utf-8
2644          */
2645         this.charset = null;
2646
2647         /**
2648          * The name of the variable in a sandbox or script node
2649          * (for external script support in Safari 2.x and earlier)
2650          * to reference when the load is complete.  If this variable
2651          * is not available in the specified scripts, the operation will
2652          * fail.
2653          * @property varName
2654          * @type string
2655          */
2656         this.varName = null;
2657
2658         /**
2659          * The base directory.
2660          * @property base
2661          * @type string
2662          * @default http://yui.yahooapis.com/[YUI VERSION]/build/
2663          */
2664         this.base = YUI.info.base;
2665
2666         /**
2667          * Base path for the combo service
2668          * @property comboBase
2669          * @type string
2670          * @default http://yui.yahooapis.com/combo?
2671          */
2672         this.comboBase = YUI.info.comboBase;
2673
2674         /**
2675          * If configured, YUI will use the the combo handler on the
2676          * Yahoo! CDN to pontentially reduce the number of http requests
2677          * required.
2678          * @property combine
2679          * @type boolean
2680          * @default false
2681          */
2682         // this.combine = (o && !('base' in o));
2683         this.combine = false;
2684
2685
2686         /**
2687          * Root path to prepend to module path for the combo
2688          * service
2689          * @property root
2690          * @type string
2691          * @default [YUI VERSION]/build/
2692          */
2693         this.root = YUI.info.root;
2694
2695         /**
2696          * Timeout value in milliseconds.  If set, this value will be used by
2697          * the get utility.  the timeout event will fire if
2698          * a timeout occurs.
2699          * @property timeout
2700          * @type int
2701          */
2702         this.timeout = 0;
2703
2704         /**
2705          * A list of modules that should not be loaded, even if
2706          * they turn up in the dependency tree
2707          * @property ignore
2708          * @type string[]
2709          */
2710         this.ignore = null;
2711
2712         /**
2713          * A list of modules that should always be loaded, even
2714          * if they have already been inserted into the page.
2715          * @property force
2716          * @type string[]
2717          */
2718         this.force = null;
2719
2720         /**
2721          * Should we allow rollups
2722          * @property allowRollup
2723          * @type boolean
2724          * @default true
2725          */
2726         this.allowRollup = true;
2727
2728         /**
2729          * A filter to apply to result urls.  This filter will modify the default
2730          * path for all modules.  The default path for the YUI library is the
2731          * minified version of the files (e.g., event-min.js).  The filter property
2732          * can be a predefined filter or a custom filter.  The valid predefined
2733          * filters are:
2734          * <dl>
2735          *  <dt>DEBUG</dt>
2736          *  <dd>Selects the debug versions of the library (e.g., event-debug.js).
2737          *      This option will automatically include the logger widget</dd>
2738          *  <dt>RAW</dt>
2739          *  <dd>Selects the non-minified version of the library (e.g., event.js).
2740          * </dl>
2741          * You can also define a custom filter, which must be an object literal
2742          * containing a search expression and a replace string:
2743          * <pre>
2744          *  myFilter: &#123;
2745          *      'searchExp': "-min\\.js",
2746          *      'replaceStr': "-debug.js"
2747          *  &#125;
2748          * </pre>
2749          * @property filter
2750          * @type string|{searchExp: string, replaceStr: string}
2751          */
2752         this.filter = null;
2753
2754         /**
2755          * The list of requested modules
2756          * @property required
2757          * @type {string: boolean}
2758          */
2759         this.required = {};
2760
2761         /**
2762          * The library metadata
2763          * @property moduleInfo
2764          */
2765         this.moduleInfo = lang.merge(YUI.info.moduleInfo);
2766
2767         /**
2768          * List of rollup files found in the library metadata
2769          * @property rollups
2770          */
2771         this.rollups = null;
2772
2773         /**
2774          * Whether or not to load optional dependencies for
2775          * the requested modules
2776          * @property loadOptional
2777          * @type boolean
2778          * @default false
2779          */
2780         this.loadOptional = false;
2781
2782         /**
2783          * All of the derived dependencies in sorted order, which
2784          * will be populated when either calculate() or insert()
2785          * is called
2786          * @property sorted
2787          * @type string[]
2788          */
2789         this.sorted = [];
2790
2791         /**
2792          * Set when beginning to compute the dependency tree.
2793          * Composed of what YAHOO reports to be loaded combined
2794          * with what has been loaded by the tool
2795          * @propery loaded
2796          * @type {string: boolean}
2797          */
2798         this.loaded = {};
2799
2800         /**
2801          * Flag to indicate the dependency tree needs to be recomputed
2802          * if insert is called again.
2803          * @property dirty
2804          * @type boolean
2805          * @default true
2806          */
2807         this.dirty = true;
2808
2809         /**
2810          * List of modules inserted by the utility
2811          * @property inserted
2812          * @type {string: boolean}
2813          */
2814         this.inserted = {};
2815
2816         /**
2817          * Provides the information used to skin the skinnable components.
2818          * The following skin definition would result in 'skin1' and 'skin2'
2819          * being loaded for calendar (if calendar was requested), and
2820          * 'sam' for all other skinnable components:
2821          *
2822          *   <code>
2823          *   skin: {
2824          *
2825          *      // The default skin, which is automatically applied if not
2826          *      // overriden by a component-specific skin definition.
2827          *      // Change this in to apply a different skin globally
2828          *      defaultSkin: 'sam',
2829          *
2830          *      // This is combined with the loader base property to get
2831          *      // the default root directory for a skin. ex:
2832          *      // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
2833          *      base: 'assets/skins/',
2834          *
2835          *      // The name of the rollup css file for the skin
2836          *      path: 'skin.css',
2837          *
2838          *      // The number of skinnable components requested that are
2839          *      // required before using the rollup file rather than the
2840          *      // individual component css files
2841          *      rollup: 3,
2842          *
2843          *      // Any component-specific overrides can be specified here,
2844          *      // making it possible to load different skins for different
2845          *      // components.  It is possible to load more than one skin
2846          *      // for a given component as well.
2847          *      overrides: {
2848          *          calendar: ['skin1', 'skin2']
2849          *      }
2850          *   }
2851          *   </code>
2852          *   @property skin
2853          */
2854
2855         var self = this;
2856
2857         env.listeners.push(function(m) {
2858             if (self._useYahooListener) {
2859                 //Y.log("YAHOO listener: " + m.name);
2860                 self.loadNext(m.name);
2861             }
2862         });
2863
2864         this.skin = lang.merge(YUI.info.skin);
2865
2866         this._config(o);
2867
2868     };
2869
2870     Y.util.YUILoader.prototype = {
2871
2872         FILTERS: {
2873             RAW: {
2874                 'searchExp': "-min\\.js",
2875                 'replaceStr': ".js"
2876             },
2877             DEBUG: {
2878                 'searchExp': "-min\\.js",
2879                 'replaceStr': "-debug.js"
2880             }
2881         },
2882
2883         SKIN_PREFIX: "skin-",
2884
2885         _config: function(o) {
2886
2887             // apply config values
2888             if (o) {
2889                 for (var i in o) {
2890                     if (lang.hasOwnProperty(o, i)) {
2891                         if (i == "require") {
2892                             this.require(o[i]);
2893                         } else {
2894                             this[i] = o[i];
2895                         }
2896                     }
2897                 }
2898             }
2899
2900             // fix filter
2901             var f = this.filter;
2902
2903             if (lang.isString(f)) {
2904                 f = f.toUpperCase();
2905
2906                 // the logger must be available in order to use the debug
2907                 // versions of the library
2908                 if (f === "DEBUG") {
2909                     this.require("logger");
2910                 }
2911
2912                 // hack to handle a a bug where LogWriter is being instantiated
2913                 // at load time, and the loader has no way to sort above it
2914                 // at the moment.
2915                 if (!Y.widget.LogWriter) {
2916                     Y.widget.LogWriter = function() {
2917                         return Y;
2918                     };
2919                 }
2920
2921                 this.filter = this.FILTERS[f];
2922             }
2923
2924         },
2925
2926         /** Add a new module to the component metadata.
2927          * <dl>
2928          *     <dt>name:</dt>       <dd>required, the component name</dd>
2929          *     <dt>type:</dt>       <dd>required, the component type (js or css)</dd>
2930          *     <dt>path:</dt>       <dd>required, the path to the script from "base"</dd>
2931          *     <dt>requires:</dt>   <dd>array of modules required by this component</dd>
2932          *     <dt>optional:</dt>   <dd>array of optional modules for this component</dd>
2933          *     <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd>
2934          *     <dt>after:</dt>      <dd>array of modules the components which, if present, should be sorted above this one</dd>
2935          *     <dt>rollup:</dt>     <dd>the number of superseded modules required for automatic rollup</dd>
2936          *     <dt>fullpath:</dt>   <dd>If fullpath is specified, this is used instead of the configured base + path</dd>
2937          *     <dt>skinnable:</dt>  <dd>flag to determine if skin assets should automatically be pulled in</dd>
2938          * </dl>
2939          * @method addModule
2940          * @param o An object containing the module data
2941          * @return {boolean} true if the module was added, false if
2942          * the object passed in did not provide all required attributes
2943          */
2944         addModule: function(o) {
2945
2946             if (!o || !o.name || !o.type || (!o.path && !o.fullpath)) {
2947                 return false;
2948             }
2949
2950             o.ext = ('ext' in o) ? o.ext : true;
2951             o.requires = o.requires || [];
2952
2953             this.moduleInfo[o.name] = o;
2954             this.dirty = true;
2955
2956             return true;
2957         },
2958
2959         /**
2960          * Add a requirement for one or more module
2961          * @method require
2962          * @param what {string[] | string*} the modules to load
2963          */
2964         require: function(what) {
2965             var a = (typeof what === "string") ? arguments : what;
2966             this.dirty = true;
2967             YUI.ObjectUtil.appendArray(this.required, a);
2968         },
2969
2970         /**
2971          * Adds the skin def to the module info
2972          * @method _addSkin
2973          * @param skin {string} the name of the skin
2974          * @param mod {string} the name of the module
2975          * @return {string} the module name for the skin
2976          * @private
2977          */
2978         _addSkin: function(skin, mod) {
2979
2980             // Add a module definition for the skin rollup css
2981             var name = this.formatSkin(skin), info = this.moduleInfo,
2982                 sinf = this.skin, ext = info[mod] && info[mod].ext;
2983
2984             // Y.log('ext? ' + mod + ": " + ext);
2985             if (!info[name]) {
2986                 // Y.log('adding skin ' + name);
2987                 this.addModule({
2988                     'name': name,
2989                     'type': 'css',
2990                     'path': sinf.base + skin + '/' + sinf.path,
2991                     //'supersedes': '*',
2992                     'after': sinf.after,
2993                     'rollup': sinf.rollup,
2994                     'ext': ext
2995                 });
2996             }
2997
2998             // Add a module definition for the module-specific skin css
2999             if (mod) {
3000                 name = this.formatSkin(skin, mod);
3001                 if (!info[name]) {
3002                     var mdef = info[mod], pkg = mdef.pkg || mod;
3003                     // Y.log('adding skin ' + name);
3004                     this.addModule({
3005                         'name': name,
3006                         'type': 'css',
3007                         'after': sinf.after,
3008                         'path': pkg + '/' + sinf.base + skin + '/' + mod + '.css',
3009                         'ext': ext
3010                     });
3011                 }
3012             }
3013
3014             return name;
3015         },
3016
3017         /**
3018          * Returns an object containing properties for all modules required
3019          * in order to load the requested module
3020          * @method getRequires
3021          * @param mod The module definition from moduleInfo
3022          */
3023         getRequires: function(mod) {
3024             if (!mod) {
3025                 return [];
3026             }
3027
3028             if (!this.dirty && mod.expanded) {
3029                 return mod.expanded;
3030             }
3031
3032             mod.requires=mod.requires || [];
3033             var i, d=[], r=mod.requires, o=mod.optional, info=this.moduleInfo, m;
3034             for (i=0; i<r.length; i=i+1) {
3035                 d.push(r[i]);
3036                 m = info[r[i]];
3037                 YUI.ArrayUtil.appendArray(d, this.getRequires(m));
3038             }
3039
3040             if (o && this.loadOptional) {
3041                 for (i=0; i<o.length; i=i+1) {
3042                     d.push(o[i]);
3043                     YUI.ArrayUtil.appendArray(d, this.getRequires(info[o[i]]));
3044                 }
3045             }
3046
3047             mod.expanded = YUI.ArrayUtil.uniq(d);
3048
3049             return mod.expanded;
3050         },
3051
3052
3053         /**
3054          * Returns an object literal of the modules the supplied module satisfies
3055          * @method getProvides
3056          * @param name{string} The name of the module
3057          * @param notMe {string} don't add this module name, only include superseded modules
3058          * @return what this module provides
3059          */
3060         getProvides: function(name, notMe) {
3061             var addMe = !(notMe), ckey = (addMe) ? PROV : SUPER,
3062                 m = this.moduleInfo[name], o = {};
3063
3064             if (!m) {
3065                 return o;
3066             }
3067
3068             if (m[ckey]) {
3069 // Y.log('cached: ' + name + ' ' + ckey + ' ' + lang.dump(this.moduleInfo[name][ckey], 0));
3070                 return m[ckey];
3071             }
3072
3073             var s = m.supersedes, done={}, me = this;
3074
3075             // use worker to break cycles
3076             var add = function(mm) {
3077                 if (!done[mm]) {
3078                     // Y.log(name + ' provides worker trying: ' + mm);
3079                     done[mm] = true;
3080                     // we always want the return value normal behavior
3081                     // (provides) for superseded modules.
3082                     lang.augmentObject(o, me.getProvides(mm));
3083                 }
3084
3085                 // else {
3086                 // Y.log(name + ' provides worker skipping done: ' + mm);
3087                 // }
3088             };
3089
3090             // calculate superseded modules
3091             if (s) {
3092                 for (var i=0; i<s.length; i=i+1) {
3093                     add(s[i]);
3094                 }
3095             }
3096
3097             // supersedes cache
3098             m[SUPER] = o;
3099             // provides cache
3100             m[PROV] = lang.merge(o);
3101             m[PROV][name] = true;
3102
3103 // Y.log(name + " supersedes " + lang.dump(m[SUPER], 0));
3104 // Y.log(name + " provides " + lang.dump(m[PROV], 0));
3105
3106             return m[ckey];
3107         },
3108
3109
3110         /**
3111          * Calculates the dependency tree, the result is stored in the sorted
3112          * property
3113          * @method calculate
3114          * @param o optional options object
3115          */
3116         calculate: function(o) {
3117             if (o || this.dirty) {
3118                 this._config(o);
3119                 this._setup();
3120                 this._explode();
3121                 if (this.allowRollup) {
3122                     this._rollup();
3123                 }
3124                 this._reduce();
3125                 this._sort();
3126
3127                 // Y.log("after calculate: " + lang.dump(this.required));
3128
3129                 this.dirty = false;
3130             }
3131         },
3132
3133         /**
3134          * Investigates the current YUI configuration on the page.  By default,
3135          * modules already detected will not be loaded again unless a force
3136          * option is encountered.  Called by calculate()
3137          * @method _setup
3138          * @private
3139          */
3140         _setup: function() {
3141
3142             var info = this.moduleInfo, name, i, j;
3143
3144             // Create skin modules
3145             for (name in info) {
3146
3147                 if (lang.hasOwnProperty(info, name)) {
3148                     var m = info[name];
3149                     if (m && m.skinnable) {
3150                         // Y.log("skinning: " + name);
3151                         var o=this.skin.overrides, smod;
3152                         if (o && o[name]) {
3153                             for (i=0; i<o[name].length; i=i+1) {
3154                                 smod = this._addSkin(o[name][i], name);
3155                             }
3156                         } else {
3157                             smod = this._addSkin(this.skin.defaultSkin, name);
3158                         }
3159
3160                         if (YUI.ArrayUtil.indexOf(m.requires, smod) == -1) {
3161                             m.requires.push(smod);
3162                         }
3163                     }
3164                 }
3165
3166             }
3167
3168             var l = lang.merge(this.inserted); // shallow clone
3169
3170             if (!this._sandbox) {
3171                 l = lang.merge(l, env.modules);
3172             }
3173
3174             // Y.log("Already loaded stuff: " + lang.dump(l, 0));
3175
3176             // add the ignore list to the list of loaded packages
3177             if (this.ignore) {
3178                 YUI.ObjectUtil.appendArray(l, this.ignore);
3179             }
3180
3181             // remove modules on the force list from the loaded list
3182             if (this.force) {
3183                 for (i=0; i<this.force.length; i=i+1) {
3184                     if (this.force[i] in l) {
3185                         delete l[this.force[i]];
3186                     }
3187                 }
3188             }
3189
3190             // expand the list to include superseded modules
3191             for (j in l) {
3192                 // Y.log("expanding: " + j);
3193                 if (lang.hasOwnProperty(l, j)) {
3194                     lang.augmentObject(l, this.getProvides(j));
3195                 }
3196             }
3197
3198             // Y.log("loaded expanded: " + lang.dump(l, 0));
3199
3200             this.loaded = l;
3201
3202         },
3203
3204
3205         /**
3206          * Inspects the required modules list looking for additional
3207          * dependencies.  Expands the required list to include all
3208          * required modules.  Called by calculate()
3209          * @method _explode
3210          * @private
3211          */
3212         _explode: function() {
3213
3214             var r=this.required, i, mod;
3215
3216             for (i in r) {
3217                 if (lang.hasOwnProperty(r, i)) {
3218                     mod = this.moduleInfo[i];
3219                     if (mod) {
3220
3221                         var req = this.getRequires(mod);
3222
3223                         if (req) {
3224                             YUI.ObjectUtil.appendArray(r, req);
3225                         }
3226                     }
3227                 }
3228             }
3229         },
3230
3231         /*
3232          * @method _skin
3233          * @private
3234          * @deprecated
3235          */
3236         _skin: function() {
3237         },
3238
3239         /**
3240          * Returns the skin module name for the specified skin name.  If a
3241          * module name is supplied, the returned skin module name is
3242          * specific to the module passed in.
3243          * @method formatSkin
3244          * @param skin {string} the name of the skin
3245          * @param mod {string} optional: the name of a module to skin
3246          * @return {string} the full skin module name
3247          */
3248         formatSkin: function(skin, mod) {
3249             var s = this.SKIN_PREFIX + skin;
3250             if (mod) {
3251                 s = s + "-" + mod;
3252             }
3253
3254             return s;
3255         },
3256
3257         /**
3258          * Reverses <code>formatSkin</code>, providing the skin name and
3259          * module name if the string matches the pattern for skins.
3260          * @method parseSkin
3261          * @param mod {string} the module name to parse
3262          * @return {skin: string, module: string} the parsed skin name
3263          * and module name, or null if the supplied string does not match
3264          * the skin pattern
3265          */
3266         parseSkin: function(mod) {
3267
3268             if (mod.indexOf(this.SKIN_PREFIX) === 0) {
3269                 var a = mod.split("-");
3270                 return {skin: a[1], module: a[2]};
3271             }
3272
3273             return null;
3274         },
3275
3276         /**
3277          * Look for rollup packages to determine if all of the modules a
3278          * rollup supersedes are required.  If so, include the rollup to
3279          * help reduce the total number of connections required.  Called
3280          * by calculate()
3281          * @method _rollup
3282          * @private
3283          */
3284         _rollup: function() {
3285             var i, j, m, s, rollups={}, r=this.required, roll,
3286                 info = this.moduleInfo;
3287
3288             // find and cache rollup modules
3289             if (this.dirty || !this.rollups) {
3290                 for (i in info) {
3291                     if (lang.hasOwnProperty(info, i)) {
3292                         m = info[i];
3293                         //if (m && m.rollup && m.supersedes) {
3294                         if (m && m.rollup) {
3295                             rollups[i] = m;
3296                         }
3297                     }
3298                 }
3299
3300                 this.rollups = rollups;
3301             }
3302
3303             // make as many passes as needed to pick up rollup rollups
3304             for (;;) {
3305                 var rolled = false;
3306
3307                 // go through the rollup candidates
3308                 for (i in rollups) {
3309
3310                     // there can be only one
3311                     if (!r[i] && !this.loaded[i]) {
3312                         m =info[i]; s = m.supersedes; roll=false;
3313
3314                         if (!m.rollup) {
3315                             continue;
3316                         }
3317
3318                         var skin = (m.ext) ? false : this.parseSkin(i), c = 0;
3319
3320                         // Y.log('skin? ' + i + ": " + skin);
3321                         if (skin) {
3322                             for (j in r) {
3323                                 if (lang.hasOwnProperty(r, j)) {
3324                                     if (i !== j && this.parseSkin(j)) {
3325                                         c++;
3326                                         roll = (c >= m.rollup);
3327                                         if (roll) {
3328                                             // Y.log("skin rollup " + lang.dump(r));
3329                                             break;
3330                                         }
3331                                     }
3332                                 }
3333                             }
3334
3335                         } else {
3336
3337                             // check the threshold
3338                             for (j=0;j<s.length;j=j+1) {
3339
3340                                 // if the superseded module is loaded, we can't load the rollup
3341                                 if (this.loaded[s[j]] && (!YUI.dupsAllowed[s[j]])) {
3342                                     roll = false;
3343                                     break;
3344                                 // increment the counter if this module is required.  if we are
3345                                 // beyond the rollup threshold, we will use the rollup module
3346                                 } else if (r[s[j]]) {
3347                                     c++;
3348                                     roll = (c >= m.rollup);
3349                                     if (roll) {
3350                                         // Y.log("over thresh " + c + ", " + lang.dump(r));
3351                                         break;
3352                                     }
3353                                 }
3354                             }
3355                         }
3356
3357                         if (roll) {
3358                             // Y.log("rollup: " +  i + ", " + lang.dump(this, 1));
3359                             // add the rollup
3360                             r[i] = true;
3361                             rolled = true;
3362
3363                             // expand the rollup's dependencies
3364                             this.getRequires(m);
3365                         }
3366                     }
3367                 }
3368
3369                 // if we made it here w/o rolling up something, we are done
3370                 if (!rolled) {
3371                     break;
3372                 }
3373             }
3374         },
3375
3376         /**
3377          * Remove superceded modules and loaded modules.  Called by
3378          * calculate() after we have the mega list of all dependencies
3379          * @method _reduce
3380          * @private
3381          */
3382         _reduce: function() {
3383
3384             var i, j, s, m, r=this.required;
3385             for (i in r) {
3386
3387                 // remove if already loaded
3388                 if (i in this.loaded) {
3389                     delete r[i];
3390
3391                 // remove anything this module supersedes
3392                 } else {
3393
3394                     var skinDef = this.parseSkin(i);
3395
3396                     if (skinDef) {
3397                         //YAHOO.log("skin found in reduce: " + skinDef.skin + ", " + skinDef.module);
3398                         // the skin rollup will not have a module name
3399                         if (!skinDef.module) {
3400                             var skin_pre = this.SKIN_PREFIX + skinDef.skin;
3401                             //YAHOO.log("skin_pre: " + skin_pre);
3402                             for (j in r) {
3403
3404                                 if (lang.hasOwnProperty(r, j)) {
3405                                     m = this.moduleInfo[j];
3406                                     var ext = m && m.ext;
3407                                     if (!ext && j !== i && j.indexOf(skin_pre) > -1) {
3408                                         // Y.log ("removing component skin: " + j);
3409                                         delete r[j];
3410                                     }
3411                                 }
3412                             }
3413                         }
3414                     } else {
3415
3416                          m = this.moduleInfo[i];
3417                          s = m && m.supersedes;
3418                          if (s) {
3419                              for (j=0; j<s.length; j=j+1) {
3420                                  if (s[j] in r) {
3421                                      delete r[s[j]];
3422                                  }
3423                              }
3424                          }
3425                     }
3426                 }
3427             }
3428         },
3429
3430         _onFailure: function(msg) {
3431             YAHOO.log('Failure', 'info', 'loader');
3432
3433             var f = this.onFailure;
3434             if (f) {
3435                 f.call(this.scope, {
3436                     msg: 'failure: ' + msg,
3437                     data: this.data,
3438                     success: false
3439                 });
3440             }
3441         },
3442
3443         _onTimeout: function() {
3444             YAHOO.log('Timeout', 'info', 'loader');
3445             var f = this.onTimeout;
3446             if (f) {
3447                 f.call(this.scope, {
3448                     msg: 'timeout',
3449                     data: this.data,
3450                     success: false
3451                 });
3452             }
3453         },
3454
3455         /**
3456          * Sorts the dependency tree.  The last step of calculate()
3457          * @method _sort
3458          * @private
3459          */
3460         _sort: function() {
3461             // create an indexed list
3462             var s=[], info=this.moduleInfo, loaded=this.loaded,
3463                 checkOptional=!this.loadOptional, me = this;
3464
3465             // returns true if b is not loaded, and is required
3466             // directly or by means of modules it supersedes.
3467             var requires = function(aa, bb) {
3468
3469                 var mm=info[aa];
3470
3471                 if (loaded[bb] || !mm) {
3472                     return false;
3473                 }
3474
3475                 var ii,
3476                     rr = mm.expanded,
3477                     after = mm.after,
3478                     other = info[bb],
3479                     optional = mm.optional;
3480
3481
3482                 // check if this module requires the other directly
3483                 if (rr && YUI.ArrayUtil.indexOf(rr, bb) > -1) {
3484                     return true;
3485                 }
3486
3487                 // check if this module should be sorted after the other
3488                 if (after && YUI.ArrayUtil.indexOf(after, bb) > -1) {
3489                     return true;
3490                 }
3491
3492                 // if loadOptional is not specified, optional dependencies still
3493                 // must be sorted correctly when present.
3494                 if (checkOptional && optional && YUI.ArrayUtil.indexOf(optional, bb) > -1) {
3495                     return true;
3496                 }
3497
3498                 // check if this module requires one the other supersedes
3499                 var ss=info[bb] && info[bb].supersedes;
3500                 if (ss) {
3501                     for (ii=0; ii<ss.length; ii=ii+1) {
3502                         if (requires(aa, ss[ii])) {
3503                             return true;
3504                         }
3505                     }
3506                 }
3507
3508                 // external css files should be sorted below yui css
3509                 if (mm.ext && mm.type == 'css' && !other.ext && other.type == 'css') {
3510                     return true;
3511                 }
3512
3513                 return false;
3514             };
3515
3516             // get the required items out of the obj into an array so we
3517             // can sort
3518             for (var i in this.required) {
3519                 if (lang.hasOwnProperty(this.required, i)) {
3520                     s.push(i);
3521                 }
3522             }
3523
3524             // pointer to the first unsorted item
3525             var p=0;
3526
3527             // keep going until we make a pass without moving anything
3528             for (;;) {
3529
3530                 var l=s.length, a, b, j, k, moved=false;
3531
3532                 // start the loop after items that are already sorted
3533                 for (j=p; j<l; j=j+1) {
3534
3535                     // check the next module on the list to see if its
3536                     // dependencies have been met
3537                     a = s[j];
3538
3539                     // check everything below current item and move if we
3540                     // find a requirement for the current item
3541                     for (k=j+1; k<l; k=k+1) {
3542                         if (requires(a, s[k])) {
3543
3544                             // extract the dependency so we can move it up
3545                             b = s.splice(k, 1);
3546
3547                             // insert the dependency above the item that
3548                             // requires it
3549                             s.splice(j, 0, b[0]);
3550
3551                             moved = true;
3552                             break;
3553                         }
3554                     }
3555
3556                     // jump out of loop if we moved something
3557                     if (moved) {
3558                         break;
3559                     // this item is sorted, move our pointer and keep going
3560                     } else {
3561                         p = p + 1;
3562                     }
3563                 }
3564
3565                 // when we make it here and moved is false, we are
3566                 // finished sorting
3567                 if (!moved) {
3568                     break;
3569                 }
3570
3571             }
3572
3573             this.sorted = s;
3574         },
3575
3576         toString: function() {
3577             var o = {
3578                 type: "YUILoader",
3579                 base: this.base,
3580                 filter: this.filter,
3581                 required: this.required,
3582                 loaded: this.loaded,
3583                 inserted: this.inserted
3584             };
3585
3586             lang.dump(o, 1);
3587         },
3588
3589         _combine: function() {
3590
3591                 this._combining = [];
3592
3593                 var self = this,
3594                     s=this.sorted,
3595                     len = s.length,
3596                     js = this.comboBase,
3597                     css = this.comboBase,
3598                     target,
3599                     startLen = js.length,
3600                     i, m, type = this.loadType;
3601
3602                 YAHOO.log('type ' + type);
3603
3604                 for (i=0; i<len; i=i+1) {
3605
3606                     m = this.moduleInfo[s[i]];
3607
3608                     if (m && !m.ext && (!type || type === m.type)) {
3609
3610                         target = this.root + m.path;
3611
3612                         // if (i < len-1) {
3613                         target += '&';
3614                         // }
3615
3616                         if (m.type == 'js') {
3617                             js += target;
3618                         } else {
3619                             css += target;
3620                         }
3621
3622                         // YAHOO.log(target);
3623                         this._combining.push(s[i]);
3624                     }
3625                 }
3626
3627                 if (this._combining.length) {
3628
3629 YAHOO.log('Attempting to combine: ' + this._combining, "info", "loader");
3630
3631                     var callback=function(o) {
3632                         // YAHOO.log('Combo complete: ' + o.data, "info", "loader");
3633                         // this._combineComplete = true;
3634
3635                         var c=this._combining, len=c.length, i, m;
3636                         for (i=0; i<len; i=i+1) {
3637                             this.inserted[c[i]] = true;
3638                         }
3639
3640                         this.loadNext(o.data);
3641                     },
3642
3643                     loadScript = function() {
3644                         // YAHOO.log('combining js: ' + js);
3645                         if (js.length > startLen) {
3646                             YAHOO.util.Get.script(self._filter(js), {
3647                                 data: self._loading,
3648                                 onSuccess: callback,
3649                                 onFailure: self._onFailure,
3650                                 onTimeout: self._onTimeout,
3651                                 insertBefore: self.insertBefore,
3652                                 charset: self.charset,
3653                                 timeout: self.timeout,
3654                                 scope: self
3655                             });
3656                         } else {
3657                             this.loadNext();
3658                         }
3659                     };
3660
3661                     // load the css first
3662                     // YAHOO.log('combining css: ' + css);
3663                     if (css.length > startLen) {
3664                         YAHOO.util.Get.css(this._filter(css), {
3665                             data: this._loading,
3666                             onSuccess: loadScript,
3667                             onFailure: this._onFailure,
3668                             onTimeout: this._onTimeout,
3669                             insertBefore: this.insertBefore,
3670                             charset: this.charset,
3671                             timeout: this.timeout,
3672                             scope: self
3673                         });
3674                     } else {
3675                         loadScript();
3676                     }
3677
3678                     return;
3679
3680                 } else {
3681                     // this._combineComplete = true;
3682                     this.loadNext(this._loading);
3683                 }
3684         },
3685
3686         /**
3687          * inserts the requested modules and their dependencies.
3688          * <code>type</code> can be "js" or "css".  Both script and
3689          * css are inserted if type is not provided.
3690          * @method insert
3691          * @param o optional options object
3692          * @param type {string} the type of dependency to insert
3693          */
3694         insert: function(o, type) {
3695             // if (o) {
3696             //     Y.log("insert: " + lang.dump(o, 1) + ", " + type);
3697             // } else {
3698             //     Y.log("insert: " + this.toString() + ", " + type);
3699             // }
3700
3701             // build the dependency list
3702             this.calculate(o);
3703
3704
3705             // set a flag to indicate the load has started
3706             this._loading = true;
3707
3708             // flag to indicate we are done with the combo service
3709             // and any additional files will need to be loaded
3710             // individually
3711             // this._combineComplete = false;
3712
3713             // keep the loadType (js, css or undefined) cached
3714             this.loadType = type;
3715
3716             if (this.combine) {
3717                 return this._combine();
3718             }
3719
3720             if (!type) {
3721                 // Y.log("trying to load css first");
3722                 var self = this;
3723                 this._internalCallback = function() {
3724                             self._internalCallback = null;
3725                             self.insert(null, "js");
3726                         };
3727                 this.insert(null, "css");
3728                 return;
3729             }
3730
3731
3732             // start the load
3733             this.loadNext();
3734
3735         },
3736
3737         /**
3738          * Interns the script for the requested modules.  The callback is
3739          * provided a reference to the sandboxed YAHOO object.  This only
3740          * applies to the script: css can not be sandboxed; css will be
3741          * loaded into the page normally if specified.
3742          * @method sandbox
3743          * @param callback {Function} the callback to exectued when the load is
3744          *        complete.
3745          */
3746         sandbox: function(o, type) {
3747             // if (o) {
3748                 // YAHOO.log("sandbox: " + lang.dump(o, 1) + ", " + type);
3749             // } else {
3750                 // YAHOO.log("sandbox: " + this.toString() + ", " + type);
3751             // }
3752
3753             var self = this,
3754                 success = function(o) {
3755
3756                     var idx=o.argument[0], name=o.argument[2];
3757
3758                     // store the response in the position it was requested
3759                     self._scriptText[idx] = o.responseText;
3760
3761                     // YAHOO.log("received: " + o.responseText.substr(0, 100) + ", " + idx);
3762
3763                     if (self.onProgress) {
3764                         self.onProgress.call(self.scope, {
3765                                     name: name,
3766                                     scriptText: o.responseText,
3767                                     xhrResponse: o,
3768                                     data: self.data
3769                                 });
3770                     }
3771
3772                     // only generate the sandbox once everything is loaded
3773                     self._loadCount++;
3774
3775                     if (self._loadCount >= self._stopCount) {
3776
3777                         // the variable to find
3778                         var v = self.varName || "YAHOO";
3779
3780                         // wrap the contents of the requested modules in an anonymous function
3781                         var t = "(function() {\n";
3782
3783                         // return the locally scoped reference.
3784                         var b = "\nreturn " + v + ";\n})();";
3785
3786                         var ref = eval(t + self._scriptText.join("\n") + b);
3787
3788                         self._pushEvents(ref);
3789
3790                         if (ref) {
3791                             self.onSuccess.call(self.scope, {
3792                                     reference: ref,
3793                                     data: self.data
3794                                 });
3795                         } else {
3796                             self._onFailure.call(self.varName + " reference failure");
3797                         }
3798                     }
3799                 },
3800
3801                 failure = function(o) {
3802                     self.onFailure.call(self.scope, {
3803                             msg: "XHR failure",
3804                             xhrResponse: o,
3805                             data: self.data
3806                         });
3807                 };
3808
3809             self._config(o);
3810
3811             if (!self.onSuccess) {
3812 throw new Error("You must supply an onSuccess handler for your sandbox");
3813             }
3814
3815             self._sandbox = true;
3816
3817
3818             // take care of any css first (this can't be sandboxed)
3819             if (!type || type !== "js") {
3820                 self._internalCallback = function() {
3821                             self._internalCallback = null;
3822                             self.sandbox(null, "js");
3823                         };
3824                 self.insert(null, "css");
3825                 return;
3826             }
3827
3828             // get the connection manager if not on the page
3829             if (!util.Connect) {
3830                 // get a new loader instance to load connection.
3831                 var ld = new YAHOO.util.YUILoader();
3832                 ld.insert({
3833                     base: self.base,
3834                     filter: self.filter,
3835                     require: "connection",
3836                     insertBefore: self.insertBefore,
3837                     charset: self.charset,
3838                     onSuccess: function() {
3839                         self.sandbox(null, "js");
3840                     },
3841                     scope: self
3842                 }, "js");
3843                 return;
3844             }
3845
3846             self._scriptText = [];
3847             self._loadCount = 0;
3848             self._stopCount = self.sorted.length;
3849             self._xhr = [];
3850
3851             self.calculate();
3852
3853             var s=self.sorted, l=s.length, i, m, url;
3854
3855             for (i=0; i<l; i=i+1) {
3856                 m = self.moduleInfo[s[i]];
3857
3858                 // undefined modules cause a failure
3859                 if (!m) {
3860                     self._onFailure("undefined module " + m);
3861                     for (var j=0;j<self._xhr.length;j=j+1) {
3862                         self._xhr[j].abort();
3863                     }
3864                     return;
3865                 }
3866
3867                 // css files should be done
3868                 if (m.type !== "js") {
3869                     self._loadCount++;
3870                     continue;
3871                 }
3872
3873                 url = m.fullpath;
3874                 url = (url) ? self._filter(url) : self._url(m.path);
3875
3876                 // YAHOO.log("xhr request: " + url + ", " + i);
3877
3878                 var xhrData = {
3879                     success: success,
3880                     failure: failure,
3881                     scope: self,
3882                     // [module index, module name, sandbox name]
3883                     argument: [i, url, s[i]]
3884                 };
3885
3886                 self._xhr.push(util.Connect.asyncRequest('GET', url, xhrData));
3887             }
3888         },
3889
3890         /**
3891          * Executed every time a module is loaded, and if we are in a load
3892          * cycle, we attempt to load the next script.  Public so that it
3893          * is possible to call this if using a method other than
3894          * YAHOO.register to determine when scripts are fully loaded
3895          * @method loadNext
3896          * @param mname {string} optional the name of the module that has
3897          * been loaded (which is usually why it is time to load the next
3898          * one)
3899          */
3900         loadNext: function(mname) {
3901
3902             // It is possible that this function is executed due to something
3903             // else one the page loading a YUI module.  Only react when we
3904             // are actively loading something
3905             if (!this._loading) {
3906                 return;
3907             }
3908
3909             var self = this,
3910                 donext = function(o) {
3911                     self.loadNext(o.data);
3912                 }, successfn, s = this.sorted, len=s.length, i, fn, m, url;
3913
3914
3915             if (mname) {
3916
3917                 // if the module that was just loaded isn't what we were expecting,
3918                 // continue to wait
3919                 if (mname !== this._loading) {
3920                     return;
3921                 }
3922
3923                 // YAHOO.log("loadNext executing, just loaded " + mname);
3924
3925                 // The global handler that is called when each module is loaded
3926                 // will pass that module name to this function.  Storing this
3927                 // data to avoid loading the same module multiple times
3928                 this.inserted[mname] = true;
3929
3930                 if (this.onProgress) {
3931                     this.onProgress.call(this.scope, {
3932                             name: mname,
3933                             data: this.data
3934                         });
3935                 }
3936                 //var o = this.getProvides(mname);
3937                 //this.inserted = lang.merge(this.inserted, o);
3938             }
3939
3940
3941
3942             for (i=0; i<len; i=i+1) {
3943
3944                 // This.inserted keeps track of what the loader has loaded
3945                 if (s[i] in this.inserted) {
3946                     // YAHOO.log(s[i] + " alread loaded ");
3947                     continue;
3948                 }
3949
3950                 // Because rollups will cause multiple load notifications
3951                 // from YAHOO, loadNext may be called multiple times for
3952                 // the same module when loading a rollup.  We can safely
3953                 // skip the subsequent requests
3954                 if (s[i] === this._loading) {
3955                     // YAHOO.log("still loading " + s[i] + ", waiting");
3956                     return;
3957                 }
3958
3959                 // log("inserting " + s[i]);
3960                 m = this.moduleInfo[s[i]];
3961
3962                 if (!m) {
3963                     this.onFailure.call(this.scope, {
3964                             msg: "undefined module " + m,
3965                             data: this.data
3966                         });
3967                     return;
3968                 }
3969
3970                 // The load type is stored to offer the possibility to load
3971                 // the css separately from the script.
3972                 if (!this.loadType || this.loadType === m.type) {
3973
3974                     successfn = donext;
3975
3976                     this._loading = s[i];
3977                     //YAHOO.log("attempting to load " + s[i] + ", " + this.base);
3978
3979                     fn = (m.type === "css") ? util.Get.css : util.Get.script;
3980                     url = m.fullpath;
3981                     url = (url) ? this._filter(url) : this._url(m.path);
3982
3983                     // safari 2.x or lower, script, and part of YUI
3984                     if (env.ua.webkit && env.ua.webkit < 420 && m.type === "js" &&
3985                           !m.varName) {
3986                           //YUI.info.moduleInfo[s[i]]) {
3987                           //YAHOO.log("using YAHOO env " + s[i] + ", " + m.varName);
3988                         successfn = null;
3989                         this._useYahooListener = true;
3990                     }
3991
3992                     fn(url, {
3993                         data: s[i],
3994                         onSuccess: successfn,
3995                         onFailure: this._onFailure,
3996                         onTimeout: this._onTimeout,
3997                         insertBefore: this.insertBefore,
3998                         charset: this.charset,
3999                         timeout: this.timeout,
4000                         varName: m.varName,
4001                         scope: self
4002                     });
4003
4004                     return;
4005                 }
4006             }
4007
4008             // we are finished
4009             this._loading = null;
4010
4011             // internal callback for loading css first
4012             if (this._internalCallback) {
4013                 var f = this._internalCallback;
4014                 this._internalCallback = null;
4015                 f.call(this);
4016             } else if (this.onSuccess) {
4017                 this._pushEvents();
4018                 this.onSuccess.call(this.scope, {
4019                         data: this.data
4020                     });
4021             }
4022
4023         },
4024
4025         /**
4026          * In IE, the onAvailable/onDOMReady events need help when Event is
4027          * loaded dynamically
4028          * @method _pushEvents
4029          * @param {Function} optional function reference
4030          * @private
4031          */
4032         _pushEvents: function(ref) {
4033             var r = ref || YAHOO;
4034             if (r.util && r.util.Event) {
4035                 r.util.Event._load();
4036             }
4037         },
4038
4039         /**
4040          * Applies filter
4041          * method _filter
4042          * @return {string} the filtered string
4043          * @private
4044          */
4045         _filter: function(str) {
4046             var f = this.filter;
4047             return (f) ?  str.replace(new RegExp(f.searchExp, 'g'), f.replaceStr) : str;
4048         },
4049
4050         /**
4051          * Generates the full url for a module
4052          * method _url
4053          * @param path {string} the path fragment
4054          * @return {string} the full url
4055          * @private
4056          */
4057         _url: function(path) {
4058             return this._filter((this.base || "") + path);
4059         }
4060
4061     };
4062
4063 })();
4064
4065 YAHOO.register("yuiloader", YAHOO.util.YUILoader, {version: "2.9.0", build: "2800"});