/*/////////////////////////////////////////////////////////////////////////////

Component:    ROT13 Decryption Function

Description:  The ROT13 decryption function reverses the cipher used to "hide"
              the captcha text from automated processes in my contact form. It
              is effective only for cursory attacks, or spiders that crawl the
              web looking for entirely unprotected forms.

Project:      My Website
                User Interface
                  Contact Application

Path:         [...]/httpdocs/resources/contact.js

Author:       The Confessor <http://confessor.org/contact.php>

Copyright:    (C) 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>';
}