/* ROT13 Decryption Function ([...]/httpdocs/resources/contact.js)
 *
 * DESCRIPTION:
 * The function in this file reverses the simple cipher used to "hide" captcha
 * text from automated processes in my contact form. It is effective only for
 * cursory attacks, or spiders that crawl the web looking for completely
 * unprotected forms.
 *
 * AUTHOR:
 * The Confessor <http://confessor.org/contact.php>
 *
 * COPYRIGHT:
 * 2007-2010 The Confessor
 *
 * LICENSE:
 * Use of all or portions of my website source code in your own projects is
 * subject to the terms and conditions listed here:
 * <http://confessor.org/termsofuse.php>
 *
 */

function rot13decrypt() {
  var span = document.getElementById('contactformcaptcha');

  var captchatext = span.firstChild.innerHTML;
  var len = captchatext.length;
  var decryptedtext = '';

  if (len > 0) {
    for(var ctr=0; ctr<len ; ctr++) {
      b=captchatext.charCodeAt(ctr);
      if (((b > 64) && ( b < 78)) || ((b > 96) && (b < 110))) {
        b = b + 13;
      }
      else if (((b > 77) && (b < 91)) || ((b > 109) && (b < 123))) {
        b = b - 13;
      }
      decryptedtext = decryptedtext.concat(String.fromCharCode(b));
    }
  }

  span.innerHTML = '<code>'+decryptedtext+'</code>';
}
