function replaceText(el, text) {
	if (el != null) {
		clearText(el);
		var newNode = document.createTextNode(text);
		el.appendChild(newNode);
	}
}

function clearText(el) {
	if (el != null) {
		if (el.childNodes) {
			childLength = el.childNodes.length;
			for (var i = 0; i < childLength; i++) {
				el.removeChild(el.firstChild);
			}
		}
	}
}

function getText(el) {
	var text = "";
	if (el != null) {
		if (el.childNodes) {
			for (var i = 0; i < el.childNodes.length; i++) {
				var childNode = el.childNodes[i];
				if (childNode.nodeValue != null) {
					text = text + childNode.nodeValue;
				}
			}
		}
	}
	return text;
}

function RTrim(str) {
	while(str.charAt((str.length -1))==" "){
		str = str.substring(0,str.length-1);
	}
	return str;
}

function LTrim(str){
	while(str.charAt(0)==" "){
		str = str.replace(str.charAt(0),"");
	}
	return str;
}

function Trim(str){
	str = LTrim(str);
	return RTrim(str);
}

function addLoadEvent(func) {
   var oldonload = window.onload;
   if (typeof window.onload != 'function') {
       window.onload = func;
   }
   else {
       window.onload = function() {
           oldonload();
           func();
       }
   }
}
