rem: windowHeight = [document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a, b){return(a-b);})[1]; 
add: (function() { var Y = YAHOO.util, getStyle, setStyle, id_counter = 0, propertyCache = {};   var ua = navigator.userAgent.toLowerCase(), isOpera = (ua.indexOf('opera') > -1), isSafari = (ua.indexOf('safari') > -1), isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1), isIE = (!isOpera && ua.indexOf('msie') > -1);   var patterns = { HYPHEN: /(-[a-z])/i };  var logger = {}; logger.log = function() { YAHOO.log.apply(window, arguments); };  var toCamel = function(property) { if ( !patterns.HYPHEN.test(property) ) { return property; }  if (propertyCache[property]) { return propertyCache[property]; }  while( patterns.HYPHEN.exec(property) ) { property = property.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase()); }  propertyCache[property] = property; return property;  };   if (document.defaultView && document.defaultView.getComputedStyle) { getStyle = function(el, property) { var value = null;  var computed = document.defaultView.getComputedStyle(el, ''); if (computed) { value = computed[toCamel(property)]; }  return el.style[property] || value; }; } else if (document.documentElement.currentStyle && isIE) { getStyle = function(el, property) { switch( toCamel(property) ) { case 'opacity' : var val = 100; try { val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;  } catch(e) { try { val = el.filters('alpha').opacity; } catch(e) { logger.log('getStyle: IE filter failed', 'error', 'Dom'); } } return val / 100; break; default:  var value = el.currentStyle ? el.currentStyle[property] : null; return ( el.style[property] || value ); } }; } else { getStyle = function(el, property) { return el.style[property]; }; }  if (isIE) { setStyle = function(el, property, val) { switch (property) { case 'opacity': if ( typeof el.style.filter == 'string' ) { el.style.filter = 'alpha(opacity=' + val * 100 + ')';  if (!el.currentStyle || !el.currentStyle.hasLayout) { el.style.zoom = 1; } } break; default: el.style[property] = val; } }; } else { setStyle = function(el, property, val) { el.style[property] = val; }; }  /** * Provides helper methods for DOM elements. * @namespace YAHOO.util * @class Dom */ YAHOO.util.Dom = { /** * Returns an HTMLElement reference. * @method get * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements. * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements. */ get: function(el) { if (!el) { return null; }  if (typeof el != 'string' && !(el instanceof Array) ) { logger.log('get(' + el + ') returning ' + el, 'info', 'Dom'); return el; }  if (typeof el == 'string') { logger.log('get("' + el + '") returning ' + document.getElementById(el), 'info', 'Dom'); return document.getElementById(el); } else { var collection = []; for (var i = 0, len = el.length; i < len; ++i) { collection[collection.length] = Y.Dom.get(el[i]); }  logger.log('get("' + el + '") returning ' + collection, 'info', 'Dom'); return collection; }  logger.log('element ' + el + ' not found', 'error', 'Dom'); return null; },  /** * Normalizes currentStyle and ComputedStyle. * @method getStyle * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. * @param {String} property The style property whose value is returned. * @return {String | Array} The current value of the style property for the element(s). */ getStyle: function(el, property) { property = toCamel(property);  var f = function(element) { return getStyle(element, property); };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Wrapper for setting style properties of HTMLElements.  Normalizes "opacity" across modern browsers. * @method setStyle * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. * @param {String} property The style property to be set. * @param {String} val The value to apply to the given property. */ setStyle: function(el, property, val) { property = toCamel(property);  var f = function(element) { setStyle(element, property, val); logger.log('setStyle setting ' + property + ' to ' + val, 'info', 'Dom');  };  Y.Dom.batch(el, f, Y.Dom, true); },  /** * Gets the current position of an element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method getXY * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements * @return {Array} The XY position of the element(s) */ getXY: function(el) { var f = function(el) {   if (el.parentNode === null || el.offsetParent === null || this.getStyle(el, 'display') == 'none') { logger.log('getXY failed: element not available', 'error', 'Dom'); return false; }  var parentNode = null; var pos = []; var box;  if (el.getBoundingClientRect) { box = el.getBoundingClientRect(); var doc = document; if ( !this.inDocument(el) && parent.document != document) { doc = parent.document;  if ( !this.isAncestor(doc.documentElement, el) ) { logger.log('getXY failed: element not available', 'error', 'Dom'); return false; }  }  var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop); var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);  return [box.left + scrollLeft, box.top + scrollTop]; } else { pos = [el.offsetLeft, el.offsetTop]; parentNode = el.offsetParent; if (parentNode != el) { while (parentNode) { pos[0] += parentNode.offsetLeft; pos[1] += parentNode.offsetTop; parentNode = parentNode.offsetParent; } } if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { pos[0] -= document.body.offsetLeft; pos[1] -= document.body.offsetTop; } }  if (el.parentNode) { parentNode = el.parentNode; } else { parentNode = null; }  while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML') { if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { pos[0] -= parentNode.scrollLeft; pos[1] -= parentNode.scrollTop; }  if (parentNode.parentNode) { parentNode = parentNode.parentNode; } else { parentNode = null; } }  logger.log('getXY returning ' + pos, 'info', 'Dom');  return pos; };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Gets the current X position of an element based on page coordinates.  The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method getX * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements * @return {String | Array} The X position of the element(s) */ getX: function(el) { var f = function(el) { return Y.Dom.getXY(el)[0]; };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Gets the current Y position of an element based on page coordinates.  Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method getY * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements * @return {String | Array} The Y position of the element(s) */ getY: function(el) { var f = function(el) { return Y.Dom.getXY(el)[1]; };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Set the position of an html element in page coordinates, regardless of how the element is positioned. * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method setXY * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements * @param {Array} pos Contains X & Y values for new position (coordinates are page-based) * @param {Boolean} noRetry By default we try and set the position a second time if the first fails */ setXY: function(el, pos, noRetry) { var f = function(el) { var style_pos = this.getStyle(el, 'position'); if (style_pos == 'static') { this.setStyle(el, 'position', 'relative'); style_pos = 'relative'; }  var pageXY = this.getXY(el); if (pageXY === false) { logger.log('setXY failed: element not available', 'error', 'Dom'); return false; }  var delta = [ parseInt( this.getStyle(el, 'left'), 10 ), parseInt( this.getStyle(el, 'top'), 10 ) ];  if ( isNaN(delta[0]) ) { delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft; } if ( isNaN(delta[1]) ) { delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop; }  if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; } if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }  if (!noRetry) { var newXY = this.getXY(el);   if ( (pos[0] !== null && newXY[0] != pos[0]) || (pos[1] !== null && newXY[1] != pos[1]) ) { this.setXY(el, pos, true); } }  logger.log('setXY setting position to ' + pos, 'info', 'Dom'); };  Y.Dom.batch(el, f, Y.Dom, true); },  /** * Set the X position of an html element in page coordinates, regardless of how the element is positioned. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method setX * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. * @param {Int} x The value to use as the X coordinate for the element(s). */ setX: function(el, x) { Y.Dom.setXY(el, [x, null]); },  /** * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @method setY * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. * @param {Int} x To use as the Y coordinate for the element(s). */ setY: function(el, y) { Y.Dom.setXY(el, [null, y]); },  /** * Returns the region position of the given element. * The element must be part of the DOM tree to have a region (display:none or elements not appended return false). * @method getRegion * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data. */ getRegion: function(el) { var f = function(el) { var region = new Y.Region.getRegion(el); logger.log('getRegion returning ' + region, 'info', 'Dom'); return region; };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Returns the width of the client (viewport). * @method getClientWidth * @deprecated Now using getViewportWidth.  This interface left intact for back compat. * @return {Int} The width of the viewable area of the page. */ getClientWidth: function() { return Y.Dom.getViewportWidth(); },  /** * Returns the height of the client (viewport). * @method getClientHeight * @deprecated Now using getViewportHeight.  This interface left intact for back compat. * @return {Int} The height of the viewable area of the page. */ getClientHeight: function() { return Y.Dom.getViewportHeight(); },  /** * Returns a array of HTMLElements with the given class. * For optimized performance, include a tag and/or root node when possible. * @method getElementsByClassName * @param {String} className The class name to match against * @param {String} tag (optional) The tag name of the elements being collected * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point * @return {Array} An array of elements that have the given class name */ getElementsByClassName: function(className, tag, root) { var method = function(el) { return Y.Dom.hasClass(el, className); }; return Y.Dom.getElementsBy(method, tag, root); },  /** * Determines whether an HTMLElement has the given className. * @method hasClass * @param {String | HTMLElement | Array} el The element or collection to test * @param {String} className the class name to search for * @return {Boolean | Array} A boolean value or array of boolean values */ hasClass: function(el, className) { var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');  var f = function(el) { logger.log('hasClass returning ' + re.test(el['className']), 'info', 'Dom'); return re.test(el['className']); };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Adds a class name to a given element or collection of elements. * @method addClass * @param {String | HTMLElement | Array} el The element or collection to add the class to * @param {String} className the class name to add to the class attribute */ addClass: function(el, className) { var f = function(el) { if (this.hasClass(el, className)) { return; }  logger.log('addClass adding ' + className, 'info', 'Dom');  el['className'] = [el['className'], className].join(' '); };  Y.Dom.batch(el, f, Y.Dom, true); },  /** * Removes a class name from a given element or collection of elements. * @method removeClass * @param {String | HTMLElement | Array} el The element or collection to remove the class from * @param {String} className the class name to remove from the class attribute */ removeClass: function(el, className) { var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');  var f = function(el) { if (!this.hasClass(el, className)) { return; }  logger.log('removeClass removing ' + className, 'info', 'Dom');  var c = el['className']; el['className'] = c.replace(re, ' '); if ( this.hasClass(el, className) ) { this.removeClass(el, className); }  };  Y.Dom.batch(el, f, Y.Dom, true); },  /** * Replace a class with another class for a given element or collection of elements. * If no oldClassName is present, the newClassName is simply added. * @method replaceClass * @param {String | HTMLElement | Array} el The element or collection to remove the class from * @param {String} oldClassName the class name to be replaced * @param {String} newClassName the class name that will be replacing the old class name */ replaceClass: function(el, oldClassName, newClassName) { if (oldClassName === newClassName) { return false; }  var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');  var f = function(el) { logger.log('replaceClass replacing ' + oldClassName + ' with ' + newClassName, 'info', 'Dom');  if ( !this.hasClass(el, oldClassName) ) { this.addClass(el, newClassName); return; }  el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');  if ( this.hasClass(el, oldClassName) ) { this.replaceClass(el, oldClassName, newClassName); } };  Y.Dom.batch(el, f, Y.Dom, true); },  /** * Generates a unique ID * @method generateId * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present). * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen"). * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element) */ generateId: function(el, prefix) { prefix = prefix || 'yui-gen'; el = el || {};  var f = function(el) { if (el) { el = Y.Dom.get(el); } else { el = {}; }  if (!el.id) { el.id = prefix + id_counter++; logger.log('generateId generating ' + el.id, 'info', 'Dom'); }  logger.log('generateId returning ' + el.id, 'info', 'Dom');  return el.id; };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy. * @method isAncestor * @param {String | HTMLElement} haystack The possible ancestor * @param {String | HTMLElement} needle The possible descendent * @return {Boolean} Whether or not the haystack is an ancestor of needle */ isAncestor: function(haystack, needle) { haystack = Y.Dom.get(haystack); if (!haystack || !needle) { return false; }  var f = function(needle) { if (haystack.contains && !isSafari) { logger.log('isAncestor returning ' + haystack.contains(needle), 'info', 'Dom'); return haystack.contains(needle); } else if ( haystack.compareDocumentPosition ) { logger.log('isAncestor returning ' + !!(haystack.compareDocumentPosition(needle) & 16), 'info', 'Dom'); return !!(haystack.compareDocumentPosition(needle) & 16); } else { var parent = needle.parentNode;  while (parent) { if (parent == haystack) { logger.log('isAncestor returning true', 'info', 'Dom'); return true; } else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') { logger.log('isAncestor returning false', 'info', 'Dom'); return false; }  parent = parent.parentNode; } logger.log('isAncestor returning false', 'info', 'Dom'); return false; } };  return Y.Dom.batch(needle, f, Y.Dom, true); },  /** * Determines whether an HTMLElement is present in the current document. * @method inDocument * @param {String | HTMLElement} el The element to search for * @return {Boolean} Whether or not the element is present in the current document */ inDocument: function(el) { var f = function(el) { return this.isAncestor(document.documentElement, el); };  return Y.Dom.batch(el, f, Y.Dom, true); },  /** * Returns a array of HTMLElements that pass the test applied by supplied boolean method. * For optimized performance, include a tag and/or root node when possible. * @method getElementsBy * @param {Function} method - A boolean method for testing elements which receives the element as its only argument.  * @param {String} tag (optional) The tag name of the elements being collected * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point */ getElementsBy: function(method, tag, root) { tag = tag || '*';  var nodes = [];  if (root) { root = Y.Dom.get(root); if (!root) { return nodes; } } else { root = document; }  var elements = root.getElementsByTagName(tag);  if ( !elements.length && (tag == '*' && root.all) ) { elements = root.all; }  for (var i = 0, len = elements.length; i < len; ++i) { if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; } }  logger.log('getElementsBy returning ' + nodes, 'info', 'Dom');  return nodes; },  /** * Returns an array of elements that have had the supplied method applied. * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ). * @method batch * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to * @param {Function} method The method to apply to the element(s) * @param {Any} o (optional) An optional arg that is passed to the supplied method * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o" * @return {HTMLElement | Array} The element(s) with the method applied */ batch: function(el, method, o, override) { var id = el; el = Y.Dom.get(el);  var scope = (override) ? o : window;  if (!el || el.tagName || !el.length) { if (!el) { logger.log(id + ' not available', 'error', 'Dom'); return false; } return method.call(scope, el, o); }  var collection = [];  for (var i = 0, len = el.length; i < len; ++i) { if (!el[i]) { id = el[i]; logger.log(id + ' not available', 'error', 'Dom'); } collection[collection.length] = method.call(scope, el[i], o); }  return collection; },  /** * Returns the height of the document. * @method getDocumentHeight * @return {Int} The height of the actual document (which includes the body and its margin). */ getDocumentHeight: function() { var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;  var h = Math.max(scrollHeight, Y.Dom.getViewportHeight()); logger.log('getDocumentHeight returning ' + h, 'info', 'Dom'); return h; },  /** * Returns the width of the document. * @method getDocumentWidth * @return {Int} The width of the actual document (which includes the body and its margin). */ getDocumentWidth: function() { var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth; var w = Math.max(scrollWidth, Y.Dom.getViewportWidth()); logger.log('getDocumentWidth returning ' + w, 'info', 'Dom'); return w; },  /** * Returns the current height of the viewport. * @method getViewportHeight * @return {Int} The height of the viewable area of the page (excludes scrollbars). */ getViewportHeight: function() { var height = self.innerHeight; var mode = document.compatMode;  if ( (mode || isIE) && !isOpera ) { height = (mode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight; }  logger.log('getViewportHeight returning ' + height, 'info', 'Dom'); return height; },  /** * Returns the current width of the viewport. * @method getViewportWidth * @return {Int} The width of the viewable area of the page (excludes scrollbars). */  getViewportWidth: function() { var width = self.innerWidth; var mode = document.compatMode;  if (mode || isIE) { width = (mode == 'CSS1Compat') ? document.documentElement.clientWidth : document.body.clientWidth; } logger.log('getViewportWidth returning ' + width, 'info', 'Dom'); return width; } }; })(); 
context:                   windowHeight = [document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a, b){return(a-b);})[1];
meta: 4707	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/4707/50c3492c4c3c825dbd3401e134a19ed46799c456/dom-debug.js/buggy/www/resources/yui/dom/dom-debug.js