//==============================================================================
// Procedures
//==============================================================================

function WriteEncodedEmail(Domain, Name, AltText, Style) {

  //Writes an encoded version of an e-mail address that cannot be seen by e-mail
  //harvesters.  This routine should be called from the location the address is 
  //to be written to.  The address written will be Name@Domain, and will be 
  //given the CSS style specified by Style.  If AltText is specified, it will be
  //written instead of the e-mail address.  The address is automatically decoded 
  //the first time the the mouse hovers over it.

  //Normalize the arguments.
  AltText = AltText.trim();
  Style = Style.trim();
  if (Style == ""){Style = "{}";}

  //Create a unique ElementID.
  var ElementID = Math.floor(1e+6 * Math.random());
  ElementID = ElementID.toString();

  //Initialize global variable (i.e. not declared with var).
  EncodedEmailMessage = "The e-mail address you clicked has been encoded to prevent spammers from finding it.  To e-mail to this address, manually copy the name, @ symbol, and site domain to the address field of your e-mail program.\n\n(If you copy the full address from the Web page using your mouse, after pasting it you may need to manually delete spaces from between the name, @ symbol, and domain portions of the address.)";

  var AltEncodedEmailMessage = "The e-mail address has been encoded to prevent spammers from finding it.  To e-mail to this address, manually type the following in the address field of your e-mail program, including the @ symbol where instructed:  \\n\\n     " + Name + " (symbol) " + Domain;

  var MouseoverEventHTML;
  MouseoverEventHTML  = "onmouseover=\"";
  MouseoverEventHTML += "WriteDecodedEmail('" + ElementID + "', '" + Domain + "', '" + Name + "', '" + AltText + "', '" + Style + "');\"";

  var EncodedHTML;
  EncodedHTML    = "<table id='" + ElementID + "' " + MouseoverEventHTML + " border='0' cellpadding='0' cellspacing='0' style='{font-size:100%;}'>";  //Set the default font size to that of this table's parent element.
  EncodedHTML   += "   <tr>";
  if (AltText == "") {
    EncodedHTML += "      <td><a href='javascript:alert(EncodedEmailMessage);' style='" + Style + "'>" + Name   + "</a></td>";
    EncodedHTML += "      <td><a href='javascript:alert(EncodedEmailMessage);' style='" + Style + "'>@</a></td>";
    EncodedHTML += "      <td><a href='javascript:alert(EncodedEmailMessage);' style='" + Style + "'>" + Domain + "</a></td>";
    }
  else {
    EncodedHTML += "      <td><a href='javascript:alert(\"" + AltEncodedEmailMessage + "\");' style='" + Style + "'>" + AltText   + "</a></td>";
    EncodedHTML += "      <td></td>";
    EncodedHTML += "      <td></td>";
    }
  EncodedHTML   += "   </tr>";
  EncodedHTML   += "</table>";

  document.write(EncodedHTML);
  }


function WriteDecodedEmail(ElementID, Domain, Name, AltText, Style) {

  //See the  WriteEncodedEmail routine for documentation,

  //Disable this event handler.
  document.getElementById(ElementID).onmouseover = null;

  if (AltText == "") {
    document.getElementById(ElementID).rows[0].cells[0].innerHTML = "<a href='mailto:" + Name + "@" + Domain + "' style='" + Style + "'>" + Name + "@" + Domain + "</a>";
    }
  else {
    document.getElementById(ElementID).rows[0].cells[0].innerHTML = "<a href='mailto:" + Name + "@" + Domain + "' style='" + Style + "'>" + AltText + "</a>";
    }
  document.getElementById(ElementID).rows[0].cells[1].innerHTML = "";
  document.getElementById(ElementID).rows[0].cells[2].innerHTML = "";
  }


//------------------------------------------------------------------------------

