

function copy_clip(str) {
    var mainText;

    if (str.indexOf(';') == -1) {
        mainText = str;
    }
    else {
        var arr = str.split(';');
        mainText = arr.join('\r\n');
    }

    if (window.clipboardData) {
        // the IE-manier
        window.clipboardData.setData("Text", mainText);

    }
    return false;
}



var DownloadUrl;

var DownloadUrlCopyObject;

var DownloadMoviePath = 'scripts/ZeroClipboard10.swf'

function CopyCreateOverlay(divId, containerId) {

    if (divId == undefined && containerId == undefined) {
        divId = 'btCopyDiv';
        containerId = 'btCopyContainer';
    }

    if (!document.getElementById(divId) || !document.getElementById(containerId))
        return;

    //Flash Overlay
    if (!window.clipboardData) {
        var clip;

        if (DownloadUrlCopyObject) {
            clip = DownloadUrlCopyObject;
        } else {
            ZeroClipboard.setMoviePath(DownloadMoviePath);
            clip = new ZeroClipboard.Client();
            clip.setHandCursor(true);
        }
        clip.setText(DownloadUrl);

        clip.glue(divId, containerId);
        DownloadUrlCopyObject = clip;
    }
}

function CopyCreateOverlay2(divId, containerId, text) {

    if (divId == undefined && containerId == undefined) {
        divId = 'btCopyDiv';
        containerId = 'btCopyContainer';
    }

    if (!document.getElementById(divId) || !document.getElementById(containerId))
        return;

    //Flash Overlay
    if (!window.clipboardData) {
        var clip;

        ZeroClipboard.setMoviePath(DownloadMoviePath);
        clip = new ZeroClipboard.Client();
        clip.setHandCursor(true);

        clip.setText(text);

        clip.glue(divId, containerId);
    }
}


function CopyDownloadUrl() {
    copy_clip(DownloadUrl);
    return false;
}
