/*
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, the second part of domain
emailAddress[0] = "walter,Contact Walter,wwilliams,williamsonline,com";
emailAddress[1] = "neil,Contact Neil,nstockbridge,williamsonline,com";
emailAddress[2] = "frank,Contact Frank,fwilliams,williamsonline,com";
emailAddress[3] = "geoff,Contact Geoffery,gmcclung,williamsonline,com";
emailAddress[4] = "tonia,Contact Tonia,twilliams,williamsonline,com";
emailAddress[5] = "julie,Contact Julie,jlangone,williamsonline,com";
emailAddress[6] = "kim,Contact Kimberly,kforsythe,williamsonline,com";
emailAddress[7] = "lynda,Contact Lynda,lcox,williamsonline,com";
emailAddress[8] = "steved,Contact Steve,sdorney,williamsonline,com";
emailAddress[9] = "steves,Contact Steve,ssasenick,williamsonline,com";
emailAddress[10] = "elizabeth,Contact Elizabeth,ecromack,williamsonline,com";


//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++) {
		//slit 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);
