function cleanHumbugLink(id) {
	var elLink = document.getElementById(id);
	elLink.href = cleanHumbugString(elLink.href);
}

function cleanHumbugSpan(id) {
	var elSpan = document.getElementById(id);
	replaceText(elSpan, cleanHumbugString(elSpan.firstChild.data));	
}

function cleanHumbugString(strSource) {
	return strSource.replace('|humbug|', '@').replace(/^humbug:\/\//, 'mailto:').replace(/\/$/, '');
}

// small helper to replace first child in 'element' with text in 'text' 
function replaceText(element, text) {
	var newText = document.createTextNode(text);
	if (element.childNodes.length > 0) {
		element.replaceChild(newText, element.childNodes[0]);
	} else {
		element.appendChild(newText);
	}
}
