/*
     Author:  Benedict J. Martinka, 9/19/2003.
     These functions facilitate including email links in pages in a way that "SPAM spiders" can't find them.
     Newer pages with proper use of styles should be able to use the first, simpler function.
     Older style pages may require the second function to achieve desired formatting by supplying HTML to it.
     For both of these functions, Supply empty string "" in parameter list for any value not required.
     It is recommended that domain extension be separated into the ext parameter for greater margin of safety,
     but if included in 2nd param, set 3rd param to "".
     If txt param is "", the email address will be supplied as text.
     The subject parameter may not be supported by all mail programs or browsers but should be ignored if not.
     For greater compatibility, all spaces in subjects are URL-encoded here so user doesn't need to worry about it.
     Script tags must be declared as language="Javascript1.2" to use this capability, or spaces will not get replaced.

     Most common usage examples (embed script tag in page content where link is to appear):

     Example 1 - Use email address as link text (no subject or special formatting):
          Send questions to 
          <script type="text/javascript" language="Javascript1.2">link2email("writers","ourmailnet","com","","")</script>

     Example 2 - Use supplied subject and link text:
          Didn't find what you need? <script type="text/javascript" language="Javascript1.2">
          link2email("topics","ourmailnet","com","Topic Suggestion","Suggest a topic for a new Infoproduct!")</script>     
*/


function link2email(acct,domain,ext,subject,txt) 
{
  /* 
     Use this function if formatting is already handled by a stylesheet, body or span tag, or other enclosing element.

     Supply empty string "" in parameter list for any value not required.
     It is recommended that domain extension be separated into the ext parameter for greater margin of safety,
     but if included in 2nd param, set 3rd param to "".
     If txt param is "", the email address will be supplied as text.
  */
  if (ext != "") ext = '.' + ext;
  if (subject != "") subject = '?subject=' + subject.replace(/ /g, "%20");  //URL-encode any spaces in subject
  var address = acct + '@' + domain + ext;
  if (txt == "") txt = address;
  document.write('<a href="mailto:' + address + subject + '">' + txt + '</a>');
}


function formattedlink2email(acct,domain,ext,subject,txt,attribs,txtfmtbegin,txtfmtend) 
{
  /* 
     Use this function if you need to apply special formatting or local style to the anchor tag or its contents:
     Use attribs param for any style or other attributes to be applied to the <a> tag.
     To add other HTML formatting around the txt, use the last two params,
     e.g. for boldface italics set txtfmtbegin to "<b><i>" and txtfmtend to "</i></b>"
  */
  if (ext != "") ext = '.' + ext;
  if (subject != "") subject = '?subject=' + subject.replace(/ /g, "%20");  //URL-encode any spaces in subject
  if (attribs != "") attribs = ' ' + attribs;
  var address = acct + '@' + domain + '.' + ext;
  if (txt == "") txt = address;
  document.write('<a href="mailto:' + address + subject + '"' + attribs + '>');
  document.write(txtfmtbegin + txt + txtfmtend);
  document.write('</a>');
}
