String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/gi, "");
}

String.prototype.replaceAll = function(str1, str2) { 
	var temp_str = "";
		if (this.trim() != "" && str1 != str2) {
			temp_str = this.trim();
			while (temp_str.indexOf(str1) > -1){
				temp_str = temp_str.replace(str1, str2);
			}
		}
	return temp_str;
}

function replaceHtml(el, text) {
	if (el != null) {
		clearText(el);
		el.innerHTML = text;
	}
}
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) {
			for (var i = 0; i < el.childNodes.length; i++) {
				var childNode = el.childNodes[i];
				el.removeChild(childNode);
			}
		}
	}
}
