(function(){
	YAHOO.lang.augmentObject(YAHOO.util.Dom, {
		getFirstMatchingElement: function(types, root, tagName){
			if (tagName === undefined) tagName='*';
			if (root===undefined) root=document;

			for (var i in types){ 
				var type = types[i];
				var possible = null;

				if (type.charAt(0)=='.'){
					possible = YAHOO.util.Dom.getElementsByClassName(type.substring(1), tagName, root);
				}
				else {
					possible = root.getElementsByTagName(type);
				}

				if (possible && possible.length > 0){
					return possible[0];
				}
			}

			return null;
		}
	});
})();
