// Copyright Andrew Urquhart 2003-04-04
// Permission granted to use this script at your own risk, with no warranty or support provided that this copyright and disclaimer remains in place. I will not be responsible for consequences arising from the use of this code.

function doRot13() {
	var aCode = 'a'.charCodeAt(); var zCode = 'z'.charCodeAt(); var ACode = 'A'.charCodeAt(); var ZCode = 'Z'.charCodeAt();
	var f = document.forms['rot13form'].elements['rot13Box'];
	var rot13Box = f.value;
	var rot13 = "";
	for (var i=0; i<rot13Box.length; ++i) {
		var uniVal = rot13Box.charCodeAt(i);
		if ((uniVal >= aCode) && (uniVal <= zCode)) rot13 += String.fromCharCode(((uniVal - aCode + 13) % 26) + aCode);
		else if ((uniVal >= ACode) && (uniVal <= ZCode)) rot13 += String.fromCharCode(((uniVal - ACode + 13) % 26) + ACode);
		else rot13 += rot13Box.charAt(i);
	}
	f.value = rot13;
	return false;
}

function doPerformExample(exampleText) {
	var d = document.forms['rot13form'];
	d.elements['rot13Box'].value = exampleText;
	alert("Example: Before ...")
	doRot13();
	alert("Example: After ...")
	return false;
}

