
function copyToClipboard(textToCopy){
	if(window.clipboardData) // For IE
	{
		window.clipboardData.setData("Text", textToCopy);
	}
	else if(window.netscape) // For the Mozilla family of browsers. Doco at http://www.xulplanet.com/tutorials/xultu/clipboard.html 
	{
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		
		var clipboard     = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		var transferable  = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		var supportString = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

		if (!clipboard||!transferable||!supportString){
			alert("Error. Could not copy the text to the clipboard");
			return;
		}
		
		supportString.data=textToCopy;
		transferable.addDataFlavor('text/unicode');
		transferable.setTransferData("text/unicode",supportString,textToCopy.length*2);
		clipboard.setData(transferable,null,Components.interfaces.nsIClipboard.kGlobalClipboard);
	}
	alert("Following text was copied to your clipboard:\n\n" + textToCopy);
	return false;
}
function copyBodyToClipboard(){
	copyToClipboard(document.body.innerHTML)
}