/*
 * sendmail.js
 * Invokes the browser's associated e-mail program using an obfuscated e-mail
 * address.
 * 
 * Usage:
 *   <a href="javascript:void(0)"
 *      onclick="return sendmail('\u0075\u0073\u0065\u0072')">send e-mail</a>
 *
 * Parameters:
 *  user (required)   - String representing the username of the recipient. A
 *                      string of Unicode characters is recommended.
 *  domain (optional) - String representing the domain name of the recipient.
 *                      Default value is the domain name of the window.
 *
 * Returns:
 *   false, to override default hyperlink behavior.
 *
 * Author:
 *   David Lindquist (dave@gazingus.org)
 */
function skrivtill(user, domain) {
  
  // protocol
  var p = "\u006d\u0061\u0069\u006c\u0074\u006f\u003a";
  
  // usename
  var u = user;
  
  // domain name (host name sans machine name)
  var d = domain ||
          location.host.substring(
            location.host.lastIndexOf(
              ".",
              location.host.lastIndexOf(".") - 1
            ) + 1
          );

  void(top.location = p + u + "\u0040" + d);
  return false;
}

