
/**
 * this function replaces the mailto links which have the form (href tag):
 * nospam:account__AT__sub__DOT__domain__DOT__tld
 * and the id: nospam_X
 * where X is a number (starting from 1 and continous)
 * innerHTML will be set to the email address 
 */
function antiSpam() {
    var i = 0,
        a = null,
        old = '',
        newHref = '';
    while (true) {
        i += 1;
        a = document.getElementById('nospam_' + i);
        if (!a) {
            return;
        }
        // replace link's href attribute
        old = a.href;
        newHref = old.replace('nospam:', '');
        newHref = newHref.replace(/__AT__/, '@');
        newHref = newHref.replace(/__DOT__/g, '.'); // g --> replace all occurances
        a.href = 'mailto:' + newHref;
        a.innerHTML = newHref;
    }
}

// make the function run when the page is loaded
if (window.addEventListener) {
    window.addEventListener("load", antiSpam, false);
} else {
    if (window.attachEvent) {
        window.attachEvent("onload", antiSpam);
    } else {
        // try to run now
        antiSpam();
    }
}


