/*
dom.js
DOM Functions (Generic)
*/

var W3CDOM = (document.createElement && document.getElementsByTagName);

// Attach functions to window.onload event
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// Finds and returns first TEXT_NODE, even if within another ELEMENT_NODE (recursive)
function findTextNode(elem) {
	//alert(elem.nodeType);
	// Works, but is it quite correct in [ALL] situations?
	if (elem.nodeType != 3) {
	  if (elem.hasChildNodes) { 
			return findTextNode(elem.firstChild);
		}
	} else {
		// TEXT_NODE
		return elem;
	}
}
