function DomUtil(){}

DomUtil.getChildNodesOfType = function(parent,type){
	filteredChildren = new Array();
	if (parent) {
		var children = parent.childNodes;
		for (var i=0;i<children.length;i++) {
			if(children[i].nodeName.toLowerCase() == type.toLowerCase()) {
				filteredChildren.push(children[i]);
			}
		}
	}
	return filteredChildren;
}

/**returns the first parent node whose nodeName matches type.  stops when it gets to the body element.  returns null if it's not found*/
DomUtil.getParentNodeOfType = function(current,type){
	current = current.parentNode;
	while (current.nodeName.toLowerCase() != type.toLowerCase() && current.nodeName.toLowerCase() != "body") {
		current = current.parentNode;
	}
	if (current.nodeName.toLowerCase() != type.toLowerCase()) {
		current = null;
	}
	return current;
}

/**returns the first parent node that is not a text node.  returns null if it's not found*/
DomUtil.getNonTextParentNode = function(current){
	current = current.parentNode;
	while (current.nodeName.toLowerCase() == "#text" && current.nodeName.toLowerCase() != "body") {
		current = current.parentNode;
	}
	if (current.nodeName.toLowerCase() == "#text") {
		current = null;
	}
	return current;
}

/**returns the next sibling node whose nodeName matches type.  stops when it runs out of siblings.  returns null if it's not found*/
DomUtil.getNextSiblingNodesOfType = function(current,type){
	current = current.nextSibling;
	while (current && current.nodeName.toLowerCase() != type.toLowerCase()) {
		current = current.nextSibling;
	}
	return current;
}

/** returns a the position of the given element.  the returned value has .x and .y members */
DomUtil.getRealPosition = function(el){
	var position = new Object();
	var x=el.offsetLeft;
	var y=el.offsetTop;
	var parent=el.offsetParent;
	while(parent){
		x+=parent.offsetLeft;
		y+=parent.offsetTop;
		parent=parent.offsetParent;
	}
	position.x = x;
	position.y = y;
	return position;
}
