// flippify - ben alman, paul irish, et al
// $('body').flippify();
(function($){
var charset = {a:"\u0250",b:"q",c:"\u0254",d:"p",e:"\u01DD",f:"\u025F",g:"\u0183",h:"\u0265",i:"\u0131",j:"\u027E",k:"\u029E",l:"l",m:"\u026F",n:"u",o:"o",p:"d",q:"b",r:"\u0279",s:"s",t:"\u0287",u:"n",v:"\u028C",w:"\u028D",y:"\u028E",z:"z",1:"\u21C2",2:"\u1105",3:"\u1110",4:"\u3123",5:"\u078E" /* or u03DB */ ,6:"9",7:"\u3125",8:"8",9:"6",0:"0",".":"\u02D9",",":"'","'":",",'"':",,","´":",","`":",",";":"\u061B","!":"\u00A1","\u00A1":"!","?":"\u00BF","\u00BF":"?","[":"]","]":"[","(":")",")":"(","{":"}","}":"{","<":">",">":"<",_:"\u203E","\r":"\n"};
function flipStr(str) {
return $.map(str, function(v,i){
return charset[v] || v;
}).reverse().join('');
};
function withTextNodes(node, callback) {
var childNodes = node.childNodes,
i = childNodes.length;
while (--i >= 0) {
node = childNodes[i];
if ( node.nodeType === 3 ) {
callback( node );
} else if ( node.nodeType === 1 ) {
arguments.callee( node, callback );
}
node.parentNode.appendChild( node.parentNode.removeChild( node ) );
}
}
$.fn.flippify = function(){
withTextNodes( this.get(0), function(node){
node.nodeValue = flipStr( node.nodeValue );
});
return this;
};
})(jQuery);