Import Dromaeo to WebKit repository.
[WebKit-https.git] / PerformanceTests / Dromaeo / resources / dromaeo / web / lib / dojo.js
1 /*
2         Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
3         Available via Academic Free License >= 2.1 OR the modified BSD license.
4         see: http://dojotoolkit.org/license for details
5 */
6
7 /*
8         This is a compiled version of Dojo, built for deployment and not for
9         development. To get an editable version, please visit:
10
11                 http://dojotoolkit.org
12
13         for documentation and information on getting the source.
14 */
15
16 ;(function(){
17
18         /*
19         dojo, dijit, and dojox must always be the first three, and in that order.
20         djConfig.scopeMap = [
21                 ["dojo", "fojo"],
22                 ["dijit", "fijit"],
23                 ["dojox", "fojox"]
24         
25         ]
26         */
27
28         /**Build will replace this comment with a scoped djConfig **/
29
30         //The null below can be relaced by a build-time value used instead of djConfig.scopeMap.
31         var sMap = null;
32
33         //See if new scopes need to be defined.
34         if((sMap || (typeof djConfig != "undefined" && djConfig.scopeMap)) && (typeof window != "undefined")){
35                 var scopeDef = "", scopePrefix = "", scopeSuffix = "", scopeMap = {}, scopeMapRev = {};
36                 sMap = sMap || djConfig.scopeMap;
37                 for(var i = 0; i < sMap.length; i++){
38                         //Make local variables, then global variables that use the locals.
39                         var newScope = sMap[i];
40                         scopeDef += "var " + newScope[0] + " = {}; " + newScope[1] + " = " + newScope[0] + ";" + newScope[1] + "._scopeName = '" + newScope[1] + "';";
41                         scopePrefix += (i == 0 ? "" : ",") + newScope[0];
42                         scopeSuffix += (i == 0 ? "" : ",") + newScope[1];
43                         scopeMap[newScope[0]] = newScope[1];
44                         scopeMapRev[newScope[1]] = newScope[0];
45                 }
46
47                 eval(scopeDef + "dojo._scopeArgs = [" + scopeSuffix + "];");
48
49                 dojo._scopePrefixArgs = scopePrefix;
50                 dojo._scopePrefix = "(function(" + scopePrefix + "){";
51                 dojo._scopeSuffix = "})(" + scopeSuffix + ")";
52                 dojo._scopeMap = scopeMap;
53                 dojo._scopeMapRev = scopeMapRev;
54         }
55
56 /*=====
57 // note:
58 //              'djConfig' does not exist under 'dojo.*' so that it can be set before the
59 //              'dojo' variable exists.
60 // note:
61 //              Setting any of these variables *after* the library has loaded does
62 //              nothing at all.
63
64 djConfig = {
65         // summary:
66         //              Application code can set the global 'djConfig' prior to loading
67         //              the library to override certain global settings for how dojo works.
68         //
69         // isDebug: Boolean
70         //              Defaults to `false`. If set to `true`, ensures that Dojo provides
71         //              extended debugging feedback via Firebug. If Firebug is not available
72         //              on your platform, setting `isDebug` to `true` will force Dojo to
73         //              pull in (and display) the version of Firebug Lite which is
74         //              integrated into the Dojo distribution, thereby always providing a
75         //              debugging/logging console when `isDebug` is enabled. Note that
76         //              Firebug's `console.*` methods are ALWAYS defined by Dojo. If
77         //              `isDebug` is false and you are on a platform without Firebug, these
78         //              methods will be defined as no-ops.
79         isDebug: false,
80         // debugAtAllCosts: Boolean
81         //              Defaults to `false`. If set to `true`, this triggers an alternate
82         //              mode of the package system in which dependencies are detected and
83         //              only then are resources evaluated in dependency order via
84         //              `<script>` tag inclusion. This may double-request resources and
85         //              cause problems with scripts which expect `dojo.require()` to
86         //              preform synchronously. `debugAtAllCosts` can be an invaluable
87         //              debugging aid, but when using it, ensure that all code which
88         //              depends on Dojo modules is wrapped in `dojo.addOnLoad()` handlers.
89         //              Due to the somewhat unpredictable side-effects of using
90         //              `debugAtAllCosts`, it is strongly recommended that you enable this
91         //              flag as a last resort. `debugAtAllCosts` has no effect when loading
92         //              resources across domains. For usage information, see the
93         //              [Dojo Book](http://dojotoolkit.org/book/book-dojo/part-4-meta-dojo-making-your-dojo-code-run-faster-and-better/debugging-facilities/deb)
94         debugAtAllCosts: false,
95         // locale: String
96         //              The locale to assume for loading localized resources in this page,
97         //              specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt).
98         //              Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`.
99         //              See the documentation for `dojo.i18n` and `dojo.requireLocalization`
100         //              for details on loading localized resources. If no locale is specified,
101         //              Dojo assumes the locale of the user agent, according to `navigator.userLanguage`
102         //              or `navigator.language` properties.
103         locale: undefined,
104         // extraLocale: Array
105         //              No default value. Specifies additional locales whose
106         //              resources should also be loaded alongside the default locale when
107         //              calls to `dojo.requireLocalization()` are processed.
108         extraLocale: undefined,
109         // baseUrl: String
110         //              The directory in which `dojo.js` is located. Under normal
111         //              conditions, Dojo auto-detects the correct location from which it
112         //              was loaded. You may need to manually configure `baseUrl` in cases
113         //              where you have renamed `dojo.js` or in which `<base>` tags confuse
114         //              some browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned
115         //              either the value of `djConfig.baseUrl` if one is provided or the
116         //              auto-detected root if not. Other modules are located relative to
117         //              this path.
118         baseUrl: undefined,
119         // modulePaths: Object
120         //              A map of module names to paths relative to `dojo.baseUrl`. The
121         //              key/value pairs correspond directly to the arguments which
122         //              `dojo.registerModulePath` accepts. Specifiying
123         //              `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent
124         //              of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple
125         //              modules may be configured via `djConfig.modulePaths`.
126         modulePaths: {},
127         // afterOnLoad: Boolean 
128         //              Indicates Dojo was added to the page after the page load. In this case
129         //              Dojo will not wait for the page DOMContentLoad/load events and fire
130         //              its dojo.addOnLoad callbacks after making sure all outstanding
131         //              dojo.required modules have loaded.
132         afterOnLoad: false,
133         // addOnLoad: Function or Array
134         //              Adds a callback via dojo.addOnLoad. Useful when Dojo is added after
135         //              the page loads and djConfig.afterOnLoad is true. Supports the same
136         //              arguments as dojo.addOnLoad. When using a function reference, use
137         //              `djConfig.addOnLoad = function(){};`. For object with function name use
138         //              `djConfig.addOnLoad = [myObject, "functionName"];` and for object with
139         //              function reference use
140         //              `djConfig.addOnLoad = [myObject, function(){}];`
141         addOnLoad: null,
142         // require: Array
143         //              An array of module names to be loaded immediately after dojo.js has been included
144         //              in a page. 
145         require: []
146 }
147 =====*/
148
149 (function(){
150         // firebug stubs
151
152         // if((!this["console"])||(!console["firebug"])){
153
154         if(!this["console"]){
155                 this.console = {
156                 };
157         }
158
159         //      Be careful to leave 'log' always at the end
160         var cn = [
161                 "assert", "count", "debug", "dir", "dirxml", "error", "group",
162                 "groupEnd", "info", "profile", "profileEnd", "time", "timeEnd",
163                 "trace", "warn", "log" 
164         ];
165         var i=0, tn;
166         while((tn=cn[i++])){
167                 if(!console[tn]){
168                         (function(){
169                                 var tcn = tn+"";
170                                 console[tcn] = ('log' in console) ? function(){ 
171                                         var a = Array.apply({}, arguments);
172                                         a.unshift(tcn+":");
173                                         console["log"](a.join(" "));
174                                 } : function(){}
175                         })();
176                 }
177         }
178
179         //TODOC:  HOW TO DOC THIS?
180         // dojo is the root variable of (almost all) our public symbols -- make sure it is defined.
181         if(typeof dojo == "undefined"){
182                 this.dojo = {
183                         _scopeName: "dojo",
184                         _scopePrefix: "",
185                         _scopePrefixArgs: "",
186                         _scopeSuffix: "",
187                         _scopeMap: {},
188                         _scopeMapRev: {}
189                 };
190         }
191
192         var d = dojo;
193
194         //Need placeholders for dijit and dojox for scoping code.
195         if(typeof dijit == "undefined"){
196                 this.dijit = {_scopeName: "dijit"};
197         }
198         if(typeof dojox == "undefined"){
199                 this.dojox = {_scopeName: "dojox"};
200         }
201         
202         if(!d._scopeArgs){
203                 d._scopeArgs = [dojo, dijit, dojox];
204         }
205
206 /*=====
207 dojo.global = {
208         //      summary:
209         //              Alias for the global scope
210         //              (e.g. the window object in a browser).
211         //      description:
212         //              Refer to 'dojo.global' rather than referring to window to ensure your
213         //              code runs correctly in contexts other than web browsers (e.g. Rhino on a server).
214 }
215 =====*/
216         d.global = this;
217
218         d.config =/*===== djConfig = =====*/{
219                 isDebug: false,
220                 debugAtAllCosts: false
221         };
222
223         if(typeof djConfig != "undefined"){
224                 for(var opt in djConfig){
225                         d.config[opt] = djConfig[opt];
226                 }
227         }
228
229         var _platforms = ["Browser", "Rhino", "Spidermonkey", "Mobile"];
230         var t;
231         while((t=_platforms.shift())){
232                 d["is"+t] = false;
233         }
234
235 /*=====
236         // Override locale setting, if specified
237         dojo.locale = {
238                 // summary: the locale as defined by Dojo (read-only)
239         };
240 =====*/
241         dojo.locale = d.config.locale;
242         
243         var rev = "$Rev: 15729 $".match(/\d+/);
244
245         dojo.version = {
246                 // summary: 
247                 //              version number of dojo
248                 //      major: Integer
249                 //              Major version. If total version is "1.2.0beta1", will be 1
250                 //      minor: Integer
251                 //              Minor version. If total version is "1.2.0beta1", will be 2
252                 //      patch: Integer
253                 //              Patch version. If total version is "1.2.0beta1", will be 0
254                 //      flag: String
255                 //              Descriptor flag. If total version is "1.2.0beta1", will be "beta1"
256                 //      revision: Number
257                 //              The SVN rev from which dojo was pulled
258                 major: 1, minor: 2, patch: 2, flag: "",
259                 revision: rev ? +rev[0] : 999999, //FIXME: use NaN?
260                 toString: function(){
261                         with(d.version){
262                                 return major + "." + minor + "." + patch + flag + " (" + revision + ")";        // String
263                         }
264                 }
265         }
266
267         // Register with the OpenAjax hub
268         if(typeof OpenAjax != "undefined"){
269                 OpenAjax.hub.registerLibrary(dojo._scopeName, "http://dojotoolkit.org", d.version.toString());
270         }
271
272         dojo._mixin = function(/*Object*/ obj, /*Object*/ props){
273                 // summary:
274                 //              Adds all properties and methods of props to obj. This addition
275                 //              is "prototype extension safe", so that instances of objects
276                 //              will not pass along prototype defaults.
277                 var tobj = {};
278                 for(var x in props){
279                         // the "tobj" condition avoid copying properties in "props"
280                         // inherited from Object.prototype.  For example, if obj has a custom
281                         // toString() method, don't overwrite it with the toString() method
282                         // that props inherited from Object.prototype
283                         if(tobj[x] === undefined || tobj[x] != props[x]){
284                                 obj[x] = props[x];
285                         }
286                 }
287                 // IE doesn't recognize custom toStrings in for..in
288                 if(d["isIE"] && props){
289                         var p = props.toString;
290                         if(typeof p == "function" && p != obj.toString && p != tobj.toString &&
291                                 p != "\nfunction toString() {\n    [native code]\n}\n"){
292                                         obj.toString = props.toString;
293                         }
294                 }
295                 return obj; // Object
296         }
297
298         dojo.mixin = function(/*Object*/obj, /*Object...*/props){
299                 // summary:     
300                 //              Adds all properties and methods of props to obj and returns the
301                 //              (now modified) obj.
302                 //      description:
303                 //              `dojo.mixin` can mix multiple source objects into a
304                 //              destionation object which is then returned. Unlike regular
305                 //              `for...in` iteration, `dojo.mixin` is also smart about avoiding
306                 //              extensions which other toolkits may unwisely add to the root
307                 //              object prototype
308                 //      obj:
309                 //              The object to mix properties into. Also the return value.
310                 //      props:
311                 //              One or more objects whose values are successively copied into
312                 //              obj. If more than one of these objects contain the same value,
313                 //              the one specified last in the function call will "win".
314                 //      example:
315                 //              make a shallow copy of an object
316                 //      |       var copy = dojo.mixin({}, source);
317                 //      example:
318                 //              many class constructors often take an object which specifies
319                 //              values to be configured on the object. In this case, it is
320                 //              often simplest to call `dojo.mixin` on the `this` object:
321                 //      |       dojo.declare("acme.Base", null, {
322                 //      |               constructor: function(properties){
323                 //      |                       // property configuration:
324                 //      |                       dojo.mixin(this, properties);
325                 //      |       
326                 //      |                       
327                 //      |                       //  ...
328                 //      |               },
329                 //      |               quip: "I wasn't born yesterday, you know - I've seen movies.",
330                 //      |               // ...
331                 //      |       });
332                 //      |
333                 //      |       // create an instance of the class and configure it
334                 //      |       var b = new acme.Base({quip: "That's what it does!" });
335                 //      example:
336                 //              copy in properties from multiple objects
337                 //      |       var flattened = dojo.mixin(
338                 //      |               {
339                 //      |                       name: "Frylock",
340                 //      |                       braces: true
341                 //      |               },
342                 //      |               {
343                 //      |                       name: "Carl Brutanananadilewski"
344                 //      |               }
345                 //      |       );
346                 //      |       
347                 //      |       // will print "Carl Brutanananadilewski"
348                 //      |       
349                 //      |       // will print "true"
350                 //      |       
351                 for(var i=1, l=arguments.length; i<l; i++){
352                         d._mixin(obj, arguments[i]);
353                 }
354                 return obj; // Object
355         }
356
357         dojo._getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
358                 var obj=context || d.global;
359                 for(var i=0, p; obj && (p=parts[i]); i++){
360                         if(i == 0 && this._scopeMap[p]){
361                                 p = this._scopeMap[p];
362                         }
363                         obj = (p in obj ? obj[p] : (create ? obj[p]={} : undefined));
364                 }
365                 return obj; // mixed
366         }
367
368         dojo.setObject = function(/*String*/name, /*Object*/value, /*Object?*/context){
369                 // summary: 
370                 //              Set a property from a dot-separated string, such as "A.B.C"
371                 //      description: 
372                 //              Useful for longer api chains where you have to test each object in
373                 //              the chain, or when you have an object reference in string format.
374                 //              Objects are created as needed along `path`. Returns the passed
375                 //              value if setting is successful or `undefined` if not.
376                 //      name:   
377                 //              Path to a property, in the form "A.B.C".
378                 //      context:
379                 //              Optional. Object to use as root of path. Defaults to
380                 //              `dojo.global`.
381                 //      example:
382                 //              set the value of `foo.bar.baz`, regardless of whether
383                 //              intermediate objects already exist:
384                 //      |       dojo.setObject("foo.bar.baz", value);
385                 //      example:
386                 //              without `dojo.setObject`, we often see code like this:
387                 //      |       // ensure that intermediate objects are available
388                 //      |       if(!obj["parent"]){ obj.parent = {}; }
389                 //      |       if(!obj.parent["child"]){ obj.parent.child= {}; }
390                 //      |       // now we can safely set the property
391                 //      |       obj.parent.child.prop = "some value";
392                 //              wheras with `dojo.setObject`, we can shorten that to:
393                 //      |       dojo.setObject("parent.child.prop", "some value", obj);
394                 var parts=name.split("."), p=parts.pop(), obj=d._getProp(parts, true, context);
395                 return obj && p ? (obj[p]=value) : undefined; // Object
396         }
397
398         dojo.getObject = function(/*String*/name, /*Boolean*/create, /*Object*/context){
399                 // summary: 
400                 //              Get a property from a dot-separated string, such as "A.B.C"
401                 //      description: 
402                 //              Useful for longer api chains where you have to test each object in
403                 //              the chain, or when you have an object reference in string format.
404                 //      name:   
405                 //              Path to an property, in the form "A.B.C".
406                 //      context:
407                 //              Optional. Object to use as root of path. Defaults to
408                 //              'dojo.global'. Null may be passed.
409                 //      create: 
410                 //              Optional. Defaults to `false`. If `true`, Objects will be
411                 //              created at any point along the 'path' that is undefined.
412                 return d._getProp(name.split("."), create, context); // Object
413         }
414
415         dojo.exists = function(/*String*/name, /*Object?*/obj){
416                 //      summary: 
417                 //              determine if an object supports a given method
418                 //      description: 
419                 //              useful for longer api chains where you have to test each object in
420                 //              the chain
421                 //      name:   
422                 //              Path to an object, in the form "A.B.C".
423                 //      obj:
424                 //              Object to use as root of path. Defaults to
425                 //              'dojo.global'. Null may be passed.
426                 //      example:
427                 //      |       // define an object
428                 //      |       var foo = {
429                 //      |               bar: { }
430                 //      |       };
431                 //      |
432                 //      |       // search the global scope
433                 //      |       dojo.exists("foo.bar"); // true
434                 //      |       dojo.exists("foo.bar.baz"); // false
435                 //      |
436                 //      |       // search from a particular scope
437                 //      |       dojo.exists("bar", foo); // true
438                 //      |       dojo.exists("bar.baz", foo); // false
439                 return !!d.getObject(name, false, obj); // Boolean
440         }
441
442
443         dojo["eval"] = function(/*String*/ scriptFragment){
444                 //      summary: 
445                 //              Perform an evaluation in the global scope. Use this rather than
446                 //              calling 'eval()' directly.
447                 //      description: 
448                 //              Placed in a separate function to minimize size of trapped
449                 //              exceptions. Calling eval() directly from some other scope may
450                 //              complicate tracebacks on some platforms.
451                 //      returns:
452                 //              The result of the evaluation. Often `undefined`
453
454
455                 // note:
456                 //       - JSC eval() takes an optional second argument which can be 'unsafe'.
457                 //       - Mozilla/SpiderMonkey eval() takes an optional second argument which is the
458                 //       scope object for new symbols.
459
460                 // FIXME: investigate Joseph Smarr's technique for IE:
461                 //              http://josephsmarr.com/2007/01/31/fixing-eval-to-use-global-scope-in-ie/
462                 //      see also:
463                 //              http://trac.dojotoolkit.org/ticket/744
464                 return d.global.eval ? d.global.eval(scriptFragment) : eval(scriptFragment);    // Object
465         }
466
467         /*=====
468                 dojo.deprecated = function(behaviour, extra, removal){
469                         //      summary: 
470                         //              Log a debug message to indicate that a behavior has been
471                         //              deprecated.
472                         //      behaviour: String
473                         //              The API or behavior being deprecated. Usually in the form
474                         //              of "myApp.someFunction()".
475                         //      extra: String?
476                         //              Text to append to the message. Often provides advice on a
477                         //              new function or facility to achieve the same goal during
478                         //              the deprecation period.
479                         //      removal: String?
480                         //              Text to indicate when in the future the behavior will be
481                         //              removed. Usually a version number.
482                         //      example:
483                         //      |       dojo.deprecated("myApp.getTemp()", "use myApp.getLocaleTemp() instead", "1.0");
484                 }
485
486                 dojo.experimental = function(moduleName, extra){
487                         //      summary: Marks code as experimental.
488                         //      description: 
489                         //              This can be used to mark a function, file, or module as
490                         //              experimental.  Experimental code is not ready to be used, and the
491                         //              APIs are subject to change without notice.  Experimental code may be
492                         //              completed deleted without going through the normal deprecation
493                         //              process.
494                         //      moduleName: String
495                         //              The name of a module, or the name of a module file or a specific
496                         //              function
497                         //      extra: String?
498                         //              some additional message for the user
499                         //      example:
500                         //      |       dojo.experimental("dojo.data.Result");
501                         //      example:
502                         //      |       dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA");
503                 }
504         =====*/
505
506         //Real functions declared in dojo._firebug.firebug.
507         d.deprecated = d.experimental = function(){};
508
509 })();
510 // vim:ai:ts=4:noet
511
512 /*
513  * loader.js - A bootstrap module.  Runs before the hostenv_*.js file. Contains
514  * all of the package loading methods.
515  */
516
517 (function(){
518         var d = dojo;
519
520         d.mixin(d, {
521                 _loadedModules: {},
522                 _inFlightCount: 0,
523                 _hasResource: {},
524
525                 _modulePrefixes: {
526                         dojo:   {       name: "dojo", value: "." },
527                         // dojox:       {       name: "dojox", value: "../dojox" },
528                         // dijit:       {       name: "dijit", value: "../dijit" },
529                         doh:    {       name: "doh", value: "../util/doh" },
530                         tests:  {       name: "tests", value: "tests" }
531                 },
532
533                 _moduleHasPrefix: function(/*String*/module){
534                         // summary: checks to see if module has been established
535                         var mp = this._modulePrefixes;
536                         return !!(mp[module] && mp[module].value); // Boolean
537                 },
538
539                 _getModulePrefix: function(/*String*/module){
540                         // summary: gets the prefix associated with module
541                         var mp = this._modulePrefixes;
542                         if(this._moduleHasPrefix(module)){
543                                 return mp[module].value; // String
544                         }
545                         return module; // String
546                 },
547
548                 _loadedUrls: [],
549
550                 //WARNING: 
551                 //              This variable is referenced by packages outside of bootstrap:
552                 //              FloatingPane.js and undo/browser.js
553                 _postLoad: false,
554                 
555                 //Egad! Lots of test files push on this directly instead of using dojo.addOnLoad.
556                 _loaders: [],
557                 _unloaders: [],
558                 _loadNotifying: false
559         });
560
561
562                 dojo._loadPath = function(/*String*/relpath, /*String?*/module, /*Function?*/cb){
563                 //      summary:
564                 //              Load a Javascript module given a relative path
565                 //
566                 //      description:
567                 //              Loads and interprets the script located at relpath, which is
568                 //              relative to the script root directory.  If the script is found but
569                 //              its interpretation causes a runtime exception, that exception is
570                 //              not caught by us, so the caller will see it.  We return a true
571                 //              value if and only if the script is found.
572                 //
573                 // relpath: 
574                 //              A relative path to a script (no leading '/', and typically ending
575                 //              in '.js').
576                 // module: 
577                 //              A module whose existance to check for after loading a path.  Can be
578                 //              used to determine success or failure of the load.
579                 // cb: 
580                 //              a callback function to pass the result of evaluating the script
581
582                 var uri = ((relpath.charAt(0) == '/' || relpath.match(/^\w+:/)) ? "" : this.baseUrl) + relpath;
583                 try{
584                         return !module ? this._loadUri(uri, cb) : this._loadUriAndCheck(uri, module, cb); // Boolean
585                 }catch(e){
586                         console.error(e);
587                         return false; // Boolean
588                 }
589         }
590
591         dojo._loadUri = function(/*String*/uri, /*Function?*/cb){
592                 //      summary:
593                 //              Loads JavaScript from a URI
594                 //      description:
595                 //              Reads the contents of the URI, and evaluates the contents.  This is
596                 //              used to load modules as well as resource bundles. Returns true if
597                 //              it succeeded. Returns false if the URI reading failed.  Throws if
598                 //              the evaluation throws.
599                 //      uri: a uri which points at the script to be loaded
600                 //      cb: 
601                 //              a callback function to process the result of evaluating the script
602                 //              as an expression, typically used by the resource bundle loader to
603                 //              load JSON-style resources
604
605                 if(this._loadedUrls[uri]){
606                         return true; // Boolean
607                 }
608                 var contents = this._getText(uri, true);
609                 if(!contents){ return false; } // Boolean
610                 this._loadedUrls[uri] = true;
611                 this._loadedUrls.push(uri);
612                 if(cb){
613                         contents = '('+contents+')';
614                 }else{
615                         //Only do the scoping if no callback. If a callback is specified,
616                         //it is most likely the i18n bundle stuff.
617                         contents = this._scopePrefix + contents + this._scopeSuffix;
618                 }
619                 if(d.isMoz){ contents += "\r\n//@ sourceURL=" + uri; } // debugging assist for Firebug
620                 var value = d["eval"](contents);
621                 if(cb){ cb(value); }
622                 return true; // Boolean
623         }
624         
625         // FIXME: probably need to add logging to this method
626         dojo._loadUriAndCheck = function(/*String*/uri, /*String*/moduleName, /*Function?*/cb){
627                 // summary: calls loadUri then findModule and returns true if both succeed
628                 var ok = false;
629                 try{
630                         ok = this._loadUri(uri, cb);
631                 }catch(e){
632                         console.error("failed loading " + uri + " with error: " + e);
633                 }
634                 return !!(ok && this._loadedModules[moduleName]); // Boolean
635         }
636
637         dojo.loaded = function(){
638                 // summary:
639                 //              signal fired when initial environment and package loading is
640                 //              complete. You may use dojo.addOnLoad() or dojo.connect() to
641                 //              this method in order to handle initialization tasks that
642                 //              require the environment to be initialized. In a browser host,
643                 //              declarative widgets will be constructed when this function
644                 //              finishes runing.
645                 this._loadNotifying = true;
646                 this._postLoad = true;
647                 var mll = d._loaders;
648
649                 //Clear listeners so new ones can be added
650                 //For other xdomain package loads after the initial load.
651                 this._loaders = [];
652
653                 for(var x = 0; x < mll.length; x++){
654                         mll[x]();
655                 }
656
657                 this._loadNotifying = false;
658                 
659                 //Make sure nothing else got added to the onload queue
660                 //after this first run. If something did, and we are not waiting for any
661                 //more inflight resources, run again.
662                 if(d._postLoad && d._inFlightCount == 0 && mll.length){
663                         d._callLoaded();
664                 }
665         }
666
667         dojo.unloaded = function(){
668                 // summary:
669                 //              signal fired by impending environment destruction. You may use
670                 //              dojo.addOnUnload() or dojo.connect() to this method to perform
671                 //              page/application cleanup methods. See dojo.addOnUnload for more info.
672                 var mll = this._unloaders;
673                 while(mll.length){
674                         (mll.pop())();
675                 }
676         }
677
678         d._onto = function(arr, obj, fn){
679                 if(!fn){
680                         arr.push(obj);
681                 }else if(fn){
682                         var func = (typeof fn == "string") ? obj[fn] : fn;
683                         arr.push(function(){ func.call(obj); });
684                 }
685         }
686
687         dojo.addOnLoad = function(/*Object?*/obj, /*String|Function*/functionName){
688                 // summary:
689                 //              Registers a function to be triggered after the DOM has finished
690                 //              loading and widgets declared in markup have been instantiated.
691                 //              Images and CSS files may or may not have finished downloading when
692                 //              the specified function is called.  (Note that widgets' CSS and HTML
693                 //              code is guaranteed to be downloaded before said widgets are
694                 //              instantiated.)
695                 // example:
696                 //      |       dojo.addOnLoad(functionPointer);
697                 //      |       dojo.addOnLoad(object, "functionName");
698                 //      |       dojo.addOnLoad(object, function(){ /* ... */});
699
700                 d._onto(d._loaders, obj, functionName);
701
702                 //Added for xdomain loading. dojo.addOnLoad is used to
703                 //indicate callbacks after doing some dojo.require() statements.
704                 //In the xdomain case, if all the requires are loaded (after initial
705                 //page load), then immediately call any listeners.
706                 if(d._postLoad && d._inFlightCount == 0 && !d._loadNotifying){
707                         d._callLoaded();
708                 }
709         }
710
711         //Support calling dojo.addOnLoad via djConfig.addOnLoad. Support all the
712         //call permutations of dojo.addOnLoad. Mainly useful when dojo is added
713         //to the page after the page has loaded.
714         var dca = d.config.addOnLoad;
715         if(dca){
716                 d.addOnLoad[(dca instanceof Array ? "apply" : "call")](d, dca);
717         }
718
719         dojo.addOnUnload = function(/*Object?*/obj, /*String|Function?*/functionName){
720                 // summary:
721                 //              registers a function to be triggered when the page unloads. In a browser
722                 //              enviroment, the functions will be triggered during the window.onbeforeunload
723                 //              event. Be careful doing work during window.onbeforeunload. onbeforeunload
724                 //              can be triggered if a link to download a file is clicked, or if the link is a
725                 //              javascript: link. In these cases, the onbeforeunload event fires, but the
726                 //              document is not actually destroyed. So be careful about doing destructive
727                 //              operations in a dojo.addOnUnload callback.
728                 // example:
729                 //      |       dojo.addOnUnload(functionPointer)
730                 //      |       dojo.addOnUnload(object, "functionName")
731                 //      |       dojo.addOnUnload(object, function(){ /* ... */});
732
733                 d._onto(d._unloaders, obj, functionName);
734         }
735
736         dojo._modulesLoaded = function(){
737                 if(d._postLoad){ return; }
738                 if(d._inFlightCount > 0){ 
739                         console.warn("files still in flight!");
740                         return;
741                 }
742                 d._callLoaded();
743         }
744
745         dojo._callLoaded = function(){
746
747                 // The "object" check is for IE, and the other opera check fixes an
748                 // issue in Opera where it could not find the body element in some
749                 // widget test cases.  For 0.9, maybe route all browsers through the
750                 // setTimeout (need protection still for non-browser environments
751                 // though). This might also help the issue with FF 2.0 and freezing
752                 // issues where we try to do sync xhr while background css images are
753                 // being loaded (trac #2572)? Consider for 0.9.
754                 if(typeof setTimeout == "object" || (dojo.config.useXDomain && d.isOpera)){
755                         if(dojo.isAIR){
756                                 setTimeout(function(){dojo.loaded();}, 0);
757                         }else{
758                                 setTimeout(dojo._scopeName + ".loaded();", 0);
759                         }
760                 }else{
761                         d.loaded();
762                 }
763         }
764
765         dojo._getModuleSymbols = function(/*String*/modulename){
766                 // summary:
767                 //              Converts a module name in dotted JS notation to an array
768                 //              representing the path in the source tree
769                 var syms = modulename.split(".");
770                 for(var i = syms.length; i>0; i--){
771                         var parentModule = syms.slice(0, i).join(".");
772                         if((i==1) && !this._moduleHasPrefix(parentModule)){             
773                                 // Support default module directory (sibling of dojo) for top-level modules 
774                                 syms[0] = "../" + syms[0];
775                         }else{
776                                 var parentModulePath = this._getModulePrefix(parentModule);
777                                 if(parentModulePath != parentModule){
778                                         syms.splice(0, i, parentModulePath);
779                                         break;
780                                 }
781                         }
782                 }
783                 // 
784                 return syms; // Array
785         }
786
787         dojo._global_omit_module_check = false;
788
789         dojo.loadInit = function(/*Function*/init){
790                 //      summary:
791                 //              Executes a function that needs to be executed for the loader's dojo.requireIf
792                 //              resolutions to work. This is needed mostly for the xdomain loader case where
793                 //              a function needs to be executed to set up the possible values for a dojo.requireIf
794                 //              call.
795                 //      init:
796                 //              a function reference. Executed immediately.
797                 //      description: This function is mainly a marker for the xdomain loader to know parts of
798                 //              code that needs be executed outside the function wrappper that is placed around modules.
799                 //              The init function could be executed more than once, and it should make no assumptions
800                 //              on what is loaded, or what modules are available. Only the functionality in Dojo Base
801                 //              is allowed to be used. Avoid using this method. For a valid use case,
802                 //              see the source for dojox.gfx.
803                 init();
804         }
805
806         dojo._loadModule = dojo.require = function(/*String*/moduleName, /*Boolean?*/omitModuleCheck){
807                 //      summary:
808                 //              loads a Javascript module from the appropriate URI
809                 //      moduleName:
810                 //              module name to load, using periods for separators,
811                 //               e.g. "dojo.date.locale".  Module paths are de-referenced by dojo's
812                 //              internal mapping of locations to names and are disambiguated by
813                 //              longest prefix. See `dojo.registerModulePath()` for details on
814                 //              registering new modules.
815                 //      omitModuleCheck:
816                 //              if `true`, omitModuleCheck skips the step of ensuring that the
817                 //              loaded file actually defines the symbol it is referenced by.
818                 //              For example if it called as `dojo.require("a.b.c")` and the
819                 //              file located at `a/b/c.js` does not define an object `a.b.c`,
820                 //              and exception will be throws whereas no exception is raised
821                 //              when called as `dojo.require("a.b.c", true)`
822                 //      description:
823                 //              `dojo.require("A.B")` first checks to see if symbol A.B is
824                 //              defined. If it is, it is simply returned (nothing to do).
825                 //      
826                 //              If it is not defined, it will look for `A/B.js` in the script root
827                 //              directory.
828                 //      
829                 //              `dojo.require` throws an excpetion if it cannot find a file
830                 //              to load, or if the symbol `A.B` is not defined after loading.
831                 //      
832                 //              It returns the object `A.B`.
833                 //      
834                 //              `dojo.require()` does nothing about importing symbols into
835                 //              the current namespace.  It is presumed that the caller will
836                 //              take care of that. For example, to import all symbols into a
837                 //              local block, you might write:
838                 //      
839                 //              |       with (dojo.require("A.B")) {
840                 //              |               ...
841                 //              |       }
842                 //      
843                 //              And to import just the leaf symbol to a local variable:
844                 //      
845                 //              |       var B = dojo.require("A.B");
846                 //              |       ...
847                 //      returns: the required namespace object
848                 omitModuleCheck = this._global_omit_module_check || omitModuleCheck;
849
850                 //Check if it is already loaded.
851                 var module = this._loadedModules[moduleName];
852                 if(module){
853                         return module;
854                 }
855
856                 // convert periods to slashes
857                 var relpath = this._getModuleSymbols(moduleName).join("/") + '.js';
858
859                 var modArg = (!omitModuleCheck) ? moduleName : null;
860                 var ok = this._loadPath(relpath, modArg);
861
862                 if(!ok && !omitModuleCheck){
863                         throw new Error("Could not load '" + moduleName + "'; last tried '" + relpath + "'");
864                 }
865
866                 // check that the symbol was defined
867                 // Don't bother if we're doing xdomain (asynchronous) loading.
868                 if(!omitModuleCheck && !this._isXDomain){
869                         // pass in false so we can give better error
870                         module = this._loadedModules[moduleName];
871                         if(!module){
872                                 throw new Error("symbol '" + moduleName + "' is not defined after loading '" + relpath + "'"); 
873                         }
874                 }
875
876                 return module;
877         }
878
879         dojo.provide = function(/*String*/ resourceName){
880                 //      summary:
881                 //              Each javascript source file must have at least one
882                 //              `dojo.provide()` call at the top of the file, corresponding to
883                 //              the file name.  For example, `js/dojo/foo.js` must have
884                 //              `dojo.provide("dojo.foo");` before any calls to
885                 //              `dojo.require()` are made.
886                 //      description:
887                 //              Each javascript source file is called a resource.  When a
888                 //              resource is loaded by the browser, `dojo.provide()` registers
889                 //              that it has been loaded.
890                 //      
891                 //              For backwards compatibility reasons, in addition to registering
892                 //              the resource, `dojo.provide()` also ensures that the javascript
893                 //              object for the module exists.  For example,
894                 //              `dojo.provide("dojox.data.FlickrStore")`, in addition to
895                 //              registering that `FlickrStore.js` is a resource for the
896                 //              `dojox.data` module, will ensure that the `dojox.data`
897                 //              javascript object exists, so that calls like 
898                 //              `dojo.data.foo = function(){ ... }` don't fail.
899                 //
900                 //              In the case of a build where multiple javascript source files
901                 //              are combined into one bigger file (similar to a .lib or .jar
902                 //              file), that file may contain multiple dojo.provide() calls, to
903                 //              note that it includes multiple resources.
904
905                 //Make sure we have a string.
906                 resourceName = resourceName + "";
907                 return (d._loadedModules[resourceName] = d.getObject(resourceName, true)); // Object
908         }
909
910         //Start of old bootstrap2:
911
912         dojo.platformRequire = function(/*Object*/modMap){
913                 //      summary:
914                 //              require one or more modules based on which host environment
915                 //              Dojo is currently operating in
916                 //      description:
917                 //              This method takes a "map" of arrays which one can use to
918                 //              optionally load dojo modules. The map is indexed by the
919                 //              possible dojo.name_ values, with two additional values:
920                 //              "default" and "common". The items in the "default" array will
921                 //              be loaded if none of the other items have been choosen based on
922                 //              dojo.name_, set by your host environment. The items in the
923                 //              "common" array will *always* be loaded, regardless of which
924                 //              list is chosen.
925                 //      example:
926                 //              |       dojo.platformRequire({
927                 //              |               browser: [
928                 //              |                       "foo.sample", // simple module
929                 //              |                       "foo.test",
930                 //              |                       ["foo.bar.baz", true] // skip object check in _loadModule (dojo.require)
931                 //              |               ],
932                 //              |               default: [ "foo.sample._base" ],
933                 //              |               common: [ "important.module.common" ]
934                 //              |       });
935
936                 var common = modMap.common || [];
937                 var result = common.concat(modMap[d._name] || modMap["default"] || []);
938
939                 for(var x=0; x<result.length; x++){
940                         var curr = result[x];
941                         if(curr.constructor == Array){
942                                 d._loadModule.apply(d, curr);
943                         }else{
944                                 d._loadModule(curr);
945                         }
946                 }
947         }
948
949         dojo.requireIf = function(/*Boolean*/ condition, /*String*/ resourceName){
950                 // summary:
951                 //              If the condition is true then call dojo.require() for the specified
952                 //              resource
953                 if(condition === true){
954                         // FIXME: why do we support chained require()'s here? does the build system?
955                         var args = [];
956                         for(var i = 1; i < arguments.length; i++){ 
957                                 args.push(arguments[i]);
958                         }
959                         d.require.apply(d, args);
960                 }
961         }
962
963         dojo.requireAfterIf = d.requireIf;
964
965         dojo.registerModulePath = function(/*String*/module, /*String*/prefix){
966                 //      summary: 
967                 //              maps a module name to a path
968                 //      description: 
969                 //              An unregistered module is given the default path of ../[module],
970                 //              relative to Dojo root. For example, module acme is mapped to
971                 //              ../acme.  If you want to use a different module name, use
972                 //              dojo.registerModulePath. 
973                 //      example:
974                 //              If your dojo.js is located at this location in the web root:
975                 //      |       /myapp/js/dojo/dojo/dojo.js
976                 //              and your modules are located at:
977                 //      |       /myapp/js/foo/bar.js
978                 //      |       /myapp/js/foo/baz.js
979                 //      |       /myapp/js/foo/thud/xyzzy.js
980                 //              Your application can tell Dojo to locate the "foo" namespace by calling:
981                 //      |       dojo.registerModulePath("foo", "../../foo");
982                 //              At which point you can then use dojo.require() to load the
983                 //              modules (assuming they provide() the same things which are
984                 //              required). The full code might be:
985                 //      |       <script type="text/javascript" 
986                 //      |               src="/myapp/js/dojo/dojo/dojo.js"></script>
987                 //      |       <script type="text/javascript">
988                 //      |               dojo.registerModulePath("foo", "../../foo");
989                 //      |               dojo.require("foo.bar");
990                 //      |               dojo.require("foo.baz");
991                 //      |               dojo.require("foo.thud.xyzzy");
992                 //      |       </script>
993                 d._modulePrefixes[module] = { name: module, value: prefix };
994         }
995
996         dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale, /*String?*/availableFlatLocales){
997                 // summary:
998                 //              Declares translated resources and loads them if necessary, in the
999                 //              same style as dojo.require.  Contents of the resource bundle are
1000                 //              typically strings, but may be any name/value pair, represented in
1001                 //              JSON format.  See also `dojo.i18n.getLocalization`.
1002                 //
1003                 // description:
1004                 //              Load translated resource bundles provided underneath the "nls"
1005                 //              directory within a package.  Translated resources may be located in
1006                 //              different packages throughout the source tree.  
1007                 //
1008                 //              Each directory is named for a locale as specified by RFC 3066,
1009                 //              (http://www.ietf.org/rfc/rfc3066.txt), normalized in lowercase.
1010                 //              Note that the two bundles in the example do not define all the
1011                 //              same variants.  For a given locale, bundles will be loaded for
1012                 //              that locale and all more general locales above it, including a
1013                 //              fallback at the root directory.  For example, a declaration for
1014                 //              the "de-at" locale will first load `nls/de-at/bundleone.js`,
1015                 //              then `nls/de/bundleone.js` and finally `nls/bundleone.js`.  The
1016                 //              data will be flattened into a single Object so that lookups
1017                 //              will follow this cascading pattern.  An optional build step can
1018                 //              preload the bundles to avoid data redundancy and the multiple
1019                 //              network hits normally required to load these resources.
1020                 //
1021                 // moduleName: 
1022                 //              name of the package containing the "nls" directory in which the
1023                 //              bundle is found
1024                 //
1025                 // bundleName: 
1026                 //              bundle name, i.e. the filename without the '.js' suffix
1027                 //
1028                 // locale: 
1029                 //              the locale to load (optional)  By default, the browser's user
1030                 //              locale as defined by dojo.locale
1031                 //
1032                 // availableFlatLocales: 
1033                 //              A comma-separated list of the available, flattened locales for this
1034                 //              bundle. This argument should only be set by the build process.
1035                 //
1036                 //      example:
1037                 //              A particular widget may define one or more resource bundles,
1038                 //              structured in a program as follows, where moduleName is
1039                 //              mycode.mywidget and bundleNames available include bundleone and
1040                 //              bundletwo:
1041                 //      |               ...
1042                 //      |       mycode/
1043                 //      |               mywidget/
1044                 //      |                       nls/
1045                 //      |                               bundleone.js (the fallback translation, English in this example)
1046                 //      |                               bundletwo.js (also a fallback translation)
1047                 //      |                               de/
1048                 //      |                                       bundleone.js
1049                 //      |                                       bundletwo.js
1050                 //      |                               de-at/
1051                 //      |                                       bundleone.js
1052                 //      |                               en/
1053                 //      |                                       (empty; use the fallback translation)
1054                 //      |                               en-us/
1055                 //      |                                       bundleone.js
1056                 //      |                               en-gb/
1057                 //      |                                       bundleone.js
1058                 //      |                               es/
1059                 //      |                                       bundleone.js
1060                 //      |                                       bundletwo.js
1061                 //      |                                 ...etc
1062                 //      |                               ...
1063                 //
1064
1065                 d.require("dojo.i18n");
1066                 d.i18n._requireLocalization.apply(d.hostenv, arguments);
1067         };
1068
1069
1070         var ore = new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$");
1071         var ire = new RegExp("^((([^\\[:]+):)?([^@]+)@)?(\\[([^\\]]+)\\]|([^\\[:]*))(:([0-9]+))?$");
1072
1073         dojo._Url = function(/*dojo._Url||String...*/){
1074                 // summary: 
1075                 //              Constructor to create an object representing a URL.
1076                 //              It is marked as private, since we might consider removing
1077                 //              or simplifying it.
1078                 // description: 
1079                 //              Each argument is evaluated in order relative to the next until
1080                 //              a canonical uri is produced. To get an absolute Uri relative to
1081                 //              the current document use:
1082                 //              new dojo._Url(document.baseURI, url)
1083
1084                 var n = null;
1085
1086                 var _a = arguments;
1087                 var uri = [_a[0]];
1088                 // resolve uri components relative to each other
1089                 for(var i = 1; i<_a.length; i++){
1090                         if(!_a[i]){ continue; }
1091
1092                         // Safari doesn't support this.constructor so we have to be explicit
1093                         // FIXME: Tracked (and fixed) in Webkit bug 3537.
1094                         //              http://bugs.webkit.org/show_bug.cgi?id=3537
1095                         var relobj = new d._Url(_a[i]+"");
1096                         var uriobj = new d._Url(uri[0]+"");
1097
1098                         if(
1099                                 relobj.path == "" &&
1100                                 !relobj.scheme &&
1101                                 !relobj.authority &&
1102                                 !relobj.query
1103                         ){
1104                                 if(relobj.fragment != n){
1105                                         uriobj.fragment = relobj.fragment;
1106                                 }
1107                                 relobj = uriobj;
1108                         }else if(!relobj.scheme){
1109                                 relobj.scheme = uriobj.scheme;
1110
1111                                 if(!relobj.authority){
1112                                         relobj.authority = uriobj.authority;
1113
1114                                         if(relobj.path.charAt(0) != "/"){
1115                                                 var path = uriobj.path.substring(0,
1116                                                         uriobj.path.lastIndexOf("/") + 1) + relobj.path;
1117
1118                                                 var segs = path.split("/");
1119                                                 for(var j = 0; j < segs.length; j++){
1120                                                         if(segs[j] == "."){
1121                                                                 // flatten "./" references
1122                                                                 if(j == segs.length - 1){
1123                                                                         segs[j] = "";
1124                                                                 }else{
1125                                                                         segs.splice(j, 1);
1126                                                                         j--;
1127                                                                 }
1128                                                         }else if(j > 0 && !(j == 1 && segs[0] == "") &&
1129                                                                 segs[j] == ".." && segs[j-1] != ".."){
1130                                                                 // flatten "../" references
1131                                                                 if(j == (segs.length - 1)){
1132                                                                         segs.splice(j, 1);
1133                                                                         segs[j - 1] = "";
1134                                                                 }else{
1135                                                                         segs.splice(j - 1, 2);
1136                                                                         j -= 2;
1137                                                                 }
1138                                                         }
1139                                                 }
1140                                                 relobj.path = segs.join("/");
1141                                         }
1142                                 }
1143                         }
1144
1145                         uri = [];
1146                         if(relobj.scheme){ 
1147                                 uri.push(relobj.scheme, ":");
1148                         }
1149                         if(relobj.authority){
1150                                 uri.push("//", relobj.authority);
1151                         }
1152                         uri.push(relobj.path);
1153                         if(relobj.query){
1154                                 uri.push("?", relobj.query);
1155                         }
1156                         if(relobj.fragment){
1157                                 uri.push("#", relobj.fragment);
1158                         }
1159                 }
1160
1161                 this.uri = uri.join("");
1162
1163                 // break the uri into its main components
1164                 var r = this.uri.match(ore);
1165
1166                 this.scheme = r[2] || (r[1] ? "" : n);
1167                 this.authority = r[4] || (r[3] ? "" : n);
1168                 this.path = r[5]; // can never be undefined
1169                 this.query = r[7] || (r[6] ? "" : n);
1170                 this.fragment  = r[9] || (r[8] ? "" : n);
1171
1172                 if(this.authority != n){
1173                         // server based naming authority
1174                         r = this.authority.match(ire);
1175
1176                         this.user = r[3] || n;
1177                         this.password = r[4] || n;
1178                         this.host = r[6] || r[7]; // ipv6 || ipv4
1179                         this.port = r[9] || n;
1180                 }
1181         }
1182
1183         dojo._Url.prototype.toString = function(){ return this.uri; };
1184
1185         dojo.moduleUrl = function(/*String*/module, /*dojo._Url||String*/url){
1186                 //      summary: 
1187                 //              Returns a `dojo._Url` object relative to a module.
1188                 //      example:
1189                 //      |       var pngPath = dojo.moduleUrl("acme","images/small.png");
1190                 //      |        // list the object properties
1191                 //      |       // create an image and set it's source to pngPath's value:
1192                 //      |       var img = document.createElement("img");
1193                 //      |       // NOTE: we assign the string representation of the url object
1194                 //      |       img.src = pngPath.toString(); 
1195                 //      |       // add our image to the document
1196                 //      |       dojo.body().appendChild(img);
1197                 //      example: 
1198                 //              you may de-reference as far as you like down the package
1199                 //              hierarchy.  This is sometimes handy to avoid lenghty relative
1200                 //              urls or for building portable sub-packages. In this example,
1201                 //              the `acme.widget` and `acme.util` directories may be located
1202                 //              under different roots (see `dojo.registerModulePath`) but the
1203                 //              the modules which reference them can be unaware of their
1204                 //              relative locations on the filesystem:
1205                 //      |       // somewhere in a configuration block
1206                 //      |       dojo.registerModulePath("acme.widget", "../../acme/widget");
1207                 //      |       dojo.registerModulePath("acme.util", "../../util");
1208                 //      |       
1209                 //      |       // ...
1210                 //      |       
1211                 //      |       // code in a module using acme resources
1212                 //      |       var tmpltPath = dojo.moduleUrl("acme.widget","templates/template.html");
1213                 //      |       var dataPath = dojo.moduleUrl("acme.util","resources/data.json");
1214
1215                 var loc = d._getModuleSymbols(module).join('/');
1216                 if(!loc){ return null; }
1217                 if(loc.lastIndexOf("/") != loc.length-1){
1218                         loc += "/";
1219                 }
1220                 
1221                 //If the path is an absolute path (starts with a / or is on another
1222                 //domain/xdomain) then don't add the baseUrl.
1223                 var colonIndex = loc.indexOf(":");
1224                 if(loc.charAt(0) != "/" && (colonIndex == -1 || colonIndex > loc.indexOf("/"))){
1225                         loc = d.baseUrl + loc;
1226                 }
1227
1228                 return new d._Url(loc, url); // String
1229         }
1230 })();
1231
1232 /*=====
1233 dojo.isBrowser = {
1234         //      example:
1235         //      |       if(dojo.isBrowser){ ... }
1236 };
1237
1238 dojo.isFF = {
1239         //      example:
1240         //      |       if(dojo.isFF > 1){ ... }
1241 };
1242
1243 dojo.isIE = {
1244         // example:
1245         //      |       if(dojo.isIE > 6){
1246         //      |               // we are IE7
1247         //      |       }
1248 };
1249
1250 dojo.isSafari = {
1251         //      example:
1252         //      |       if(dojo.isSafari){ ... }
1253         //      example: 
1254         //              Detect iPhone:
1255         //      |       if(dojo.isSafari && navigator.userAgent.indexOf("iPhone") != -1){ 
1256         //      |               // we are iPhone. Note, iPod touch reports "iPod" above and fails this test.
1257         //      |       }
1258 };
1259
1260 dojo = {
1261         // isBrowser: Boolean
1262         //              True if the client is a web-browser
1263         isBrowser: true,
1264         //      isFF: Number | undefined
1265         //              Version as a Number if client is FireFox. undefined otherwise. Corresponds to
1266         //              major detected FireFox version (1.5, 2, 3, etc.)
1267         isFF: 2,
1268         //      isIE: Number | undefined
1269         //              Version as a Number if client is MSIE(PC). undefined otherwise. Corresponds to
1270         //              major detected IE version (6, 7, 8, etc.)
1271         isIE: 6,
1272         //      isKhtml: Number | undefined
1273         //              Version as a Number if client is a KTHML-derived browser (Konqueror,
1274         //              Safari, etc.). undefined otherwise. Corresponds to major detected version.
1275         isKhtml: 0,
1276         //      isMozilla: Number | undefined
1277         //              Version as a Number if client is a Mozilla-based browser (Firefox,
1278         //              SeaMonkey). undefined otherwise. Corresponds to major detected version.
1279         isMozilla: 0,
1280         //      isOpera: Number | undefined
1281         //              Version as a Number if client is Opera. undefined otherwise. Corresponds to
1282         //              major detected version.
1283         isOpera: 0,
1284         //      isSafari: Number | undefined
1285         //              Version as a Number if client is Safari or iPhone. undefined otherwise.
1286         isSafari: 0
1287 }
1288 =====*/
1289
1290 if(typeof window != 'undefined'){
1291         dojo.isBrowser = true;
1292         dojo._name = "browser";
1293
1294
1295         // attempt to figure out the path to dojo if it isn't set in the config
1296         (function(){
1297                 var d = dojo;
1298                 // this is a scope protection closure. We set browser versions and grab
1299                 // the URL we were loaded from here.
1300
1301                 // grab the node we were loaded from
1302                 if(document && document.getElementsByTagName){
1303                         var scripts = document.getElementsByTagName("script");
1304                         var rePkg = /dojo(\.xd)?\.js(\W|$)/i;
1305                         for(var i = 0; i < scripts.length; i++){
1306                                 var src = scripts[i].getAttribute("src");
1307                                 if(!src){ continue; }
1308                                 var m = src.match(rePkg);
1309                                 if(m){
1310                                         // find out where we came from
1311                                         if(!d.config.baseUrl){
1312                                                 d.config.baseUrl = src.substring(0, m.index);
1313                                         }
1314                                         // and find out if we need to modify our behavior
1315                                         var cfg = scripts[i].getAttribute("djConfig");
1316                                         if(cfg){
1317                                                 var cfgo = eval("({ "+cfg+" })");
1318                                                 for(var x in cfgo){
1319                                                         dojo.config[x] = cfgo[x];
1320                                                 }
1321                                         }
1322                                         break; // "first Dojo wins"
1323                                 }
1324                         }
1325                 }
1326                 d.baseUrl = d.config.baseUrl;
1327
1328                 // fill in the rendering support information in dojo.render.*
1329                 var n = navigator;
1330                 var dua = n.userAgent;
1331                 var dav = n.appVersion;
1332                 var tv = parseFloat(dav);
1333
1334                 if(dua.indexOf("Opera") >= 0){ d.isOpera = tv; }
1335                 // safari detection derived from:
1336                 //              http://developer.apple.com/internet/safari/faq.html#anchor2
1337                 //              http://developer.apple.com/internet/safari/uamatrix.html
1338                 var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0);
1339                 if(index){
1340                         // try to grab the explicit Safari version first. If we don't get
1341                         // one, look for 419.3+ as the indication that we're on something
1342                         // "Safari 3-ish". Lastly, default to "Safari 2" handling.
1343                         d.isSafari = parseFloat(dav.split("Version/")[1]) ||
1344                                 (parseFloat(dav.substr(index + 7)) > 419.3) ? 3 : 2;
1345                 }
1346                 if(dua.indexOf("AdobeAIR") >= 0){ d.isAIR = 1; }
1347                 if(dav.indexOf("Konqueror") >= 0 || d.isSafari){ d.isKhtml =  tv; }
1348                 if(dua.indexOf("Gecko") >= 0 && !d.isKhtml){ d.isMozilla = d.isMoz = tv; }
1349                 if(d.isMoz){
1350                         d.isFF = parseFloat(dua.split("Firefox/")[1]) || undefined;
1351                 }
1352                 if(document.all && !d.isOpera){
1353                         d.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;
1354                 }
1355
1356                 //Workaround to get local file loads of dojo to work on IE 7
1357                 //by forcing to not use native xhr.
1358                 if(dojo.isIE && window.location.protocol === "file:"){
1359                         dojo.config.ieForceActiveXXhr=true;
1360                 }
1361
1362                 var cm = document.compatMode;
1363                 d.isQuirks = cm == "BackCompat" || cm == "QuirksMode" || d.isIE < 6;
1364
1365                 // TODO: is the HTML LANG attribute relevant?
1366                 d.locale = dojo.config.locale || (d.isIE ? n.userLanguage : n.language).toLowerCase();
1367
1368                 // These are in order of decreasing likelihood; this will change in time.
1369                 d._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
1370
1371                 d._xhrObj = function(){
1372                         // summary: 
1373                         //              does the work of portably generating a new XMLHTTPRequest
1374                         //              object.
1375                         var http = null;
1376                         var last_e = null;
1377                         if(!dojo.isIE || !dojo.config.ieForceActiveXXhr){
1378                                 try{ http = new XMLHttpRequest(); }catch(e){}
1379                         }
1380                         if(!http){
1381                                 for(var i=0; i<3; ++i){
1382                                         var progid = d._XMLHTTP_PROGIDS[i];
1383                                         try{
1384                                                 http = new ActiveXObject(progid);
1385                                         }catch(e){
1386                                                 last_e = e;
1387                                         }
1388
1389                                         if(http){
1390                                                 d._XMLHTTP_PROGIDS = [progid];  // so faster next time
1391                                                 break;
1392                                         }
1393                                 }
1394                         }
1395
1396                         if(!http){
1397                                 throw new Error("XMLHTTP not available: "+last_e);
1398                         }
1399
1400                         return http; // XMLHTTPRequest instance
1401                 }
1402
1403                 d._isDocumentOk = function(http){
1404                         var stat = http.status || 0;
1405                         return (stat >= 200 && stat < 300) ||   // Boolean
1406                                 stat == 304 ||                                          // allow any 2XX response code
1407                                 stat == 1223 ||                                                 // get it out of the cache
1408                                 (!stat && (location.protocol=="file:" || location.protocol=="chrome:") ); // Internet Explorer mangled the status code
1409                 }
1410
1411                 //See if base tag is in use.
1412                 //This is to fix http://trac.dojotoolkit.org/ticket/3973,
1413                 //but really, we need to find out how to get rid of the dojo._Url reference
1414                 //below and still have DOH work with the dojo.i18n test following some other
1415                 //test that uses the test frame to load a document (trac #2757).
1416                 //Opera still has problems, but perhaps a larger issue of base tag support
1417                 //with XHR requests (hasBase is true, but the request is still made to document
1418                 //path, not base path).
1419                 var owloc = window.location+"";
1420                 var base = document.getElementsByTagName("base");
1421                 var hasBase = (base && base.length > 0);
1422
1423                 d._getText = function(/*URI*/ uri, /*Boolean*/ fail_ok){
1424                         // summary: Read the contents of the specified uri and return those contents.
1425                         // uri:
1426                         //              A relative or absolute uri. If absolute, it still must be in
1427                         //              the same "domain" as we are.
1428                         // fail_ok:
1429                         //              Default false. If fail_ok and loading fails, return null
1430                         //              instead of throwing.
1431                         // returns: The response text. null is returned when there is a
1432                         //              failure and failure is okay (an exception otherwise)
1433
1434                         // alert("_getText: " + uri);
1435
1436                         // NOTE: must be declared before scope switches ie. this._xhrObj()
1437                         var http = this._xhrObj();
1438
1439                         if(!hasBase && dojo._Url){
1440                                 uri = (new dojo._Url(owloc, uri)).toString();
1441                         }
1442                         /*
1443                         
1444                         
1445                         alert(uri);
1446                         */
1447
1448                         if(d.config.cacheBust){
1449                                 //Make sure we have a string before string methods are used on uri
1450                                 uri += "";
1451                                 uri += (uri.indexOf("?") == -1 ? "?" : "&") + String(d.config.cacheBust).replace(/\W+/g,"");
1452                         }
1453
1454                         http.open('GET', uri, false);
1455                         try{
1456                                 http.send(null);
1457                                 // alert(http);
1458                                 if(!d._isDocumentOk(http)){
1459                                         var err = Error("Unable to load "+uri+" status:"+ http.status);
1460                                         err.status = http.status;
1461                                         err.responseText = http.responseText;
1462                                         throw err;
1463                                 }
1464                         }catch(e){
1465                                 if(fail_ok){ return null; } // null
1466                                 // rethrow the exception
1467                                 throw e;
1468                         }
1469                         return http.responseText; // String
1470                 }
1471                 
1472                 d._windowUnloaders = [];
1473                 
1474                 d.windowUnloaded = function(){
1475                         // summary:
1476                         //              signal fired by impending window destruction. You may use
1477                         //              dojo.addOnWIndowUnload() or dojo.connect() to this method to perform
1478                         //              page/application cleanup methods. See dojo.addOnWindowUnload for more info.
1479                         var mll = this._windowUnloaders;
1480                         while(mll.length){
1481                                 (mll.pop())();
1482                         }
1483                 }
1484
1485                 d.addOnWindowUnload = function(/*Object?*/obj, /*String|Function?*/functionName){
1486                         // summary:
1487                         //              registers a function to be triggered when window.onunload fires.
1488                         //              Be careful trying to modify the DOM or access JavaScript properties
1489                         //              during this phase of page unloading: they may not always be available.
1490                         //              Consider dojo.addOnUnload() if you need to modify the DOM or do heavy
1491                         //              JavaScript work.
1492                         // example:
1493                         //      |       dojo.addOnWindowUnload(functionPointer)
1494                         //      |       dojo.addOnWindowUnload(object, "functionName")
1495                         //      |       dojo.addOnWindowUnload(object, function(){ /* ... */});
1496         
1497                         d._onto(d._windowUnloaders, obj, functionName);
1498                 }
1499         })();
1500
1501         dojo._initFired = false;
1502         //      BEGIN DOMContentLoaded, from Dean Edwards (http://dean.edwards.name/weblog/2006/06/again/)
1503         dojo._loadInit = function(e){
1504                 dojo._initFired = true;
1505                 // allow multiple calls, only first one will take effect
1506                 // A bug in khtml calls events callbacks for document for event which isnt supported
1507                 // for example a created contextmenu event calls DOMContentLoaded, workaround
1508                 var type = (e && e.type) ? e.type.toLowerCase() : "load";
1509                 if(arguments.callee.initialized || (type != "domcontentloaded" && type != "load")){ return; }
1510                 arguments.callee.initialized = true;
1511                 if("_khtmlTimer" in dojo){
1512                         clearInterval(dojo._khtmlTimer);
1513                         delete dojo._khtmlTimer;
1514                 }
1515
1516                 if(dojo._inFlightCount == 0){
1517                         dojo._modulesLoaded();
1518                 }
1519         }
1520
1521         dojo._fakeLoadInit = function(){
1522                 dojo._loadInit({type: "load"});
1523         }
1524
1525         if(!dojo.config.afterOnLoad){
1526                 //      START DOMContentLoaded
1527                 // Mozilla and Opera 9 expose the event we could use
1528                 if(document.addEventListener){
1529                         // NOTE: 
1530                         //              due to a threading issue in Firefox 2.0, we can't enable
1531                         //              DOMContentLoaded on that platform. For more information, see:
1532                         //              http://trac.dojotoolkit.org/ticket/1704
1533                         if(dojo.isOpera || dojo.isFF >= 3 || (dojo.isMoz && dojo.config.enableMozDomContentLoaded === true)){
1534                                 document.addEventListener("DOMContentLoaded", dojo._loadInit, null);
1535                         }
1536         
1537                         //      mainly for Opera 8.5, won't be fired if DOMContentLoaded fired already.
1538                         //  also used for Mozilla because of trac #1640
1539                         window.addEventListener("load", dojo._loadInit, null);
1540                 }
1541         
1542                 if(dojo.isAIR){
1543                         window.addEventListener("load", dojo._loadInit, null);
1544                 }else if(/(WebKit|khtml)/i.test(navigator.userAgent)){ // sniff
1545                         dojo._khtmlTimer = setInterval(function(){
1546                                 if(/loaded|complete/.test(document.readyState)){
1547                                         dojo._loadInit(); // call the onload handler
1548                                 }
1549                         }, 10);
1550                 }
1551                 //      END DOMContentLoaded
1552         }
1553
1554         (function(){
1555                 var _w = window;
1556                 var _handleNodeEvent = function(/*String*/evtName, /*Function*/fp){
1557                         // summary:
1558                         //              non-destructively adds the specified function to the node's
1559                         //              evtName handler.
1560                         // evtName: should be in the form "onclick" for "onclick" handlers.
1561                         // Make sure you pass in the "on" part.
1562                         var oldHandler = _w[evtName] || function(){};
1563                         _w[evtName] = function(){
1564                                 fp.apply(_w, arguments);
1565                                 oldHandler.apply(_w, arguments);
1566                         };
1567                 };
1568
1569                 if(dojo.isIE){
1570                         //      for Internet Explorer. readyState will not be achieved on init
1571                         //      call, but dojo doesn't need it however, we'll include it
1572                         //      because we don't know if there are other functions added that
1573                         //      might.  Note that this has changed because the build process
1574                         //      strips all comments -- including conditional ones.
1575                         if(!dojo.config.afterOnLoad){
1576                                 document.write('<scr'+'ipt defer src="//:" '
1577                                         + 'onreadystatechange="if(this.readyState==\'complete\'){' + dojo._scopeName + '._loadInit();}">'
1578                                         + '</scr'+'ipt>'
1579                                 );
1580                         }
1581
1582                         try{
1583                                 document.namespaces.add("v","urn:schemas-microsoft-com:vml");
1584                                 document.createStyleSheet().addRule("v\\:*", "behavior:url(#default#VML)");
1585                         }catch(e){}
1586                 }
1587
1588                 // FIXME: dojo.unloaded requires dojo scope, so using anon function wrapper.
1589                 _handleNodeEvent("onbeforeunload", function() { dojo.unloaded(); });
1590                 _handleNodeEvent("onunload", function() { dojo.windowUnloaded(); });
1591         })();
1592
1593         /*
1594         OpenAjax.subscribe("OpenAjax", "onload", function(){
1595                 if(dojo._inFlightCount == 0){
1596                         dojo._modulesLoaded();
1597                 }
1598         });
1599
1600         OpenAjax.subscribe("OpenAjax", "onunload", function(){
1601                 dojo.unloaded();
1602         });
1603         */
1604 } //if (typeof window != 'undefined')
1605
1606 //Register any module paths set up in djConfig. Need to do this
1607 //in the hostenvs since hostenv_browser can read djConfig from a
1608 //script tag's attribute.
1609 (function(){
1610         var mp = dojo.config["modulePaths"];
1611         if(mp){
1612                 for(var param in mp){
1613                         dojo.registerModulePath(param, mp[param]);
1614                 }
1615         }
1616 })();
1617
1618 //Load debug code if necessary.
1619 if(dojo.config.isDebug){
1620         dojo.require("dojo._firebug.firebug");
1621 }
1622
1623 if(dojo.config.debugAtAllCosts){
1624         dojo.config.useXDomain = true;
1625         dojo.require("dojo._base._loader.loader_xd");
1626         dojo.require("dojo._base._loader.loader_debug");
1627         dojo.require("dojo.i18n");
1628 }
1629
1630 if(!dojo._hasResource["dojo._base.lang"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
1631 dojo._hasResource["dojo._base.lang"] = true;
1632 dojo.provide("dojo._base.lang");
1633
1634 // Crockford (ish) functions
1635
1636 dojo.isString = function(/*anything*/ it){
1637         //      summary:
1638         //              Return true if it is a String
1639         return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean
1640 }
1641
1642 dojo.isArray = function(/*anything*/ it){
1643         //      summary:
1644         //              Return true if it is an Array
1645         return it && (it instanceof Array || typeof it == "array"); // Boolean
1646 }
1647
1648 /*=====
1649 dojo.isFunction = function(it){
1650         // summary: Return true if it is a Function
1651         // it: anything
1652         return; // Boolean
1653 }
1654 =====*/
1655
1656 dojo.isFunction = (function(){
1657         var _isFunction = function(/*anything*/ it){
1658                 return it && (typeof it == "function" || it instanceof Function); // Boolean
1659         };
1660
1661         return dojo.isSafari ?
1662                 // only slow this down w/ gratuitious casting in Safari since it's what's b0rken
1663                 function(/*anything*/ it){
1664                         if(typeof it == "function" && it == "[object NodeList]"){ return false; }
1665                         return _isFunction(it); // Boolean
1666                 } : _isFunction;
1667 })();
1668
1669 dojo.isObject = function(/*anything*/ it){
1670         // summary: 
1671         //              Returns true if it is a JavaScript object (or an Array, a Function
1672         //              or null)
1673         return it !== undefined &&
1674                 (it === null || typeof it == "object" || dojo.isArray(it) || dojo.isFunction(it)); // Boolean
1675 }
1676
1677 dojo.isArrayLike = function(/*anything*/ it){
1678         //      summary:
1679         //              similar to dojo.isArray() but more permissive
1680         //      description:
1681         //              Doesn't strongly test for "arrayness".  Instead, settles for "isn't
1682         //              a string or number and has a length property". Arguments objects
1683         //              and DOM collections will return true when passed to
1684         //              dojo.isArrayLike(), but will return false when passed to
1685         //              dojo.isArray().
1686         //      returns:
1687         //              If it walks like a duck and quicks like a duck, return `true`
1688         var d = dojo;
1689         return it && it !== undefined && // Boolean
1690                 // keep out built-in constructors (Number, String, ...) which have length
1691                 // properties
1692                 !d.isString(it) && !d.isFunction(it) &&
1693                 !(it.tagName && it.tagName.toLowerCase() == 'form') &&
1694                 (d.isArray(it) || isFinite(it.length));
1695 }
1696
1697 dojo.isAlien = function(/*anything*/ it){
1698         // summary: 
1699         //              Returns true if it is a built-in function or some other kind of
1700         //              oddball that *should* report as a function but doesn't
1701         return it && !dojo.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean
1702 }
1703
1704 dojo.extend = function(/*Object*/ constructor, /*Object...*/ props){
1705         // summary:
1706         //              Adds all properties and methods of props to constructor's
1707         //              prototype, making them available to all instances created with
1708         //              constructor.
1709         for(var i=1, l=arguments.length; i<l; i++){
1710                 dojo._mixin(constructor.prototype, arguments[i]);
1711         }
1712         return constructor; // Object
1713 }
1714
1715 dojo._hitchArgs = function(scope, method /*,...*/){
1716         var pre = dojo._toArray(arguments, 2);
1717         var named = dojo.isString(method);
1718         return function(){
1719                 // arrayify arguments
1720                 var args = dojo._toArray(arguments);
1721                 // locate our method
1722                 var f = named ? (scope||dojo.global)[method] : method;
1723                 // invoke with collected args
1724                 return f && f.apply(scope || this, pre.concat(args)); // mixed
1725         } // Function
1726 }
1727
1728 dojo.hitch = function(/*Object*/scope, /*Function|String*/method /*,...*/){
1729         //      summary: 
1730         //              Returns a function that will only ever execute in the a given scope. 
1731         //              This allows for easy use of object member functions
1732         //              in callbacks and other places in which the "this" keyword may
1733         //              otherwise not reference the expected scope. 
1734         //              Any number of default positional arguments may be passed as parameters 
1735         //              beyond "method".
1736         //              Each of these values will be used to "placehold" (similar to curry)
1737         //              for the hitched function. 
1738         //      scope: 
1739         //              The scope to use when method executes. If method is a string, 
1740         //              scope is also the object containing method.
1741         //      method:
1742         //              A function to be hitched to scope, or the name of the method in
1743         //              scope to be hitched.
1744         //      example:
1745         //      |       dojo.hitch(foo, "bar")(); 
1746         //              runs foo.bar() in the scope of foo
1747         //      example:
1748         //      |       dojo.hitch(foo, myFunction);
1749         //              returns a function that runs myFunction in the scope of foo
1750         if(arguments.length > 2){
1751                 return dojo._hitchArgs.apply(dojo, arguments); // Function
1752         }
1753         if(!method){
1754                 method = scope;
1755                 scope = null;
1756         }
1757         if(dojo.isString(method)){
1758                 scope = scope || dojo.global;
1759                 if(!scope[method]){ throw(['dojo.hitch: scope["', method, '"] is null (scope="', scope, '")'].join('')); }
1760                 return function(){ return scope[method].apply(scope, arguments || []); }; // Function
1761         }
1762         return !scope ? method : function(){ return method.apply(scope, arguments || []); }; // Function
1763 }
1764
1765 /*=====
1766 dojo.delegate = function(obj, props){
1767         //      summary:
1768         //              returns a new object which "looks" to obj for properties which it
1769         //              does not have a value for. Optionally takes a bag of properties to
1770         //              seed the returned object with initially. 
1771         //      description:
1772         //              This is a small implementaton of the Boodman/Crockford delegation
1773         //              pattern in JavaScript. An intermediate object constructor mediates
1774         //              the prototype chain for the returned object, using it to delegate
1775         //              down to obj for property lookup when object-local lookup fails.
1776         //              This can be thought of similarly to ES4's "wrap", save that it does
1777         //              not act on types but rather on pure objects.
1778         //      obj:
1779         //              The object to delegate to for properties not found directly on the
1780         //              return object or in props.
1781         //      props:
1782         //              an object containing properties to assign to the returned object
1783         //      returns:
1784         //              an Object of anonymous type
1785         //      example:
1786         //      |       var foo = { bar: "baz" };
1787         //      |       var thinger = dojo.delegate(foo, { thud: "xyzzy"});
1788         //      |       thinger.bar == "baz"; // delegated to foo
1789         //      |       foo.thud == undefined; // by definition
1790         //      |       thinger.thud == "xyzzy"; // mixed in from props
1791         //      |       foo.bar = "thonk";
1792         //      |       thinger.bar == "thonk"; // still delegated to foo's bar
1793 }
1794 =====*/
1795
1796 dojo.delegate = dojo._delegate = (function(){
1797         // boodman/crockford delegation w/ cornford optimization
1798         function TMP(){};
1799         return function(obj, props){
1800                 TMP.prototype = obj;
1801                 var tmp = new TMP();
1802                 if(props){
1803                         dojo._mixin(tmp, props);
1804                 }
1805                 return tmp; // Object
1806         }
1807 })();
1808
1809 /*=====
1810 dojo._toArray = function(obj, offset, startWith){
1811         //      summary:
1812         //              Converts an array-like object (i.e. arguments, DOMCollection) to an
1813         //              array. Returns a new Array with the elements of obj.
1814         //      obj: Object
1815         //              the object to "arrayify". We expect the object to have, at a
1816         //              minimum, a length property which corresponds to integer-indexed
1817         //              properties.
1818         //      offset: Number?
1819         //              the location in obj to start iterating from. Defaults to 0.
1820         //              Optional.
1821         //      startWith: Array?
1822         //              An array to pack with the properties of obj. If provided,
1823         //              properties in obj are appended at the end of startWith and
1824         //              startWith is the returned array.
1825 }
1826 =====*/
1827
1828 (function(){
1829         var efficient = function(obj, offset, startWith){
1830                 return (startWith||[]).concat(Array.prototype.slice.call(obj, offset||0));
1831         };
1832
1833         var slow = function(obj, offset, startWith){
1834                 var arr = startWith||[]; 
1835                 for(var x = offset || 0; x < obj.length; x++){ 
1836                         arr.push(obj[x]); 
1837                 } 
1838                 return arr;
1839         };
1840
1841         dojo._toArray = (!dojo.isIE) ? efficient : function(obj){
1842                 return ((obj.item) ? slow : efficient).apply(this, arguments);
1843         };
1844
1845 })();
1846
1847 dojo.partial = function(/*Function|String*/method /*, ...*/){
1848         //      summary:
1849         //              similar to hitch() except that the scope object is left to be
1850         //              whatever the execution context eventually becomes.
1851         //      description:
1852         //              Calling dojo.partial is the functional equivalent of calling:
1853         //              |       dojo.hitch(null, funcName, ...);
1854         var arr = [ null ];
1855         return dojo.hitch.apply(dojo, arr.concat(dojo._toArray(arguments))); // Function
1856 }
1857
1858 dojo.clone = function(/*anything*/ o){
1859         // summary:
1860         //              Clones objects (including DOM nodes) and all children.
1861         //              Warning: do not clone cyclic structures.
1862         if(!o){ return o; }
1863         if(dojo.isArray(o)){
1864                 var r = [];
1865                 for(var i = 0; i < o.length; ++i){
1866                         r.push(dojo.clone(o[i]));
1867                 }
1868                 return r; // Array
1869         }
1870         if(!dojo.isObject(o)){
1871                 return o;       /*anything*/
1872         }
1873         if(o.nodeType && o.cloneNode){ // isNode
1874                 return o.cloneNode(true); // Node
1875         }
1876         if(o instanceof Date){
1877                 return new Date(o.getTime());   // Date
1878         }
1879         // Generic objects
1880         var r = new o.constructor(); // specific to dojo.declare()'d classes!
1881         for(var i in o){
1882                 if(!(i in r) || r[i] != o[i]){
1883                         r[i] = dojo.clone(o[i]);
1884                 }
1885         }
1886         return r; // Object
1887 }
1888
1889 dojo.trim = function(/*String*/ str){
1890         // summary: 
1891         //              trims whitespaces from both sides of the string
1892         // description:
1893         //              This version of trim() was selected for inclusion into the base due
1894         //              to its compact size and relatively good performance (see Steven
1895         //              Levithan's blog:
1896         //              http://blog.stevenlevithan.com/archives/faster-trim-javascript).
1897         //              The fastest but longest version of this function is located at
1898         //              dojo.string.trim()
1899         return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); // String
1900 }
1901
1902 }
1903
1904 if(!dojo._hasResource["dojo._base.declare"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
1905 dojo._hasResource["dojo._base.declare"] = true;
1906 dojo.provide("dojo._base.declare");
1907
1908
1909 // this file courtesy of the TurboAjax Group, licensed under a Dojo CLA
1910
1911 dojo.declare = function(/*String*/ className, /*Function|Function[]*/ superclass, /*Object*/ props){
1912         //      summary: 
1913         //              Create a feature-rich constructor from compact notation
1914         //      className:
1915         //              The name of the constructor (loosely, a "class")
1916         //              stored in the "declaredClass" property in the created prototype
1917         //      superclass:
1918         //              May be null, a Function, or an Array of Functions. If an array, 
1919         //              the first element is used as the prototypical ancestor and
1920         //              any following Functions become mixin ancestors.
1921         //      props:
1922         //              An object whose properties are copied to the
1923         //              created prototype.
1924         //              Add an instance-initialization function by making it a property 
1925         //              named "constructor".
1926         //      description:
1927         //              Create a constructor using a compact notation for inheritance and
1928         //              prototype extension. 
1929         //
1930         //              All superclasses (including mixins) must be Functions (not simple Objects).
1931         //
1932         //              Mixin ancestors provide a type of multiple inheritance. Prototypes of mixin 
1933         //              ancestors are copied to the new class: changes to mixin prototypes will
1934         //              not affect classes to which they have been mixed in.
1935         //
1936         //              "className" is cached in "declaredClass" property of the new class.
1937         //
1938         //      example:
1939         //      |       dojo.declare("my.classes.bar", my.classes.foo, {
1940         //      |               // properties to be added to the class prototype
1941         //      |               someValue: 2,
1942         //      |               // initialization function
1943         //      |               constructor: function(){
1944         //      |                       this.myComplicatedObject = new ReallyComplicatedObject(); 
1945         //      |               },
1946         //      |               // other functions
1947         //      |               someMethod: function(){ 
1948         //      |                       doStuff(); 
1949         //      |               }
1950         //      |       );
1951
1952         // process superclass argument
1953         var dd = arguments.callee, mixins;
1954         if(dojo.isArray(superclass)){
1955                 mixins = superclass;
1956                 superclass = mixins.shift();
1957         }
1958         // construct intermediate classes for mixins
1959         if(mixins){
1960                 dojo.forEach(mixins, function(m){
1961                         if(!m){ throw(className + ": mixin #" + i + " is null"); } // It's likely a required module is not loaded
1962                         superclass = dd._delegate(superclass, m);
1963                 });
1964         }
1965         // create constructor
1966         var ctor = dd._delegate(superclass);
1967         // extend with "props"
1968         props = props || {};
1969         ctor.extend(props);
1970         // more prototype decoration
1971         dojo.extend(ctor, {declaredClass: className, _constructor: props.constructor/*, preamble: null*/});
1972         // special help for IE
1973         ctor.prototype.constructor = ctor;
1974         // create named reference
1975         return dojo.setObject(className, ctor); // Function
1976 };
1977
1978 dojo.mixin(dojo.declare, {
1979         _delegate: function(base, mixin){
1980                 var bp = (base||0).prototype, mp = (mixin||0).prototype, dd=dojo.declare;
1981                 // fresh constructor, fresh prototype
1982                 var ctor = dd._makeCtor();
1983                 // cache ancestry
1984                 dojo.mixin(ctor, {superclass: bp, mixin: mp, extend: dd._extend});
1985                 // chain prototypes
1986                 if(base){ctor.prototype = dojo._delegate(bp);}
1987                 // add mixin and core
1988                 dojo.extend(ctor, dd._core, mp||0, {_constructor: null, preamble: null});
1989                 // special help for IE
1990                 ctor.prototype.constructor = ctor;
1991                 // name this class for debugging
1992                 ctor.prototype.declaredClass = (bp||0).declaredClass + '_' + (mp||0).declaredClass;
1993                 return ctor;
1994         },
1995         _extend: function(props){
1996                 var i, fn;
1997                 for(i in props){ if(dojo.isFunction(fn=props[i]) && !0[i]){fn.nom=i;fn.ctor=this;} }
1998                 dojo.extend(this, props);
1999         },
2000         _makeCtor: function(){
2001                 // we have to make a function, but don't want to close over anything
2002                 return function(){ this._construct(arguments); };
2003         },
2004         _core: { 
2005                 _construct: function(args){
2006                         var c=args.callee, s=c.superclass, ct=s&&s.constructor, m=c.mixin, mct=m&&m.constructor, a=args, ii, fn;
2007                         // side-effect of = used on purpose here, lint may complain, don't try this at home
2008                         if(a[0]){ 
2009                                 // FIXME: preambles for each mixin should be allowed
2010                                 // FIXME: 
2011                                 //              should we allow the preamble here NOT to modify the
2012                                 //              default args, but instead to act on each mixin
2013                                 //              independently of the class instance being constructed
2014                                 //              (for impedence matching)?
2015
2016                                 // allow any first argument w/ a "preamble" property to act as a
2017                                 // class preamble (not exclusive of the prototype preamble)
2018                                 if(/*dojo.isFunction*/((fn = a[0].preamble))){ 
2019                                         a = fn.apply(this, a) || a; 
2020                                 }
2021                         } 
2022                         // prototype preamble
2023                         if((fn = c.prototype.preamble)){a = fn.apply(this, a) || a;}
2024                         // FIXME: 
2025                         //              need to provide an optional prototype-settable
2026                         //              "_explicitSuper" property which disables this
2027                         // initialize superclass
2028                         if(ct&&ct.apply){ct.apply(this, a);}
2029                         // initialize mixin
2030                         if(mct&&mct.apply){mct.apply(this, a);}
2031                         // initialize self
2032                         if((ii=c.prototype._constructor)){ii.apply(this, args);}
2033                         // post construction
2034                         if(this.constructor.prototype==c.prototype && (ct=this.postscript)){ ct.apply(this, args); }
2035                 },
2036                 _findMixin: function(mixin){
2037                         var c = this.constructor, p, m;
2038                         while(c){
2039                                 p = c.superclass;
2040                                 m = c.mixin;
2041                                 if(m==mixin || (m instanceof mixin.constructor)){return p;}
2042                                 if(m && m._findMixin && (m=m._findMixin(mixin))){return m;}
2043                                 c = p && p.constructor;
2044                         }
2045                 },
2046                 _findMethod: function(name, method, ptype, has){
2047                         // consciously trading readability for bytes and speed in this low-level method
2048                         var p=ptype, c, m, f;
2049                         do{
2050                                 c = p.constructor;
2051                                 m = c.mixin;
2052                                 // find method by name in our mixin ancestor
2053                                 if(m && (m=this._findMethod(name, method, m, has))){return m;}
2054                                 // if we found a named method that either exactly-is or exactly-is-not 'method'
2055                                 if((f=p[name])&&(has==(f==method))){return p;}
2056                                 // ascend chain
2057                                 p = c.superclass;
2058                         }while(p);
2059                         // if we couldn't find an ancestor in our primary chain, try a mixin chain
2060                         return !has && (p=this._findMixin(ptype)) && this._findMethod(name, method, p, has);
2061                 },
2062                 inherited: function(name, args, newArgs){
2063                         // optionalize name argument
2064                         var a = arguments;
2065                         if(!dojo.isString(a[0])){newArgs=args; args=name; name=args.callee.nom;}
2066                         a = newArgs||args;
2067                         var c = args.callee, p = this.constructor.prototype, fn, mp;
2068                         // if not an instance override
2069                         if(this[name] != c || p[name] == c){
2070                                 // start from memoized prototype, or
2071                                 // find a prototype that has property 'name' == 'c'
2072                                 mp = (c.ctor||0).superclass || this._findMethod(name, c, p, true);
2073                                 if(!mp){throw(this.declaredClass + ': inherited method "' + name + '" mismatch');}
2074                                 // find a prototype that has property 'name' != 'c'
2075                                 p = this._findMethod(name, c, mp, false);
2076                         }
2077                         // we expect 'name' to be in prototype 'p'
2078                         fn = p && p[name];
2079                         if(!fn){throw(mp.declaredClass + ': inherited method "' + name + '" not found');}
2080                         // if the function exists, invoke it in our scope
2081                         return fn.apply(this, a);
2082                 }
2083         }
2084 });
2085
2086 }
2087
2088 if(!dojo._hasResource["dojo._base.connect"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2089 dojo._hasResource["dojo._base.connect"] = true;
2090 dojo.provide("dojo._base.connect");
2091
2092
2093 // this file courtesy of the TurboAjax Group, licensed under a Dojo CLA
2094
2095 // low-level delegation machinery
2096 dojo._listener = {
2097         // create a dispatcher function
2098         getDispatcher: function(){
2099                 // following comments pulled out-of-line to prevent cloning them 
2100                 // in the returned function.
2101                 // - indices (i) that are really in the array of listeners (ls) will 
2102                 //   not be in Array.prototype. This is the 'sparse array' trick
2103                 //   that keeps us safe from libs that take liberties with built-in 
2104                 //   objects
2105                 // - listener is invoked with current scope (this)
2106                 return function(){
2107                         var ap=Array.prototype, c=arguments.callee, ls=c._listeners, t=c.target;
2108                         // return value comes from original target function
2109                         var r = t && t.apply(this, arguments);
2110                         // make local copy of listener array so it is immutable during processing
2111                         var lls;
2112                                                                                         lls = [].concat(ls);
2113                                                         
2114                         // invoke listeners after target function
2115                         for(var i in lls){
2116                                 if(!(i in ap)){
2117                                         lls[i].apply(this, arguments);
2118                                 }
2119                         }
2120                         // return value comes from original target function
2121                         return r;
2122                 }
2123         },
2124         // add a listener to an object
2125         add: function(/*Object*/ source, /*String*/ method, /*Function*/ listener){
2126                 // Whenever 'method' is invoked, 'listener' will have the same scope.
2127                 // Trying to supporting a context object for the listener led to 
2128                 // complexity. 
2129                 // Non trivial to provide 'once' functionality here
2130                 // because listener could be the result of a dojo.hitch call,
2131                 // in which case two references to the same hitch target would not
2132                 // be equivalent. 
2133                 source = source || dojo.global;
2134                 // The source method is either null, a dispatcher, or some other function
2135                 var f = source[method];
2136                 // Ensure a dispatcher
2137                 if(!f||!f._listeners){
2138                         var d = dojo._listener.getDispatcher();
2139                         // original target function is special
2140                         d.target = f;
2141                         // dispatcher holds a list of listeners
2142                         d._listeners = []; 
2143                         // redirect source to dispatcher
2144                         f = source[method] = d;
2145                 }
2146                 // The contract is that a handle is returned that can 
2147                 // identify this listener for disconnect. 
2148                 //
2149                 // The type of the handle is private. Here is it implemented as Integer. 
2150                 // DOM event code has this same contract but handle is Function 
2151                 // in non-IE browsers.
2152                 //
2153                 // We could have separate lists of before and after listeners.
2154                 return f._listeners.push(listener) ; /*Handle*/
2155         },
2156         // remove a listener from an object
2157         remove: function(/*Object*/ source, /*String*/ method, /*Handle*/ handle){
2158                 var f = (source||dojo.global)[method];
2159                 // remember that handle is the index+1 (0 is not a valid handle)
2160                 if(f && f._listeners && handle--){
2161                         delete f._listeners[handle];
2162                 }
2163         }
2164 };
2165
2166 // Multiple delegation for arbitrary methods.
2167
2168 // This unit knows nothing about DOM, 
2169 // but we include DOM aware 
2170 // documentation and dontFix
2171 // argument here to help the autodocs.
2172 // Actual DOM aware code is in event.js.
2173
2174 dojo.connect = function(/*Object|null*/ obj, 
2175                                                 /*String*/ event, 
2176                                                 /*Object|null*/ context, 
2177                                                 /*String|Function*/ method,
2178                                                 /*Boolean*/ dontFix){
2179         // summary:
2180         //              Create a link that calls one function when another executes. 
2181         //
2182         // description:
2183         //              Connects method to event, so that after event fires, method
2184         //              does too. All connected functions are passed the same arguments as
2185         //              the event function was initially called with. You may connect as
2186         //              many methods to event as needed.
2187         //
2188         //              event must be a string. If obj is null, dojo.global is used.
2189         //
2190         //              null arguments may simply be omitted.
2191         //
2192         //              obj[event] can resolve to a function or undefined (null). 
2193         //              If obj[event] is null, it is assigned a function.
2194         //
2195         //              The return value is a handle that is needed to 
2196         //              remove this connection with dojo.disconnect.
2197         //
2198         // obj: 
2199         //              The source object for the event function. 
2200         //              Defaults to dojo.global if null.
2201         //              If obj is a DOM node, the connection is delegated 
2202         //              to the DOM event manager (unless dontFix is true).
2203         //
2204         // event:
2205         //              String name of the event function in obj. 
2206         //              I.e. identifies a property obj[event].
2207         //
2208         // context: 
2209         //              The object that method will receive as "this".
2210         //
2211         //              If context is null and method is a function, then method
2212         //              inherits the context of event.
2213         //      
2214         //              If method is a string then context must be the source 
2215         //              object object for method (context[method]). If context is null,
2216         //              dojo.global is used.
2217         //
2218         // method:
2219         //              A function reference, or name of a function in context. 
2220         //              The function identified by method fires after event does. 
2221         //              method receives the same arguments as the event.
2222         //              See context argument comments for information on method's scope.
2223         //
2224         // dontFix:
2225         //              If obj is a DOM node, set dontFix to true to prevent delegation 
2226         //              of this connection to the DOM event manager. 
2227         //
2228         // example:
2229         //              When obj.onchange(), do ui.update():
2230         //      |       dojo.connect(obj, "onchange", ui, "update");
2231         //      |       dojo.connect(obj, "onchange", ui, ui.update); // same
2232         //
2233         // example:
2234         //              Using return value for disconnect:
2235         //      |       var link = dojo.connect(obj, "onchange", ui, "update");
2236         //      |       ...
2237         //      |       dojo.disconnect(link);
2238         //
2239         // example:
2240         //              When onglobalevent executes, watcher.handler is invoked:
2241         //      |       dojo.connect(null, "onglobalevent", watcher, "handler");
2242         //
2243         // example:
2244         //              When ob.onCustomEvent executes, customEventHandler is invoked:
2245         //      |       dojo.connect(ob, "onCustomEvent", null, "customEventHandler");
2246         //      |       dojo.connect(ob, "onCustomEvent", "customEventHandler"); // same
2247         //
2248         // example:
2249         //              When ob.onCustomEvent executes, customEventHandler is invoked
2250         //              with the same scope (this):
2251         //      |       dojo.connect(ob, "onCustomEvent", null, customEventHandler);
2252         //      |       dojo.connect(ob, "onCustomEvent", customEventHandler); // same
2253         //
2254         // example:
2255         //              When globalEvent executes, globalHandler is invoked
2256         //              with the same scope (this):
2257         //      |       dojo.connect(null, "globalEvent", null, globalHandler);
2258         //      |       dojo.connect("globalEvent", globalHandler); // same
2259
2260         // normalize arguments
2261         var a=arguments, args=[], i=0;
2262         // if a[0] is a String, obj was ommited
2263         args.push(dojo.isString(a[0]) ? null : a[i++], a[i++]);
2264         // if the arg-after-next is a String or Function, context was NOT omitted
2265         var a1 = a[i+1];
2266         args.push(dojo.isString(a1)||dojo.isFunction(a1) ? a[i++] : null, a[i++]);
2267         // absorb any additional arguments
2268         for(var l=a.length; i<l; i++){  args.push(a[i]); }
2269         // do the actual work
2270         return dojo._connect.apply(this, args); /*Handle*/
2271 }
2272
2273 // used by non-browser hostenvs. always overriden by event.js
2274 dojo._connect = function(obj, event, context, method){
2275         var l=dojo._listener, h=l.add(obj, event, dojo.hitch(context, method)); 
2276         return [obj, event, h, l]; // Handle
2277 }
2278
2279 dojo.disconnect = function(/*Handle*/ handle){
2280         // summary:
2281         //              Remove a link created by dojo.connect.
2282         // description:
2283         //              Removes the connection between event and the method referenced by handle.
2284         // handle:
2285         //              the return value of the dojo.connect call that created the connection.
2286         if(handle && handle[0] !== undefined){
2287                 dojo._disconnect.apply(this, handle);
2288                 // let's not keep this reference
2289                 delete handle[0];
2290         }
2291 }
2292
2293 dojo._disconnect = function(obj, event, handle, listener){
2294         listener.remove(obj, event, handle);
2295 }
2296
2297 // topic publish/subscribe
2298
2299 dojo._topics = {};
2300
2301 dojo.subscribe = function(/*String*/ topic, /*Object|null*/ context, /*String|Function*/ method){
2302         //      summary:
2303         //              Attach a listener to a named topic. The listener function is invoked whenever the
2304         //              named topic is published (see: dojo.publish).
2305         //              Returns a handle which is needed to unsubscribe this listener.
2306         //      context:
2307         //              Scope in which method will be invoked, or null for default scope.
2308         //      method:
2309         //              The name of a function in context, or a function reference. This is the function that
2310         //              is invoked when topic is published.
2311         //      example:
2312         //      |       dojo.subscribe("alerts", null, function(caption, message){ alert(caption + "\n" + message); };
2313         //      |       dojo.publish("alerts", [ "read this", "hello world" ]);                                                                                                                                 
2314
2315         // support for 2 argument invocation (omitting context) depends on hitch
2316         return [topic, dojo._listener.add(dojo._topics, topic, dojo.hitch(context, method))]; /*Handle*/
2317 }
2318
2319 dojo.unsubscribe = function(/*Handle*/ handle){
2320         //      summary:
2321         //              Remove a topic listener. 
2322         //      handle:
2323         //              The handle returned from a call to subscribe.
2324         //      example:
2325         //      |       var alerter = dojo.subscribe("alerts", null, function(caption, message){ alert(caption + "\n" + message); };
2326         //      |       ...
2327         //      |       dojo.unsubscribe(alerter);
2328         if(handle){
2329                 dojo._listener.remove(dojo._topics, handle[0], handle[1]);
2330         }
2331 }
2332
2333 dojo.publish = function(/*String*/ topic, /*Array*/ args){
2334         //      summary:
2335         //              Invoke all listener method subscribed to topic.
2336         //      topic:
2337         //              The name of the topic to publish.
2338         //      args:
2339         //              An array of arguments. The arguments will be applied 
2340         //              to each topic subscriber (as first class parameters, via apply).
2341         //      example:
2342         //      |       dojo.subscribe("alerts", null, function(caption, message){ alert(caption + "\n" + message); };
2343         //      |       dojo.publish("alerts", [ "read this", "hello world" ]); 
2344
2345         // Note that args is an array, which is more efficient vs variable length
2346         // argument list.  Ideally, var args would be implemented via Array
2347         // throughout the APIs.
2348         var f = dojo._topics[topic];
2349         if(f){
2350                 f.apply(this, args||[]);
2351         }
2352 }
2353
2354 dojo.connectPublisher = function(       /*String*/ topic, 
2355                                                                         /*Object|null*/ obj, 
2356                                                                         /*String*/ event){
2357         //      summary:
2358         //              Ensure that everytime obj.event() is called, a message is published
2359         //              on the topic. Returns a handle which can be passed to
2360         //              dojo.disconnect() to disable subsequent automatic publication on
2361         //              the topic.
2362         //      topic:
2363         //              The name of the topic to publish.
2364         //      obj: 
2365         //              The source object for the event function. Defaults to dojo.global
2366         //              if null.
2367         //      event:
2368         //              The name of the event function in obj. 
2369         //              I.e. identifies a property obj[event].
2370         //      example:
2371         //      |       dojo.connectPublisher("/ajax/start", dojo, "xhrGet");
2372         var pf = function(){ dojo.publish(topic, arguments); }
2373         return (event) ? dojo.connect(obj, event, pf) : dojo.connect(obj, pf); //Handle
2374 };
2375
2376 }
2377
2378 if(!dojo._hasResource["dojo._base.Deferred"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2379 dojo._hasResource["dojo._base.Deferred"] = true;
2380 dojo.provide("dojo._base.Deferred");
2381
2382
2383 dojo.Deferred = function(/*Function?*/ canceller){
2384         // summary:
2385         //              Encapsulates a sequence of callbacks in response to a value that
2386         //              may not yet be available.  This is modeled after the Deferred class
2387         //              from Twisted <http://twistedmatrix.com>.
2388         // description:
2389         //              JavaScript has no threads, and even if it did, threads are hard.
2390         //              Deferreds are a way of abstracting non-blocking events, such as the
2391         //              final response to an XMLHttpRequest. Deferreds create a promise to
2392         //              return a response a some point in the future and an easy way to
2393         //              register your interest in receiving that response.
2394         //
2395         //              The most important methods for Deffered users are:
2396         //
2397         //                      * addCallback(handler)
2398         //                      * addErrback(handler)
2399         //                      * callback(result)
2400         //                      * errback(result)
2401         //
2402         //              In general, when a function returns a Deferred, users then "fill
2403         //              in" the second half of the contract by registering callbacks and
2404         //              error handlers. You may register as many callback and errback
2405         //              handlers as you like and they will be executed in the order
2406         //              registered when a result is provided. Usually this result is
2407         //              provided as the result of an asynchronous operation. The code
2408         //              "managing" the Deferred (the code that made the promise to provide
2409         //              an answer later) will use the callback() and errback() methods to
2410         //              communicate with registered listeners about the result of the
2411         //              operation. At this time, all registered result handlers are called
2412         //              *with the most recent result value*.
2413         //
2414         //              Deferred callback handlers are treated as a chain, and each item in
2415         //              the chain is required to return a value that will be fed into
2416         //              successive handlers. The most minimal callback may be registered
2417         //              like this:
2418         //
2419         //              |       var d = new dojo.Deferred();
2420         //              |       d.addCallback(function(result){ return result; });
2421         //
2422         //              Perhaps the most common mistake when first using Deferreds is to
2423         //              forget to return a value (in most cases, the value you were
2424         //              passed).
2425         //
2426         //              The sequence of callbacks is internally represented as a list of
2427         //              2-tuples containing the callback/errback pair.  For example, the
2428         //              following call sequence:
2429         //              
2430         //              |       var d = new dojo.Deferred();
2431         //              |       d.addCallback(myCallback);
2432         //              |       d.addErrback(myErrback);
2433         //              |       d.addBoth(myBoth);
2434         //              |       d.addCallbacks(myCallback, myErrback);
2435         //
2436         //              is translated into a Deferred with the following internal
2437         //              representation:
2438         //
2439         //              |       [
2440         //              |               [myCallback, null],
2441         //              |               [null, myErrback],
2442         //              |               [myBoth, myBoth],
2443         //              |               [myCallback, myErrback]
2444         //              |       ]
2445         //
2446         //              The Deferred also keeps track of its current status (fired).  Its
2447         //              status may be one of three things:
2448         //
2449         //                      * -1: no value yet (initial condition)
2450         //                      * 0: success
2451         //                      * 1: error
2452         //      
2453         //              A Deferred will be in the error state if one of the following three
2454         //              conditions are met:
2455         //
2456         //                      1. The result given to callback or errback is "instanceof" Error
2457         //                      2. The previous callback or errback raised an exception while
2458         //                         executing
2459         //                      3. The previous callback or errback returned a value
2460         //                         "instanceof" Error
2461         //
2462         //              Otherwise, the Deferred will be in the success state. The state of
2463         //              the Deferred determines the next element in the callback sequence
2464         //              to run.
2465         //
2466         //              When a callback or errback occurs with the example deferred chain,
2467         //              something equivalent to the following will happen (imagine
2468         //              that exceptions are caught and returned):
2469         //
2470         //              |       // d.callback(result) or d.errback(result)
2471         //              |       if(!(result instanceof Error)){
2472         //              |               result = myCallback(result);
2473         //              |       }
2474         //              |       if(result instanceof Error){
2475         //              |               result = myErrback(result);
2476         //              |       }
2477         //              |       result = myBoth(result);
2478         //              |       if(result instanceof Error){
2479         //              |               result = myErrback(result);
2480         //              |       }else{
2481         //              |               result = myCallback(result);
2482         //              |       }
2483         //
2484         //              The result is then stored away in case another step is added to the
2485         //              callback sequence.      Since the Deferred already has a value
2486         //              available, any new callbacks added will be called immediately.
2487         //
2488         //              There are two other "advanced" details about this implementation
2489         //              that are useful:
2490         //
2491         //              Callbacks are allowed to return Deferred instances themselves, so
2492         //              you can build complicated sequences of events with ease.
2493         //
2494         //              The creator of the Deferred may specify a canceller.  The canceller
2495         //              is a function that will be called if Deferred.cancel is called
2496         //              before the Deferred fires. You can use this to implement clean
2497         //              aborting of an XMLHttpRequest, etc. Note that cancel will fire the
2498         //              deferred with a CancelledError (unless your canceller returns
2499         //              another kind of error), so the errbacks should be prepared to
2500         //              handle that error for cancellable Deferreds.
2501         // example:
2502         //      |       var deferred = new dojo.Deferred();
2503         //      |       setTimeout(function(){ deferred.callback({success: true}); }, 1000);
2504         //      |       return deferred;
2505         // example:
2506         //              Deferred objects are often used when making code asynchronous. It