function contacts_url2domain(url)
 {
  if(!url.match(/^http\:/))
    return '';

  var s = url.replace(/\s/g, ''); // Whitespace
  s = s.replace(/^http\:\/+/, ''); // Protocol
  s = s.replace(/^[^@]*@/, ''); // User/password
  s = s.replace(/^([^\/\\]*)[\/\\].*$/, '$1'); // Path
  s = s.replace(/^www\./, ''); // www.
  //TODO: subdomains aren't supported!

  return s;
 }

function contacts_email(user,domain)
 {
  if((user.length < 1) || (domain.length < 1))
    return '';
  return user + '@' + domain;
 }

 function contacts_mailto(user,domain)
  {
   var email = contacts_email(user,domain);
   if(email.length < 1)
     return '';
   return 'mailto:' + email;
  }

 function contacts_mailtolink(user,domain)
  {
   var email = contacts_email(user,domain);
   if(email.length < 1)
     return '';
   return '<a href="mailto:' + email + '">' + email + '</a>';
  }


