// Spam-proof email decryptor script
// Created by Kevin Patz, March 2003

// Encrypted email address goes here
// If you need more than one address, define additional variables
var addr1 = "2067151416,992028460,657865248,809186864,655697445,874914096,573585208";

function decryptEmail(address)
{
  var work = address;
  var result = "";
  var errcount = 10;
  while(work.length > 0)
  {
    errcount--;
    if (errcount == 0) return "Whoops!";
    var i = work.indexOf(",");
    var workNum;
    if (i > -1)
    {
      workNum = work.substring(0, i);
      work = work.substring(i + 1);
    }
    else
    {
      workNum = work;
      work = "";
    }
    errcount = 10;
    while (workNum > 0)
    {
      errcount--;
      if (errcount == 0) return "Whoops loop 2";
      var charValue = (workNum ^ 85) & 255;
      workNum >>>= 8;
      result = String.fromCharCode(charValue) + result;
    }
  }
  return result;
}

function decryptEmailHTML(address)
{
  var work = address;
  var result = "";
  var errcount = 10;
  while(work.length > 0)
  {
    errcount--;
    if (errcount == 0) return "Whoops!";
    var i = work.indexOf(",");
    var workNum;
    if (i > -1)
    {
      workNum = work.substring(0, i);
      work = work.substring(i + 1);
    }
    else
    {
      workNum = work;
      work = "";
    }
    errcount = 10;
    while (workNum > 0)
    {
      errcount--;
      if (errcount == 0) return "Whoops loop 2";
      var charValue = (workNum ^ 85) & 255;
      workNum >>>= 8;
      result = "&#" + charValue + ";" + result;
    }
  }
  return result;
}

function writeEmailLink(sEncryptedEmail, sLinkText)
{
  if (sLinkText == "") sLinkText = decryptEmailHTML(sEncryptedEmail);
  document.write("<A HREF='mailto:" + decryptEmail(sEncryptedEmail) + "'>" + sLinkText + "</A>");
}

