CmdUtils.CreateCommand({
	names: ["rot13"],
	homepage: "http://www.randomloci.com/dev/ubiquity/rot13.php",
	author: { name: "John Tocher", email: "jmtocher@gmail.com"},
	contributors: ["Jeroen van Rijn"],
	license: "MPL",
	description: _("Translates text using the ROT13 algorithm."),
	help: _("Will modify text in place using the ROT13 algorithm."),

 	_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;
 	},
  
 	preview: function( pblock ) {
		pblock.innerHTML = _("A preview of the transformed text will appear here");
		pblock.innerHTML = _("Change text to ["+ this._rot13() + "]");
   
	},
   
 	execute: function() {
		CmdUtils.setSelection( this._rot13() );
  }   
});
