/*
rotator.js
http://www.josephfinsterwald.com

characters are rotated 13 places and numbers are rotated 5 places.

example email = rznvy

In your HTML
<head>
	<script type="text/javascript">
<!--
    $(function() {
    $('#your-id').attr('href', $.rotate13('znvygb:uryyb@fgnaqjnir.pbz')).text(
        $.rotate13('RZNVY'));
    });
// -->
</script>
</head>

<body>
	<a id="your-id"></a><noscript><i>You need javascript to see this link</i></noscript>
</body>

*/

(function($) {
    $.rotate = function(s) {
        return $.rotate13($.rotate5(s));
    }

    $.rotate5 = function(s) {
        var b = [],c,i = s.length,a = '0'.charCodeAt(),z = a + 10;
        while (i--) { 
            c = s.charCodeAt(i);
            if (c >= a && c < z) { b[i] = String.fromCharCode(((c - a + 5) % (10)) + a); }
            else { b[i] = s.charAt(i); }
        }
        return b.join('');
    };

    $.rotate13 = function(s) {
        var b = [],c,i = s.length,a = 'a'.charCodeAt(),z = a + 26,A = 'A'.charCodeAt(),Z = A + 26;
        while (i--) {
            c = s.charCodeAt(i);
            if (c >= a && c < z) { b[i] = String.fromCharCode(((c - a + 13) % (26)) + a); }
            else if (c >= A && c < Z) { b[i] = String.fromCharCode(((c - A + 13) % (26)) + A); }
            else { b[i] = s.charAt(i); }
        }
        return b.join('');
    };
})(jQuery)
