var DOMUtils = {
	moduleName: "DOMUtils",
	moduleVersion: "0.1-beta",
	toString: function() {
		return this.moduleName + ' ' + this.moduleVersion;
	},
	// Taken from MDC : http://developer.mozilla.org/fr/docs/Gestion_des_espaces_dans_le_DOM
	// get the next sibling of an element in the DOM Tree, avoiding ignorable nodes
	getNextSibling: function(oCurrentElement) {
		while (oCurrentElement = oCurrentElement.nextSibling) {
			if(!this.isIgnorableNode(oCurrentElement)) {
				return oCurrentElement;
			}
		}
		
		return null;
	},
	// get the previous sibling of an element in the DOM Tree, avoiding ignorable nodes
	getPreviousSibling: function(oCurrentElement) {
		while (oCurrentElement = oCurrentElement.previousSibling) {
			if(!this.isIgnorableNode(oCurrentElement)) {
				return oCurrentElement;
			}
		}
		
		return null;
	},
	
	// get the last child of an element in the DOM Tree, avoiding ignorable nodes
	getLastChild: function(oCurrentElement) {
		var oLastElement = oCurrentElement.lastChild;
		do  {
			if(!this.isIgnorableNode(oLastElement)) {
				return oLastElement;
			}
		} while(oLastElement = oLastElement.previousSibling);
		
		return null;
	},
	
	// get the first child of an element in the DOM Tree, avoiding ignorable nodes
	getFirstChild: function(oCurrentElement) {
		var oFirstElement = oCurrentElement.firstChild;
		do {
			if(!this.isIgnorableNode(oFirstElement)) {
				return oFirstElement;
			}
		} while (oFirstElement = oFirstElement.nextSibling);
		
		return null;
	},
	
	// test if a node is all white space (including non-breakable spaces)
	isAllWS: function (oNode) {
		return !(/[^\t\n\r]/.test(oNode.data));
	},
	// test if a node is ignorable. An ignorable node is a all WS node
	isIgnorableNode: function(oNode) {
		return (oNode.nodeType == 8 || (oNode.nodeType == 3 && this.isAllWS(oNode)));
	}
};