////////////////////////////////////////
//
// hack create SPAM-safe mailto-links
//
// Author: Andy Spiegl
// original idea from a hotline tip in c't magazine, 11/2002, page 192
//
////////////////////////////////////////


//
// Function write_email_address
//
// Parameters:
//   name        : username part of the email address
//   domain      : number or alias of domainname part of the email address
function write_email_address(name,domain)
{
  var addr = email_address(name,domain);
  document.write(addr);
}

//
// Function write_mailto
//
// Parameters:
//   name        : username part of the email address
//   domain      : number or alias of domainname part of the email address
//   description : optional - full name of the email address
//   color       : optional - color of link
//   a_params    : optional - more parameters to the A-tag
function write_mailto(name,domain,description,color,a_params)
{
  var addr = email_address(name,domain);

  document.write('<a href=\'mailto:' + addr + '\'');
  if (a_params)
    document.write(' ' + a_params);
  document.write('>');

  if (color)
    document.write('<font color=' + color + '>')

  if (description)
    document.write(description)
  else
    document.write(addr);

  if (color)
    document.write('</font>')

  document.write('</a>')
}

//
// Function write_flexible
//
// Parameters:
//   prefix      : optional - string to write before the email address
//   name        : username part of the email address
//   domain      : number or alias of domainname part of the email address
//   postfix     : optional - string to write after the email address
function write_flexible(prefix,name,domain,postfix)
{
  var addr = email_address(name,domain);

  document.write(prefix + addr + postfix);
}

//
// Function email_address
//
// Parameters:
//   name        : username part of the email address
//   domain      : number or alias of domainname part of the email address
function email_address(name,domain)
{
  var domainname;

  switch(domain)
  {
	case "1":
	case "spiegl":
      domainname ="spiegl.de";
      break;

    case "2":
	case "rm":
	case "maranon":
	case "radiomaranon":
      domainname ="radiomaranon.org.pe";
      break;

    case "3":
	case "marco":
	case "webdemarco":
      domainname ="webdemarco.de";
      break;

    default:  // if it's not a shortcut
      domainname = domain;
      break;
  }

  return name + '@' + domainname;
}
