/* author:	Richard Schmid, infolox GmbH, http://www.infolox.de */

function OSL_CopyToClipboard(oDocument) {
	var sCBValue = "";
	for( var i=0; i < hw_osidx.length; i++ ) {
		sCBValue = sCBValue + hw_osidx[i][0] + '\n';
	}
	if (sCBValue != "") {
		oDocument.forms['OSLCBCopy'].s1value.value = sCBValue;
	}
	if (document.all) {
		var tr = oDocument.forms['OSLCBCopy'].s1value.createTextRange();
		tr.select();
		tr.execCommand('copy');
		alert("Data was copied to the Clipboard.");
	}
	else if (window.Components) {
		var sValue = oDocument.forms['OSLCBCopy'].s1value.value;
		try {
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		}
		catch (e) {
			alert("This functionality was tested for Internet Explorer.");
			return false;
		}
        this.iClipBoardID = Components.interfaces.nsIClipboard;
        this.cClipBoard = Components.classes['@mozilla.org/widget/clipboard;1'].getService(this.iClipBoardID);
        this.cClipBoardString = Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString);
        this.cClipBoardString.data = sValue;
        var cTransfer = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        cTransfer.setTransferData('text/unicode', this.cClipBoardString, sValue.length*2 );
        this.cClipBoard.setData(cTransfer, null, this.iClipBoardID.kGlobalClipboard);
	}
}
