function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload(); func();
		}
	}
}

function removeChildren(node) {
	while(node.hasChildNodes()) {
		node.removeChild(node.firstChild);
	}
}

function addText(node, str) {
	node.appendChild(document.createTextNode(str));
	return node.lastChild;
}

function addClassText(node, str, cls) {
	var sp = document.createElement('span');
	sp.setAttribute('class', cls);
	sp.appendChild(document.createTextNode(str));
	node.appendChild(sp);
	return node.lastChild;
}

function addLink(node, adr, str) {
	a = document.createElement('a');
	a.setAttribute('href', adr);
	addText(a, str);
	node.appendChild(a);
}
