
/*
	usage:	
	<span class="buildMail"> xxx at yyy dot net</span>
*/

function w_buildMail()
{
	if (!document.getElementsByTagName && !document.createElement && !document.createTextNode) return;
	
	var nodes = document.getElementsByTagName("span");
	
	for(var i = nodes.length-1; i >= 0; i--)
	{
		if (nodes[i].className == "buildMail")
		{
			var at = / at /;
			var dot = / dot /g;
			var node = document.createElement("a");
			var address = nodes[i].firstChild.nodeValue;
			
			address = address.replace(at, "@");
			address = address.replace(dot, ".");
			
			node.setAttribute("href", "mailto:" + address);
			node.appendChild(document.createTextNode(address));
			
			var prnt = nodes[i].parentNode;
			for(var j=0; j < prnt.childNodes.length; j++)
			{
				if (prnt.childNodes[j] == nodes[i])
				{
					if(!prnt.replaceChild) return;
					prnt.replaceChild(node, prnt.childNodes[j]);
					break;
				}
			}
		}
	}
}
