//Creator: Bill Martin
//Email: sscripts@simple-scripts.net
//This script can be modified or used as is,
//but the creator's name and email must stay intact.

function rot13(s) {
  var alph="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
      encrypted='', chr='';    

  for(j=0; j< s.length; j++) {
      chr = s.substr(j,1).match(/[^a-zA-Z]/) ? s.substr(j,1) : '';
      
      if (chr)
          encrypted +=chr;
      
      if (!chr) {     
          for(i=0; i<alph.length; i++) {
              chr = s.substr(j,1) != alph.substr(i,1) ? '' : i<13 ? alph.substr((i+13)%alph.length, 1) 
                                                           : i>12&&i<26 ? alph.substr((i+39)%alph.length, 1) 
                                                           : i>25&&i<39 ? alph.substr((i+65)%alph.length,1) 
                                                           : alph.substr((i+91)%alph.length, 1);           
              if (chr)          
                  encrypted += chr;
          }
      }
  }
  return encrypted;
}
