                              hex = '0123456789ABCDEF';

function encode(theForm) {
  //this function creates the hexadecimal equivalent to "document.write('<a href="mailto:emailaddress">name</a>')"
  //ie it effectively encrpts this as far as spam-bots are concerned
  //the Javascript to unencrypt it simply changes the hex back into ascii then executes the code using the 'eval' statement
  //... and ta da ... you've got a normal mailto address displayed in the browser.
  //Written by Jeff Robson of Cynergic Net Solutions www.cynergic.net jeff.robson@cynergic.net
  //You can use the code freely - just don't try to claim it as your own.
  //
  new_text = hex_string('document.write(\'<a href=\"mailto:' + theForm.email.value + '\">' + theForm.name.value + '</a>\')');
  theForm.encoded_txt.value = '<script language=\"JavaScript\">eval(unescape(\'' + new_text + '\'))</script>';
}

function encode_html(theForm) {
  //this function encodes any html string passed to it so you can use it for
  //image maps, images ... or anything else that takes your fancy
  //it works pretty much the same as the one above except that it just encodes the whole string
  re = /\"/g;
  plain_html = theForm.html.value.replace (re, '\\\"');
  encoded_html = hex_string('document.write(\'' + plain_html + '\')');
  theForm.encoded_html.value = '<script language=\"JavaScript\">eval(unescape(\'' + encoded_html + '\'))</script>';
}

function hex_string(mystring) {
  newstring = '';
  for (i=0; i<mystring.length; i++) {
    newstring = newstring + '%' + tohex(mystring.charCodeAt(i));
  }
  return newstring;
}

function tohex(n) {
    var hs='0123456789ABCDEF'
    return hs.charAt(Math.floor(n/16))+hs.charAt(n%16);
}