/*
EMAIL SPAMBOT BUSTER
BY DENNIS LEMBREE, NOV 2007
www.DennisLembree.com
www.CheckEngineUSA.com
http://www.checkengineusa.com/ce/articles/spambot_buster.htm

Example implementation:

<script type="text/javascript">
var emailAddress = new Array();
emailAddress[0] = "infoDiv,contact us today,info,yourDomain,com";
</script>
<script src="email_spambot_buster.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = spambotBuster;
</script>
*/

//create array
var emailAddress = new Array();

//set the parameters for email(s) on page
//values: ID of the span, text to be hyperlinked, recipient, first part of domain, second part of domain
emailAddress[0] = "addy,craig.warkentin@oswego.edu,craig.warkentin,oswego,edu";

//main Email Spambot Buster function
function spambotBuster() {
	//ensure user agent can do DOM
	if(!document.getElementById || !document.createElement) return;

	//loop through email addresses
	for (var i=0;i<emailAddress.length;i++) {
		//split value of current array into new array
		x = emailAddress[i].split(',');
		
		//grab the email span element
		el = document.getElementById(x[0]);
		
		//create the actual link
		theLink = "mailto:" + x[2] + "@" + x[3] + "." + x[4];
		
		//build node for email link
		emailLink = document.createElement("a");
		emailLink.appendChild(document.createTextNode(x[1]));
		emailLink.href = theLink;
		emailLink.title = "email link";
		emailLink.rel = "email";
		
		//replace it!
		el.parentNode.replaceChild(emailLink,el)
	}
}

//the awesome addLoad Event function by Simon Willison
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

//call Buster function on page load
addLoadEvent(spambotBuster);
