﻿function copyToClipboard(textboxsource) {

    document.getElementById(textboxsource).focus();
    document.getElementById(textboxsource).select();

    // BROWSER-COMPAT: FFx / IEx / SAFx
    // If using FireFox, then display prompt to press Ctrl+C to copy
    if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1 |
        navigator.userAgent.toLowerCase().indexOf("safari") != -1) 
    {
        alert("After you close this box, please press control+C (or command+C on a Mac) to copy the selected text.");
    }
    else {
        copiedTxt = document.selection.createRange();
        copiedTxt.execCommand("Copy");
    }
    return false;
}

function copyImageLinkToClipboard(imgSource) {
    var img = document.getElementById(imgSource);

    if (img) {	
        if (document.selection) {
            var div = document.body.createTextRange();

            div.moveToElementText(img);
            div.select();
        }
        else {
            var div = document.createRange();

            div.setStartBefore(img);
            div.setEndAfter(img);
 
            window.getSelection().addRange(div);
        }

        // BROWSER-COMPAT: FFx / IEx / SAFx
        // If using FireFox, then display prompt to press Ctrl+C to copy
        if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1 |
            navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
            alert("After you close this box, please press control+C (or command+C on a Mac) to copy the image and link. Then paste into your email.");
        }
        else {
            copiedTxt = document.selection.createRange();
            copiedTxt.execCommand("Copy");
        }
    }

    return false;
}