
CmdUtils.CreateCommand({
  name: "rot13",
  _rot13: function() {
    var oldMsg = CmdUtils.getSelection();
    var newMsg = "";
    var charCode = 0;
    for (i = 0; i < oldMsg.length; i++)
    {
      charCode=oldMsg.charCodeAt(i);
      if ( (charCode>64) && (charCode<91) )  // Upper case
        charCode = 65 + ( (charCode-52) % 26 );
      if ( (charCode>96) && (charCode<123) ) // Lower case
        charCode = 97 +  ( (charCode-84) % 26 );
      newMsg = newMsg + String.fromCharCode(charCode);
    }
    return newMsg;
  },
  homepage: "http://www.randomloci.com/dev/ubiquity/rot13.php",
  author: { name: "John Tocher", email: "jmtocher@gmail.com"},
  license: "MPL",
  description: "Tranlates text using the ROT13 (debug2) algorithm.",
  help: "If you've got a block of txt selected, it will be ROT13'ed in place.",
  preview: function( pblock ) {
    pblock.innerHTML = "Translates text using the ROT13 algorithm.";
    pblock.innerHTML = "Translates text using the ROT13 algorithm <hr /> "+  this._rot13();
  },
  takes: {"some text": noun_arb_text},
  execute: function() {
    CmdUtils.setSelection( this._rot13() );
  }
})

