/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* This tool will allow you to limit email crawling on your website.
* Author: Keegan Rowe
* Version: 1.3
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

//run when the DOM is ready
$(document).ready(function() {
	//check each span element with a mailto class
	$("span.mailto").each(function(){
		//retrieve the email address from the inner part of the span element
		var addr = $(this).text().replace(/ at /,"@").replace(/ dot /g,".");

		//retrieve the link text from the title attribute of the span element if it exists, otherwise just use the email address
		var link = ($(this).attr('title') == "") ? addr : $(this).attr('title');

		//write out a standard anchor link element using the email address and the title to the DOM
		$(this).after('<a href="mailto:'+addr+'">'+ link + '</a>');

		//remove the original span element from the DOM
		$(this).remove();
	});
});