/**************************************************************************
* copy_paste.js 2007/12/19 v1.1
===========================================================================
* 自動複製功能
===========================================================================
* Edited by Pai in GOGOTDI
* Copyright (C) 2006 Tang Digital Integration
***************************************************************************/

function ShowText(TextName){
	text_obj	= document.getElementById('readme'+TextName);
	but_obj 	= document.getElementById('show'+TextName);
	
	if (text_obj.style.display == "block"){		   
		text_obj.style.display = "none";
		but_obj.value = "詳細說明";
	}
	else{
		text_obj.style.display = "block";
		but_obj.value = "關閉說明";
	}
}

function CopyText(objvalue){
	if(window.clipboardData){
		var type = "Text";
		var data = document.getElementById(objvalue).value;
		var clipboard = window.clipboardData;
		clipboard.setData(type, data);
		alert('複製完成，在任何地方按右鍵貼上即可。');
	}
	else if(window.netscape){
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        }
        catch (e)
        {
			alert("瀏覽器目前的設定不支援自動複製功能！\n開一個新分頁，在網址列打上 about:config\n用篩選器找到 signed.applets.codebase_principal_support 這個值，用滑鼠點連點，把他改為 true ");
        }
		
		  var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); 
		  if (!clip) return; 
		  var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); 
		  if (!trans) return; 
		  trans.addDataFlavor('text/unicode'); 
		  var str = new Object(); 
		  var len = new Object(); 
		  var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
		  var copytext=document.getElementById(objvalue).value;
		  str.data=copytext; 
		  trans.setTransferData("text/unicode",str,copytext.length*2); 
		  
		  var clipid=Components.interfaces.nsIClipboard; 
		  if (!clip) return false; 
		 
		  clip.setData(trans,null,clipid.kGlobalClipboard); 
		  alert('複製完成，在任何地方按右鍵貼上即可。');
		  return true; 
	}
	else{
		alert("瀏覽器不支援自動複製功能,請點選左方輸入欄按滑鼠右鍵複製語法！");
	}
}
