
/*
 * Common Javascript code
 */

/* My weak attempt at avoiding spam crawlers */
function unobfuscate_address(user, domain, text) {
    user = rot13(user);
    domain = rot13(domain);
    if (text == undefined)
	text = user + "&#64;" + domain;
    document.write("<a href=\"mai");
    document.write("lto:"+user+"@"+domain+"\">"+text+"</a>");
}

/* Returns a string transformed by a simple 13 shift cipher */
function rot13(s) {
    var ch, t = "";
    for (i = 0; i < s.length; i++) {
	ch = s.charCodeAt(i);
	if (ch > 64 && ch <= 64+26)
	    ch = 65 + ((ch - 65 + 13) % 26);
	else if (ch > 96 && ch <= 96+26)
	    ch = 96 + ((ch - 96 + 13) % 26);
	t = t + String.fromCharCode(ch)
    }
    return t;
}
