/*

Author: Anthony Ettinger
Contact: anthony at chovy dot com
Blog: http://chovy.com

LICENSE: Re-distribution is strictly prohibited unless express written consent has been given by the author and copyright holder. No warranty, implied or otherwise is given with this software. This software is provided "as is" - use at your own risk. No gaurantee is made of any kind as to the effects of using this software which may or may not occur. By using this software you agree to release the author and copyright holder of any liability what-so-ever resulting directly, or indirectly as a use of this software.

*/

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;
