function EmailUnobsfuscate() {
	
	// find all links in HTML
	var link = document.getElementsByTagName && document.getElementsByTagName("a");
	var obf, e;
	
	// examine all links
	for (e = 0; link && e < link.length; e++) {
	
		// does the link have a class named "obf"
		if ((" "+link[e].className+" ").indexOf(" obf ") >= 0) {
		
			// get the obfuscated email address
			obf = link[e].firstChild.nodeValue.toLowerCase() || "";
			
			// transform into real email address
			obf = obf.replace(/&#46;/ig, ".");
			obf = obf.replace(/-dot-/ig, ".");
			obf = obf.replace(/\[dot\]/ig, ".");
			obf = obf.replace(/-at-/ig, "@");
			obf = obf.replace(/\[at\]/ig, "@");
			obf = obf.replace(/\s/g, "");
			
			// is email valid?
			if (/^[^@]+@[a-z0-9]+([_\.\-]{0,1}[a-z0-9]+)*([\.]{1}[a-z0-9]+)+$/.test(obf)) {
			
				// change into a real mailto link
				link[e].href = "mailto:" + obf;
				link[e].firstChild.nodeValue = obf;
		
			}
		}
	}
}
window.onload = EmailUnobsfuscate; 


/*
An explanation of the code:

   1. Line 4 fetches every <a> link in our HTML page and line 8 loops through them.
   2. Line 11 checks the link for a class of “obf”.
   3. Line 14 grabs the obfuscated email from the text content of the node.
   4. Lines 17 to 22 transform it to a real email address using regular expressions: “dot” is changed to a “.”, “(at)” is changed to “@”, and all spaces are removed.
   5. Line 25 checks the resulting email address is valid.
   6. Lines 28 and 29 then modify the DOM node and make it into a real “mailto:” link.

Finally, we need to ensure the function runs on page load by adding a line to the bottom of email.js
*/
	
