Rot13 = {
    map: null,

    convert: function(a) {
        Rot13.init();

        var s = "";
        for (i=0; i < a.length; i++) {
            var b = a.charAt(i);
            s += ((b>='A' && b<='Z') || (b>='a' && b<='z') ? Rot13.map[b] : b);
        }
        return s;
    },

    init: function() {
        if (Rot13.map != null)
            return;
              
        var map = new Array();
        var s   = "abcdefghijklmnopqrstuvwxyz";

        for (i=0; i<s.length; i++)
            map[s.charAt(i)] = s.charAt((i+13)%26);
        for (i=0; i<s.length; i++)
            map[s.charAt(i).toUpperCase()] = s.charAt((i+13)%26).toUpperCase();

        Rot13.map = map;
    },

    write: function(a) {
        document.write(Rot13.convert(a));
    }
}


$(function() {
	$('a[href^=mailto]').each( function(i) {
		vrai_courriel = '';
		lien = $(this);
		faux_courriel = lien.attr('href');
		faux_courriel = faux_courriel.replace('mailto:', '');
		$ctr=1;
		for (j=0 ; j<faux_courriel.length ; j++) {
			if ($ctr != 4) {
				vrai_courriel += faux_courriel.substr(j,1);
				$ctr++;
			} else {
				$ctr=1;
			}
			
		}
		vrai_courriel = Rot13.convert(vrai_courriel);
		
		if (lien.html() == texte_remplacement_email) {
			lien.html(vrai_courriel);
		}
		
		lien.attr('href', 'mailto:' + vrai_courriel);			
	}) ;	
})
