/*---------------------------------------------------------------------- 
	Namespace: u.element
----------------------------------------------------------------------*/
adobe.u.element = {
/*---------------------------------------------------------------------- 
	Function: create
	Create an element in the domain of another element
	
	Parameters:
	element - node
	name - nodename as string
	attrs(optional) - hash of attributes
	
	Returned Value:
	New Node instance
----------------------------------------------------------------------*/
	create: function(element, name, attrs) {
		var e = Element.getDocument(element).createElement(name);
		return (attrs) ? Object.extend(e, attrs||{}) : e;
	},
/*---------------------------------------------------------------------- 
	Function: getDocument
	Get the owner document with cross-browser support
	
	Parameters:
	element - node
	
	Returned Value:
	Document node
----------------------------------------------------------------------*/
	getDocument: function(element) {
		return element.ownerDocument || element.document;
	},
/*---------------------------------------------------------------------- 
	Function: getParent
	Get the parent node with cross-browser support
	
	Parameters:
	element - node
	
	Returned Value:
	Document node
----------------------------------------------------------------------*/
	getParent: function(element) {
		return (document.body.parentElement) ? element.parentElement : element.parentNode;
	},
/*---------------------------------------------------------------------- 
	Function: getParent
	Get the parent node with cross-browser support
	
	Parameters:
	element - node
	replacement - node
	
	Returned Value:
	Element argument
----------------------------------------------------------------------*/
	swap: function(element, replacement) {
		replacement.parentNode.replaceChild(element.parentNode.replaceChild(replacement, element));
		return element;
	},
/*---------------------------------------------------------------------- 
	Function: getMaxChildHeight
	Get the maximum height of this elements children or of a selection of descendants
	
	Parameters:
	element - node
	selector - string
	
	Returned Value:
	Number
----------------------------------------------------------------------*/
	getMaxChildHeight: function(element, selector) {
		var elements = (selector) ? 
				element.select(selector) : 
				element.childElements();
		
		return elements.inject(0, function(accum, element) {
      			return accum = Math.max(accum, element.scrollHeight)
		});
	},
/*---------------------------------------------------------------------- 
	Function: getTextContent
	Get the textContent property with cross-browser support
	
	Parameters:
	element - node
	
	Returned Value:
	String
----------------------------------------------------------------------*/
	getTextContent: function(element) {
		return element.textContent || element.text || element.innerText || "";
	}
}

Element.addMethods(adobe.u.element);