var popupObj = null;

function fixTags()
{
	fixEmail();
//	fixLinks();
}

function fixEmail()
{
	var elem = 'a';
	var attr = 'href'; //element attribute
	var attrTest = /^mailto:/; //regex to test value of attribute
	var replaceStr = '--at--';
	var nodeList = document.getElementsByTagName(elem);

	for (var i=0; i<nodeList.length; i++)
	{
		var item = nodeList[i];
		var itemName = item.nodeName;
		var itemVal = item.textContent ? item.textContent : item.innerText;
		//alert(itemName + itemVal);
		var attrVal = item.getAttribute(attr);
		//alert(attrVal);

		if (attrTest.test(attrVal))
		{
			//alert(attrVal);
			var newVal = attrVal.replace(replaceStr, "@");
			var newContent = itemVal.replace(replaceStr, "@");
			//alert(newContent);
			//alert(newVal);
			item.setAttribute("href", newVal);
			item.textContent ? item.textContent = newContent : item.innerText = newContent;
			item.style.display = 'inline';
		}
	}
}

function fixLinks()
{
	var elem = 'a';
	var attr = 'href';
	var attrTest = /^http:/; //regex to test value of attribute
	var classTest = /^fn url/;
	var nodeList = document.getElementsByTagName(elem);

	for (var i=0; i<nodeList.length; i++)
	{
		var item = nodeList[i];
		var itemName = item.nodeName;
		//alert(itemName + itemVal);
		var attrVal = item.getAttribute(attr);

		if (attrTest.test(attrVal))
		{
			item.onclick=showPopup;
		}

		if (item.getAttribute('class') == 'fn url')
		{
			var classVal = item.getAttribute('class');
			//alert(classVal);
			item.style.display = 'block';
		}
	}

	//clean styles in IE6/win

	
}

function showPopup()
{
	popupObj = window.open(this.href, "popup", "height=600,width=800,menubar=no,toolbar=no,location=yes,directories=no,personalbar=no,status=yes,resizable=yes,scrollbars=yes");
	popupObj.focus();

	return false;
}

window.onload = fixTags;
