/*
----------------------------------------------------------
  
  Copyright 2009 Crusader Ltd
  
  Website: Crusader Ltd
  Author:  Stephen Last
  
----------------------------------------------------------
*/

/* Add load events
----------------------------------------------------------*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

/* Get element by id shortcut
----------------------------------------------------------*/
function $(s) {
	return document.getElementById(s);
}

/* Convert e-mail address (anti-spam)
----------------------------------------------------------*/
function convertEmail() {
	var a = document.getElementsByTagName("a");
	if (a) {
		for (var i=0; i<a.length; i++) {
			var href = a[i].getAttribute("href");
			if (href) {
				if (href.indexOf("mailto:")!=-1) {
					var new_mail = href;
					new_mail = new_mail.replace("--at--","@");
					new_mail = new_mail.replace("--dot--",".");
					new_mail = new_mail.replace("--dot--",".");
					a[i].setAttribute("href",new_mail);
					a[i].childNodes[0].nodeValue = new_mail.replace("mailto:","");
				}
			}
		}
	}
}
addLoadEvent(convertEmail);
