/**
 * Copyright (c) 2008 Avake Technology, Inc.
 * All rights reserved.
 */
 
function genEmail(mailAnchorId, url, title) {
  var msg = 'Hi,\n\nThought you might find it interesting.\n\n';
  customEmail(mailAnchorId, url, title, msg);
}

function customEmail(mailAnchorId, url, title, msg) {
  var subject = "TolMol: " + title;
  var body = msg;
  body = body + langFix(url);
  body = body + "\n\n" + "http://www.tolmol.com - Search, Compare, and Share" + "\n\nCheers";

  body = escape(body);
  subject = escape(subject);

  var mailurl = "mailto:?subject=" + subject +
      "&body=" + body;

  var mailto = document.getElementById(mailAnchorId);
  mailto.href = mailurl;
}

function setEmailLink(mailAnchorId, url, msg) {
  var title = "TolMol - Interesting Link"
  var elm = document.getElementById(mailAnchorId);
  if (elm != null) {
      title = elm.title;
  }
  customEmail(mailAnchorId, url, title, msg);
}  

function setJobsMailLink(mailAnchorId, url) {
  var content = 'Hi,\n\nI found this job on TolMol. Thought this might be of your interest.\n\nPlease check out - ';
  setEmailLink(mailAnchorId, url, content);
}

function setNewsMailLink(mailAnchorId, url) {
  var content = 'Hey!\n\nI came across this news on TolMol News, thought you might find it interesting.\n\nPlease check out - ';
  setEmailLink(mailAnchorId, url, content);
}

function langFix(data) {
    return data.replace( /&lang=/g, "&amp;lang=" );
}
