function DOMUtil() {
}

DOMUtil.prototype.getElementsByTagName = function(tagName, root) {
	return (root || document).getElementsByTagName(tagName) ;
}

DOMUtil.prototype.getAncestorByClassName = function(element, className) {
	while(true) {
		var parent = element.parentNode ;
		if(parent && parent.className == className) return parent ;
	}
	return null ;
}

DOMUtil.prototype.getDescendantsByClassName = function(root, tagName, className) {
	var descendants = this.getElementsByTagName(tagName, root) ;
	var list = new Array() ;
	if(descendants && (descendants.length > 0)) {
		for( var i = 0; i < descendants.length; i++) {
			var child = descendants[i] ;
			if(child.className == className) {
				list.push(child) ;
			} else {
				if(child.className.indexOf(" ") >= 0) {
					var childName = child.className.split(" ") ;
					for( var j = 0; j < childName.length; j++) {
						if(childName[j] == className) list.push(child) ;
					}
				}
			}
		}
	}
	if(list.length > 0) return list ;
	return null ;
}

DOMUtil = new DOMUtil() ;
