/* funzioni per manipolazione DOM - rev. 20071121 */

function emptyElement(el)
{
	while (el.firstChild) {
		el.removeChild(el.firstChild);
	}
}

function appendText(father, text)
{
	if (father && text) {
		father.appendChild(document.createTextNode(text));
	}
}

function appendElement(father, tag, id)
{
	var newel;
	if (father && tag) {
		newel = document.createElement(tag);
		if (newel) {
			if (id && !document.getElementById('id')) {
				newel.setAttribute('id', id);
			}
			father.appendChild(newel);
		}
		return newel;

	} else {
		return false;
	}
}

function appendSimpleDiv(father, id)
{
	return appendElement(father, 'div', id);
}

function appendSimpleSpan(father, id)
{
	return appendElement(father, 'span', id);
}

function appendSimpleLink(father, dest, id)
{
	newlink = appendElement(father, 'a', id);
	if (newlink) {
		newlink.setAttribute('href', dest);
	}
	return newlink;
}

