﻿function email(name, domain, suffix, text)
{
    var address = name + "\u0040" + domain + "." + suffix;
    var url = "<a href='mailto:" + address + "'>" + address + "</a>";

    if (!text || text.length < 1)
    {
        text = url;
    }
    
    document.write("" + text + "");
}

function CopyToClipboard(textValue, controlId)
{
   // textValue = text to copy into clipboard.
   // controlId = TextBox (textarea) control ID to use as placeholder for copying text into clipboard. Can have width/height = 0px.
   var txt = document.getElementById(controlId);

   txt.value = textValue;

   txt.focus();
   txt.select();

   // For cross-browser compatible clipboard copy, use the flash copy to clipboard method.
   copy(txt);
}

function copy(inElement)
{
  // http://www.jeffothy.com/weblog/clipboard-copy/
  if (inElement.createTextRange) 
  {
    var range = inElement.createTextRange();
    if (range)// && BodyLoaded==1)
      range.execCommand('Copy');
  }
  else
  {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) 
    {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
 
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="/CMS/images/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}
