/*
unobtrusive safemail script - by Jonne
usage: <span class="email">example (at) example.com</span>
*/
/* this part might be redundant, depending on your other scripts */
if(typeof addLoadEvent != 'function'){
	function addLoadEvent(func)
	{	
		var oldonload = window.onload;
		if (typeof window.onload != 'function'){
	    	window.onload = func;
		} else {
			window.onload = function(){
				oldonload();
				func();
			}
		}
	}
}
addLoadEvent(makeMailLinks);
function makeMailLinks()
	{
	if (!document.getElementsByTagName && !document.createElement && !document.createTextNode)
		return;
	var spans = document.getElementsByTagName("span");
	for(var i=0;i<spans.length;i++)
		{
		if (spans[i].className=="email")
			{
			var theNode = spans[i];
			var theAddress = theNode.firstChild.nodeValue;
			theAddress = theAddress.replace(/ \(at\) /, "@");
			theAddressNode = document.createElement('A');
			theAddressNode.setAttribute("href", "mailto:" + theAddress);
			theAddressNode.appendChild(document.createTextNode(theAddress));
			theNode.parentNode.replaceChild(theAddressNode, theNode);
			i--; /*because we implicitly removed a <span> from the spans array by making it an <a>; Otherwise it'll skip the next span*/
			}
		}
	}