if (document.getElementById && document.getElementsByTagName)
{	window.onload = initialise;
}

function initialise()
{	addressMaker();
}

function addressMaker()
{	var addrs = document.getElementsByTagName("span");
	for (var i = 0; i < addrs.length; i++)
	{	if (addrs[i].className == "addr")
		{	
			/*	there will be two or three parts; id, place and name */
			var id, place;
			var name = "";
			for (var j = 0; j < addrs[i].childNodes.length; j++)
			{	var p = addrs[i].childNodes[j];
				/* if p is a span, get the class and the contents */
				if (p.nodeName == 'SPAN')
				{	if (p.className == "id")
					{	id = p.firstChild.data;
					}
					else if (p.className == "place")
					{	place = p.firstChild.data;
					}
					else if (p.className == "name")
					{	name = p.firstChild.data;
					}
				}
			}
			if (id != "" && place != "")
			{	/* do the replacement */
				while (addrs[i].childNodes.length > 0)
				{	addrs[i].removeChild(addrs[i].childNodes[0]);
				}
				var link = document.createElement('a');
				link.href = "mailto:" + id + "@" + place;
				
				var txt;
				if (name.length != 0)
				{	txt = document.createTextNode(name);
					link.title = name;
				}
				else
				{	txt = document.createTextNode(id + "@" + place);
					link.title = id + "@" + place;
				}
				link.appendChild(txt);
				addrs[i].appendChild(link);
			}
		}
	}
}

