window.onload = emailUnobsfuscate;
function emailUnobsfuscate() 
{
	// find all links in HTML
	var subject = 'New Project Inquiry'; // Add a default subject to emails
	var link = document.getElementsByTagName && document.getElementsByTagName("a");
	var email, i;
	
	// examine all links
	for (i = 0; link && i < link.length; i++) {
		// does the link have use a class named "email"
		if ((" "+link[i].className+" ").indexOf(" email ") >= 0) {
			// get the obfuscated email address
			email = link[i].firstChild.nodeValue || "";
			
			// transform into real email address
			email = email.replace(/dot/ig, ".");
			email = email.replace(/\(at\)/ig, "@");
			
			// splits out subject when written after a pipe character.
			var subjectSplit = email.split(' | ');
			email = subjectSplit[0].replace(/\s/g, "").toLowerCase();
			subject = (subjectSplit[1]) ? encodeURI(subjectSplit[1]) : encodeURI(subject);
			
			// is email valid?
			if (/^[^@]+@[a-z0-9]+([_\.\-]{0,1}[a-z0-9]+)*([\.]{1}[a-z0-9]+)+$/.test(email)) {
				// change into a real mailto link
				link[i].href = "mailto:" + email + '?subject=' + subject;
				link[i].firstChild.nodeValue = email;
			}
		}
	}
};
if (window.attachEvent) window.attachEvent("onload", contactHover);
function contactHover() {
	var contact = document.getElementById("contact");
	contact.onmouseover = function() {
		this.className += " hover";
	}
	contact.onmouseout=function() {
		this.className = this.className.replace(" hover", "");
	}
}
