function rot13(a)
{
  if (!rot13map)
  {
    rot13map = rot13init();
  }

  var s = "";
  var i;
  var entity = "";
  for (i = 0; i < a.length; i++)
  {
    var b = a.charAt(i);

    if (entity)
    {
      entity += b;

      if (b == ';')
      {
        if (entity == "&lt;")
        {
          s += "<";
        }
        else if (entity == "&gt;")
        {
          s += ">";
        }
        else if (entity == "&amp;")
        {
          s += "&";
        }
        else
        {
          var matches = entity.match(rot13numericEntityRE);

          if (matches[1])
          {
            s+= String.fromCharCode(matches[1]);
          }
        }

        entity = "";
      }
    }
    else if (b == '&')
    {
      entity = "&";
    }
    else 
    {
      s += (b >= 'A' && b <= 'Z' || b >= 'a' && b <= 'z' ? rot13map[b] : b);
    }
  }

  return s;
}

rot13map = null;
rot13numericEntityRE = /&#(.*);/;

function rot13init()
{
  var map = new Array();
  var s   = "abcdefghijklmnopqrstuvwxyz";

  var i;
  for (i = 0; i < s.length; i++)
  {
    map[s.charAt(i)]               = s.charAt((i + 13) % 26);
  }
  for (i = 0; i < s.length; i++)
  {
    map[s.charAt(i).toUpperCase()] = s.charAt((i + 13) % 26).toUpperCase();
  }

  return map;
}

function decodeEmail( string )
{
    //alert( 'going to send email to: ' + rot13( string ) );
    document.location = 'mailto:' + rot13( string );
}

        

