src/cm/media/js/lib/yui/yui3.0.0/build/compat/compat.js
changeset 0 40c8f766c9b8
equal deleted inserted replaced
-1:000000000000 0:40c8f766c9b8
       
     1 /*
       
     2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
       
     3 Code licensed under the BSD License:
       
     4 http://developer.yahoo.net/yui/license.txt
       
     5 version: 3.0.0
       
     6 build: 1549
       
     7 */
       
     8 YUI.add('compat', function(Y) {
       
     9 
       
    10 
       
    11 var COMPAT_ARG = '~yui|2|compat~';
       
    12 
       
    13 
       
    14 if (window.YAHOO != YUI) {
       
    15 
       
    16     // get any existing YAHOO obj props
       
    17     var o = (window.YAHOO) ? YUI.merge(window.YAHOO) : null;
       
    18 
       
    19     // Make the YUI global the YAHOO global
       
    20     window.YAHOO = YUI;
       
    21 
       
    22     // augment old YAHOO props
       
    23     if (o) {
       
    24         Y.mix(Y, o);
       
    25     }
       
    26 }
       
    27 
       
    28 // add old namespaces
       
    29 Y.namespace("util", "widget", "example");
       
    30 
       
    31 // case/location change
       
    32 Y.env = (Y.env) ? Y.mix(Y.env, Y.Env) : Y.Env;
       
    33 Y.lang = (Y.lang) ? Y.mix(Y.lang, Y.Lang) : Y.Lang;
       
    34 Y.env.ua = Y.UA; 
       
    35 
       
    36 // support Y.register
       
    37 Y.mix(Y.env, {
       
    38         modules: [],
       
    39         listeners: [],
       
    40         getVersion: function(name) {
       
    41             return this.Env.modules[name] || null;
       
    42         }
       
    43 });
       
    44 
       
    45 var L = Y.lang;
       
    46 
       
    47 // add old lang properties 
       
    48 Y.mix(L, {
       
    49 
       
    50     augmentObject: function(r, s) {
       
    51         var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null;
       
    52         return Y.mix(r, s, (wl), wl);
       
    53     },
       
    54  
       
    55     augmentProto: function(r, s) {
       
    56         var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null;
       
    57         return Y.mix(r, s, (wl), wl, 1);
       
    58     },
       
    59 
       
    60     // extend: Y.bind(Y.extend, Y), 
       
    61     extend: Y.extend,
       
    62     // merge: Y.bind(Y.merge, Y)
       
    63     merge: Y.merge
       
    64 }, true);
       
    65 
       
    66 L.augment = L.augmentProto;
       
    67 
       
    68 L.hasOwnProperty = function(o, k) {
       
    69     return (o.hasOwnProperty(k));
       
    70 };
       
    71 
       
    72 Y.augmentProto = L.augmentProto;
       
    73 
       
    74 // add register function
       
    75 Y.mix(Y, {
       
    76     register: function(name, mainClass, data) {
       
    77         var mods = Y.Env.modules;
       
    78         if (!mods[name]) {
       
    79             mods[name] = { versions:[], builds:[] };
       
    80         }
       
    81         var m=mods[name],v=data.version,b=data.build,ls=Y.Env.listeners;
       
    82         m.name = name;
       
    83         m.version = v;
       
    84         m.build = b;
       
    85         m.versions.push(v);
       
    86         m.builds.push(b);
       
    87         m.mainClass = mainClass;
       
    88         // fire the module load listeners
       
    89         for (var i=0;i<ls.length;i=i+1) {
       
    90             ls[i](m);
       
    91         }
       
    92         // label the main class
       
    93         if (mainClass) {
       
    94             mainClass.VERSION = v;
       
    95             mainClass.BUILD = b;
       
    96         } else {
       
    97         }
       
    98     }
       
    99 });
       
   100 
       
   101 // add old load listeners
       
   102 if ("undefined" !== typeof YAHOO_config) {
       
   103     var l=YAHOO_config.listener,ls=Y.Env.listeners,unique=true,i;
       
   104     if (l) {
       
   105         // if YAHOO is loaded multiple times we need to check to see if
       
   106         // this is a new config object.  If it is, add the new component
       
   107         // load listener to the stack
       
   108         for (i=0;i<ls.length;i=i+1) {
       
   109             if (ls[i]==l) {
       
   110                 unique=false;
       
   111                 break;
       
   112             }
       
   113         }
       
   114         if (unique) {
       
   115             ls.push(l);
       
   116         }
       
   117     }
       
   118 }
       
   119     
       
   120 // add old registration for yahoo
       
   121 Y.register("yahoo", Y, {version: "3.0.0", build: "1549"});
       
   122 
       
   123 if (Y.Event) {
       
   124 
       
   125     var o = {
       
   126         
       
   127         /**
       
   128          * Safari detection
       
   129          * @property isSafari
       
   130          * @private
       
   131          * @static
       
   132          * @deprecated use Y.Env.UA.webkit
       
   133          */
       
   134         isSafari: Y.UA.webkit,
       
   135         
       
   136         /**
       
   137          * webkit version
       
   138          * @property webkit
       
   139          * @type string
       
   140          * @private
       
   141          * @static
       
   142          * @deprecated use Y.Env.UA.webkit
       
   143          */
       
   144         webkit: Y.UA.webkit,
       
   145 
       
   146         /**
       
   147          * Normalized keycodes for webkit/safari
       
   148          * @property webkitKeymap
       
   149          * @type {int: int}
       
   150          * @private
       
   151          * @static
       
   152          * @final
       
   153          */
       
   154         webkitKeymap: {
       
   155             63232: 38, // up
       
   156             63233: 40, // down
       
   157             63234: 37, // left
       
   158             63235: 39, // right
       
   159             63276: 33, // page up
       
   160             63277: 34, // page down
       
   161             25: 9      // SHIFT-TAB (Safari provides a different key code in
       
   162                        // this case, even though the shiftKey modifier is set)
       
   163         },
       
   164         
       
   165         /**
       
   166          * IE detection 
       
   167          * @property isIE
       
   168          * @private
       
   169          * @static
       
   170          * @deprecated use Y.Env.UA.ie
       
   171          */
       
   172         isIE: Y.UA.ie,
       
   173 
       
   174         /**
       
   175          * Returns scrollLeft
       
   176          * @method _getScrollLeft
       
   177          * @static
       
   178          * @private
       
   179          */
       
   180         _getScrollLeft: function() {
       
   181             return this._getScroll()[1];
       
   182         },
       
   183 
       
   184         /**
       
   185          * Returns scrollTop
       
   186          * @method _getScrollTop
       
   187          * @static
       
   188          * @private
       
   189          */
       
   190         _getScrollTop: function() {
       
   191             return this._getScroll()[0];
       
   192         },
       
   193 
       
   194         /**
       
   195          * Returns the scrollTop and scrollLeft.  Used to calculate the 
       
   196          * pageX and pageY in Internet Explorer
       
   197          * @method _getScroll
       
   198          * @static
       
   199          * @private
       
   200          */
       
   201         _getScroll: function() {
       
   202             var d = Y.config.doc, dd = d.documentElement, db = d.body;
       
   203             if (dd && (dd.scrollTop || dd.scrollLeft)) {
       
   204                 return [dd.scrollTop, dd.scrollLeft];
       
   205             } else if (db) {
       
   206                 return [db.scrollTop, db.scrollLeft];
       
   207             } else {
       
   208                 return [0, 0];
       
   209             }
       
   210         },
       
   211 
       
   212         /**
       
   213          * Returns the event's pageX
       
   214          * @method getPageX
       
   215          * @param {Event} ev the event
       
   216          * @return {int} the event's pageX
       
   217          * @static
       
   218          */
       
   219         getPageX: function(ev) {
       
   220             var x = ev.pageX;
       
   221             if (!x && 0 !== x) {
       
   222                 x = ev.clientX || 0;
       
   223 
       
   224                 if ( Y.UA.ie ) {
       
   225                     x += this._getScrollLeft();
       
   226                 }
       
   227             }
       
   228 
       
   229             return x;
       
   230         },
       
   231 
       
   232         /**
       
   233          * Returns the charcode for an event
       
   234          * @method getCharCode
       
   235          * @param {Event} ev the event
       
   236          * @return {int} the event's charCode
       
   237          * @static
       
   238          */
       
   239         getCharCode: function(ev) {
       
   240             var code = ev.keyCode || ev.charCode || 0;
       
   241 
       
   242             // webkit normalization
       
   243             if (Y.UA.webkit && (code in Y.Event.webkitKeymap)) {
       
   244                 code = Y.Event.webkitKeymap[code];
       
   245             }
       
   246             return code;
       
   247         },
       
   248 
       
   249         /**
       
   250          * Returns the event's pageY
       
   251          * @method getPageY
       
   252          * @param {Event} ev the event
       
   253          * @return {int} the event's pageY
       
   254          * @static
       
   255          */
       
   256         getPageY: function(ev) {
       
   257             var y = ev.pageY;
       
   258             if (!y && 0 !== y) {
       
   259                 y = ev.clientY || 0;
       
   260 
       
   261                 if ( Y.UA.ie ) {
       
   262                     y += this._getScrollTop();
       
   263                 }
       
   264             }
       
   265 
       
   266 
       
   267             return y;
       
   268         },
       
   269 
       
   270         /**
       
   271          * Returns the pageX and pageY properties as an indexed array.
       
   272          * @method getXY
       
   273          * @param {Event} ev the event
       
   274          * @return {[x, y]} the pageX and pageY properties of the event
       
   275          * @static
       
   276          */
       
   277         getXY: function(ev) {
       
   278             return [this.getPageX(ev), this.getPageY(ev)];
       
   279         },
       
   280 
       
   281         /**
       
   282          * Returns the event's related target 
       
   283          * @method getRelatedTarget
       
   284          * @param {Event} ev the event
       
   285          * @return {HTMLElement} the event's relatedTarget
       
   286          * @static
       
   287          */
       
   288         getRelatedTarget: function(ev) {
       
   289             var t = ev.relatedTarget;
       
   290             if (!t) {
       
   291                 if (ev.type == "mouseout") {
       
   292                     t = ev.toElement;
       
   293                 } else if (ev.type == "mouseover") {
       
   294                     t = ev.fromElement;
       
   295                 }
       
   296             }
       
   297 
       
   298             return this.resolveTextNode(t);
       
   299         },
       
   300 
       
   301         /**
       
   302          * Returns the time of the event.  If the time is not included, the
       
   303          * event is modified using the current time.
       
   304          * @method getTime
       
   305          * @param {Event} ev the event
       
   306          * @return {Date} the time of the event
       
   307          * @static
       
   308          */
       
   309         getTime: function(ev) {
       
   310             if (!ev.time) {
       
   311                 var t = new Date().getTime();
       
   312                 try {
       
   313                     ev.time = t;
       
   314                 } catch(ex) { 
       
   315                     this.lastError = ex;
       
   316                     return t;
       
   317                 }
       
   318             }
       
   319 
       
   320             return ev.time;
       
   321         },
       
   322 
       
   323         /**
       
   324          * Convenience method for stopPropagation + preventDefault
       
   325          * @method stopEvent
       
   326          * @param {Event} ev the event
       
   327          * @static
       
   328          */
       
   329         stopEvent: function(ev) {
       
   330             this.stopPropagation(ev);
       
   331             this.preventDefault(ev);
       
   332         },
       
   333 
       
   334         /**
       
   335          * Stops event propagation
       
   336          * @method stopPropagation
       
   337          * @param {Event} ev the event
       
   338          * @static
       
   339          */
       
   340         stopPropagation: function(ev) {
       
   341             if (ev.stopPropagation) {
       
   342                 ev.stopPropagation();
       
   343             } else {
       
   344                 ev.cancelBubble = true;
       
   345             }
       
   346         },
       
   347 
       
   348         /**
       
   349          * Prevents the default behavior of the event
       
   350          * @method preventDefault
       
   351          * @param {Event} ev the event
       
   352          * @static
       
   353          */
       
   354         preventDefault: function(ev) {
       
   355             if (ev.preventDefault) {
       
   356                 ev.preventDefault();
       
   357             } else {
       
   358                 ev.returnValue = false;
       
   359             }
       
   360         },
       
   361 
       
   362         /**
       
   363          * Returns the event's target element.  Safari sometimes provides
       
   364          * a text node, and this is automatically resolved to the text
       
   365          * node's parent so that it behaves like other browsers.
       
   366          * @method getTarget
       
   367          * @param {Event} ev the event
       
   368          * @param {boolean} resolveTextNode when set to true the target's
       
   369          *                  parent will be returned if the target is a 
       
   370          *                  text node.  @deprecated, the text node is
       
   371          *                  now resolved automatically
       
   372          * @return {HTMLElement} the event's target
       
   373          * @static
       
   374          */
       
   375         getTarget: function(ev, resolveTextNode) {
       
   376             var t = ev.target || ev.srcElement;
       
   377             return this.resolveTextNode(t);
       
   378         },
       
   379 
       
   380         /**
       
   381          * In some cases, some browsers will return a text node inside
       
   382          * the actual element that was targeted.  This normalizes the
       
   383          * return value for getTarget and getRelatedTarget.
       
   384          * @method resolveTextNode
       
   385          * @param {HTMLElement} node node to resolve
       
   386          * @return {HTMLElement} the normized node
       
   387          * @static
       
   388          */
       
   389         resolveTextNode: function(node) {
       
   390             if (node && 3 == node.nodeType) {
       
   391                 return node.parentNode;
       
   392             } else {
       
   393                 return node;
       
   394             }
       
   395         },
       
   396 
       
   397         /**
       
   398          * We cache elements bound by id because when the unload event 
       
   399          * fires, we can no longer use document.getElementById
       
   400          * @method getEl
       
   401          * @static
       
   402          * @private
       
   403          * @deprecated Elements are not cached any longer
       
   404          */
       
   405         getEl: function(id) {
       
   406             return Y.get(id);
       
   407         }
       
   408     };
       
   409 
       
   410     Y.mix(Y.Event, o);
       
   411 
       
   412     /**
       
   413      * Calls Y.Event.attach with the correct argument order
       
   414      * @method removeListener
       
   415      */
       
   416     Y.Event.removeListener = function(el, type, fn, data, override) {
       
   417 
       
   418         var context, a=[type, fn, el];
       
   419 
       
   420         if (data) {
       
   421 
       
   422             if (override) {
       
   423                 context = (override === true) ? data : override;
       
   424             }
       
   425 
       
   426             a.push(context);
       
   427             a.push(data);
       
   428         }
       
   429 
       
   430         a.push(COMPAT_ARG);
       
   431 
       
   432         return Y.Event.detach.apply(Y.Event, a);
       
   433     };
       
   434 
       
   435     /**
       
   436      * Calls Y.Event.detach with the correct argument order
       
   437      * @method addListener
       
   438      */
       
   439     Y.Event.addListener = function(el, type, fn, data, override) {
       
   440 
       
   441 
       
   442         // var a = Y.Array(arguments, 0, true), el = a.shift();
       
   443         // a.splice(2, 0, el);
       
   444         // return Y.Event.attach.apply(Y.Event, a);
       
   445         var context, a=[type, fn, el];
       
   446 
       
   447         if (data) {
       
   448 
       
   449             if (override) {
       
   450                 context = (override === true) ? data : override;
       
   451             }
       
   452 
       
   453             a.push(context);
       
   454             a.push(data);
       
   455         }
       
   456 
       
   457         a.push(COMPAT_ARG);
       
   458 
       
   459         return Y.Event.attach.apply(Y.Event, a);
       
   460     };
       
   461 
       
   462     Y.Event.on = Y.Event.addListener;
       
   463 
       
   464     var newOnavail = Y.Event.onAvailable;
       
   465 
       
   466     Y.Event.onAvailable = function(id, fn, p_obj, p_override) {
       
   467         return newOnavail(id, fn, p_obj, p_override, false, true);
       
   468     };
       
   469 
       
   470     Y.Event.onContentReady = function(id, fn, p_obj, p_override) {
       
   471         return newOnavail(id, fn, p_obj, p_override, true, true);
       
   472     };
       
   473 
       
   474     Y.Event.onDOMReady = function(fn) {
       
   475         var a = Y.Array(arguments, 0, true);
       
   476         a.unshift('event:ready');
       
   477         return Y.on.apply(Y, a);
       
   478     };
       
   479 
       
   480     Y.util.Event = Y.Event;
       
   481 
       
   482     var CE = function(type, oScope, silent, signature) {
       
   483         //debugger;
       
   484 
       
   485         var o = {
       
   486             context: oScope,
       
   487             silent: silent || false
       
   488             // signature: signature || CE.LIST
       
   489         };
       
   490 
       
   491         CE.superclass.constructor.call(this, type, o);
       
   492 
       
   493         this.signature = signature || CE.LIST;
       
   494     };
       
   495 
       
   496     Y.extend(CE, Y.CustomEvent, {
       
   497 
       
   498     });
       
   499 
       
   500     /**
       
   501      * Subscriber listener sigature constant.  The LIST type returns three
       
   502      * parameters: the event type, the array of args passed to fire, and
       
   503      * the optional custom object
       
   504      * @property YAHOO.util.CustomEvent.LIST
       
   505      * @static
       
   506      * @type int
       
   507      */
       
   508     CE.LIST = 0;
       
   509 
       
   510     /**
       
   511      * Subscriber listener sigature constant.  The FLAT type returns two
       
   512      * parameters: the first argument passed to fire and the optional 
       
   513      * custom object
       
   514      * @property YAHOO.util.CustomEvent.FLAT
       
   515      * @static
       
   516      * @type int
       
   517      */
       
   518     CE.FLAT = 1;
       
   519 
       
   520     Y.util.CustomEvent = CE;
       
   521 
       
   522     var EP = function() {
       
   523         //console.log('Compat CustomEvent constructor executed: ' + this._yuid);
       
   524         if (!this._yuievt) {
       
   525             var sub = this.subscribe;
       
   526             Y.EventTarget.apply(this, arguments);
       
   527             this.subscribe = sub;
       
   528             this.__yuiepinit = function() {};
       
   529         }
       
   530     };
       
   531 
       
   532     Y.extend(EP, Y.EventTarget, {
       
   533 
       
   534         createEvent: function(type, o) {
       
   535             o = o || {};
       
   536             o.signature = o.signature || CE.FLAT;
       
   537             return this.publish(type, o);
       
   538         },
       
   539 
       
   540         subscribe: function(type, fn, obj, override) {
       
   541             var ce = this._yuievt.events[type] || this.createEvent(type),
       
   542                 a = Y.Array(arguments);
       
   543 
       
   544             if (override && true !== override) {
       
   545                 // a[2] = override;
       
   546                 // a[1] = obj;
       
   547             }
       
   548 
       
   549             Y.EventTarget.prototype.subscribe.apply(this, a);
       
   550         },
       
   551 
       
   552         fireEvent: function(type) {
       
   553             return this.fire.apply(this, arguments);
       
   554         },
       
   555 
       
   556         hasEvent: function(type) {
       
   557             return this.getEvent(type);
       
   558         }
       
   559     });
       
   560 
       
   561     Y.util.EventProvider = EP;
       
   562 
       
   563 }
       
   564 
       
   565 
       
   566 Y.register("event", Y, {version: "3.0.0", build: "1549"});
       
   567 
       
   568 
       
   569 var propertyCache = {};
       
   570 var patterns = {
       
   571     HYPHEN: /(-[a-z])/i, // to normalize get/setStyle
       
   572     ROOT_TAG: /^body|html$/i, // body for quirks mode, html for standards,
       
   573     OP_SCROLL:/^(?:inline|table-row)$/i
       
   574 };
       
   575 
       
   576 var hyphenToCamel = function(property) {
       
   577     if ( !patterns.HYPHEN.test(property) ) {
       
   578         return property; // no hyphens
       
   579     }
       
   580     
       
   581     if (propertyCache[property]) { // already converted
       
   582         return propertyCache[property];
       
   583     }
       
   584    
       
   585     var converted = property;
       
   586 
       
   587     while( patterns.HYPHEN.exec(converted) ) {
       
   588         converted = converted.replace(RegExp.$1,
       
   589                 RegExp.$1.substr(1).toUpperCase());
       
   590     }
       
   591     
       
   592     propertyCache[property] = converted;
       
   593     return converted;
       
   594     //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
       
   595 };
       
   596 
       
   597 var Dom = {
       
   598     get: function(el) {
       
   599         if (el) {
       
   600             if (el.nodeType || el.item) { // Node, or NodeList
       
   601                 return el;
       
   602             }
       
   603 
       
   604             if (typeof el === 'string') { // id
       
   605                 return document.getElementById(el);
       
   606             }
       
   607             
       
   608             if ('length' in el) { // array-like 
       
   609                 var c = [];
       
   610                 for (var i = 0, len = el.length; i < len; ++i) {
       
   611                     c[c.length] = Dom.get(el[i]);
       
   612                 }
       
   613                 
       
   614                 return c;
       
   615             }
       
   616 
       
   617             return el; // some other object, just pass it back
       
   618         }
       
   619 
       
   620         return null;
       
   621     },
       
   622 
       
   623     isAncestor: function(haystack, needle) {
       
   624         return YUI.DOM.contains(Dom.get(haystack), Dom.get(needle));
       
   625     },
       
   626 
       
   627     inDocument: function(el) {
       
   628         return Dom.isAncestor(Y.config.doc.documentElement, el);
       
   629     },
       
   630    
       
   631     batch: function(el, method, o, override, args) {
       
   632         el = (el && (el.tagName || el.item)) ? el : Dom.get(el); // skip get() when possible 
       
   633 
       
   634         if (!el || !method) { 
       
   635             return false; 
       
   636         }  
       
   637         if (args) {
       
   638             args = Y.Array(args);
       
   639         }
       
   640         var scope = (override) ? o : window; 
       
   641          
       
   642         var apply = function(el) {
       
   643             if (args) {
       
   644                 var tmp = slice.call(args);
       
   645                 tmp.unshift(el);
       
   646                 return method.apply(scope, tmp);
       
   647             } else {
       
   648                 return method.call(scope, el, o);
       
   649             }
       
   650         };
       
   651 
       
   652         if (el.tagName || el.length === undefined) { // element or not array-like  
       
   653             return apply(el); 
       
   654         }  
       
   655 
       
   656         var collection = []; 
       
   657          
       
   658         for (var i = 0, len = el.length; i < len; ++i) { 
       
   659             collection[collection.length] = apply(el[i]);
       
   660         } 
       
   661         
       
   662         return collection;
       
   663     },
       
   664 
       
   665     // 2.x returns false if already present
       
   666     _addClass: function(el, className) {
       
   667         if ( YUI.DOM.hasClass(el, className) ) {
       
   668             return false;
       
   669         }
       
   670 
       
   671         YUI.DOM.addClass(el, className);
       
   672         return true;
       
   673     },
       
   674 
       
   675     // 2.x returns false if not present
       
   676     _removeClass: function(el, className) {
       
   677         if ( !YUI.DOM.hasClass(el, className) ) {
       
   678             return false;
       
   679         }
       
   680 
       
   681         YUI.DOM.removeClass(el, className);
       
   682         return true;
       
   683     },
       
   684 
       
   685     // 2.x returns false if no newClass or same as oldClass
       
   686     _replaceClass: function(el, oldClass, newClass) {
       
   687         if (!newClass || oldClass === newClass) {
       
   688             return false;
       
   689         }
       
   690 
       
   691         YUI.DOM.replaceClass(el, oldClass, newClass);
       
   692         return true;
       
   693     },
       
   694 
       
   695     getElementsByClassName: function(className, tag, root) {
       
   696         tag = tag || '*';
       
   697         root = (root) ? Dom.get(root) : Y.config.doc; 
       
   698         var nodes = [];
       
   699         if (root) {
       
   700             nodes = Y.Selector.query(tag + '.' + className, root);
       
   701         }
       
   702         return nodes;
       
   703     },
       
   704 
       
   705     getElementsBy: function(method, tag, root) {
       
   706         tag = tag || '*';
       
   707         root = (root) ? Dom.get(root) : null || document;
       
   708 
       
   709         var nodes = [];
       
   710         if (root) {
       
   711             nodes = YUI.DOM.byTag(tag, root, method);
       
   712         }
       
   713         return nodes;
       
   714     },
       
   715 
       
   716     getViewportWidth: YUI.DOM.winWidth,
       
   717     getViewportHeight: YUI.DOM.winHeight,
       
   718     getDocumentWidth: YUI.DOM.docWidth,
       
   719     getDocumentHeight: YUI.DOM.docHeight,
       
   720     getDocumentScrollTop: YUI.DOM.docScrollY,
       
   721     getDocumentScrollLeft: YUI.DOM.docScrollX,
       
   722     getDocumentHeight: YUI.DOM.docHeight,
       
   723 
       
   724     _guid: function(el, prefix) {
       
   725         prefix = prefix || 'yui-gen';
       
   726         Dom._id_counter = Dom._id_counter || 0;
       
   727 
       
   728         if (el && el.id) { // do not override existing ID
       
   729             return el.id;
       
   730         } 
       
   731 
       
   732         var id = prefix + Dom._id_counter++;
       
   733 
       
   734         if (el) {
       
   735             el.id = id;
       
   736         }
       
   737         
       
   738         return id;
       
   739     },
       
   740 
       
   741     _region: function(el) {
       
   742         if ( (el.parentNode === null || el.offsetParent === null ||
       
   743                 YUI.DOM.getStyle(el, 'display') == 'none') && el != el.ownerDocument.body) {
       
   744             return false;
       
   745         }
       
   746 
       
   747         return YUI.DOM.region(el);
       
   748 
       
   749     },
       
   750 
       
   751     _ancestorByClass: function(element, className) {
       
   752         return YUI.DOM.ancestor(element, function(el) {
       
   753             return YUI.DOM.hasClass(el, className);
       
   754         });
       
   755     },
       
   756 
       
   757     _ancestorByTag: function(element, tag) {
       
   758         tag = tag.toUpperCase();
       
   759         return YUI.DOM.ancestor(element, function(el) {
       
   760             return el.tagName.toUpperCase() === tag;
       
   761         });
       
   762     }
       
   763 };
       
   764 
       
   765 var slice = [].slice;
       
   766 
       
   767 var wrap = function(fn, name) {
       
   768     Dom[name] = function() {
       
   769         var args = slice.call(arguments);
       
   770         args[0] = Dom.get(args[0]);
       
   771         return fn.apply(Dom, args);
       
   772     };
       
   773 };
       
   774 
       
   775 var wrapped = {
       
   776     getAncestorBy: YUI.DOM.ancestor,
       
   777     getAncestorByClassName: Dom._ancestorByClass,
       
   778     getAncestorByTagName: Dom._ancestorByTag,
       
   779     getPreviousSiblingBy: YUI.DOM.previous,
       
   780     getPreviousSibling: YUI.DOM.previous,
       
   781     getNextSiblingBy: YUI.DOM.next,
       
   782     getNextSibling: YUI.DOM.next,
       
   783     getFirstChildBy: YUI.DOM.firstChild,
       
   784     getFirstChild: YUI.DOM.firstChild,
       
   785     getLastChildBy: YUI.DOM.lastChild,
       
   786     getLastChild: YUI.DOM.lastChild,
       
   787     getChildrenBy: YUI.DOM.children,
       
   788     getChildren: YUI.DOM.children,
       
   789     insertBefore: function(newNode, refNode) {
       
   790         YUI.DOM.insertBefore(Dom.get(newNode), Dom.get(refNode));
       
   791     },
       
   792     insertAfter: function(newNode, refNode) {
       
   793         YUI.DOM.insertAfter(Dom.get(newNode), Dom.get(refNode));
       
   794     }
       
   795 };
       
   796 
       
   797 Y.each(wrapped, wrap);
       
   798 
       
   799 var batched = {
       
   800     getStyle: YUI.DOM.getStyle,
       
   801     setStyle: YUI.DOM.setStyle,
       
   802     getXY: YUI.DOM.getXY,
       
   803     setXY: YUI.DOM.setXY,
       
   804     getX: YUI.DOM.getX,
       
   805     getY: YUI.DOM.getY,
       
   806     setX: YUI.DOM.setX, 
       
   807     setY: YUI.DOM.setY, 
       
   808     getRegion: Dom._region,
       
   809     hasClass: YUI.DOM.hasClass,
       
   810     addClass: Dom._addClass,
       
   811     removeClass: Dom._removeClass,
       
   812     replaceClass: Dom._replaceClass,
       
   813     generateId: Dom._guid
       
   814 };
       
   815 
       
   816 Y.each(batched, function(v, n) {
       
   817     Dom[n] = function(el) {
       
   818         var args = slice.call(arguments, 1);
       
   819         return Dom.batch(el, v, null, null, args);
       
   820     };
       
   821 });
       
   822 
       
   823 Y.util.Dom = Dom;
       
   824 
       
   825 YAHOO.util.Region = function(t, r, b, l) {
       
   826     this.top = t;
       
   827     this[1] = t;
       
   828     this.right = r;
       
   829     this.bottom = b;
       
   830     this.left = l;
       
   831     this[0] = l;
       
   832 };
       
   833 
       
   834 YAHOO.util.Region.prototype.contains = function(region) {
       
   835     return ( region.left   >= this.left   && 
       
   836              region.right  <= this.right  && 
       
   837              region.top    >= this.top    && 
       
   838              region.bottom <= this.bottom    );
       
   839 
       
   840 };
       
   841 
       
   842 YAHOO.util.Region.prototype.getArea = function() {
       
   843     return ( (this.bottom - this.top) * (this.right - this.left) );
       
   844 };
       
   845 
       
   846 YAHOO.util.Region.prototype.intersect = function(region) {
       
   847     var t = Math.max( this.top,    region.top    );
       
   848     var r = Math.min( this.right,  region.right  );
       
   849     var b = Math.min( this.bottom, region.bottom );
       
   850     var l = Math.max( this.left,   region.left   );
       
   851     
       
   852     if (b >= t && r >= l) {
       
   853         return new YAHOO.util.Region(t, r, b, l);
       
   854     } else {
       
   855         return null;
       
   856     }
       
   857 };
       
   858 
       
   859 YAHOO.util.Region.prototype.union = function(region) {
       
   860     var t = Math.min( this.top,    region.top    );
       
   861     var r = Math.max( this.right,  region.right  );
       
   862     var b = Math.max( this.bottom, region.bottom );
       
   863     var l = Math.min( this.left,   region.left   );
       
   864 
       
   865     return new YAHOO.util.Region(t, r, b, l);
       
   866 };
       
   867 
       
   868 YAHOO.util.Region.prototype.toString = function() {
       
   869     return ( "Region {"    +
       
   870              "top: "       + this.top    + 
       
   871              ", right: "   + this.right  + 
       
   872              ", bottom: "  + this.bottom + 
       
   873              ", left: "    + this.left   + 
       
   874              "}" );
       
   875 };
       
   876 
       
   877 YAHOO.util.Region.getRegion = function(el) {
       
   878     return YUI.DOM.region(el);
       
   879 };
       
   880 
       
   881 YAHOO.util.Point = function(x, y) {
       
   882    if (YAHOO.lang.isArray(x)) { // accept input from Dom.getXY, Event.getXY, etc.
       
   883       y = x[1]; // dont blow away x yet
       
   884       x = x[0];
       
   885    }
       
   886    
       
   887     this.x = this.right = this.left = this[0] = x;
       
   888     this.y = this.top = this.bottom = this[1] = y;
       
   889 };
       
   890 
       
   891 YAHOO.util.Point.prototype = new YAHOO.util.Region();
       
   892 
       
   893 
       
   894 
       
   895 }, '3.0.0' ,{requires:['dom','event']});
       
   896 YUI._setup(); YUI.use('dom', 'event', 'compat');