// JavaScript Document
/*LOGIN BOX*/
function openLoginBox(){
	var myWidth = 0, myHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
	    myWidth = window.innerWidth;
    	myHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
  	}
	
	if(document.getElementById('loginBox').style.display == "none" || document.getElementById('loginBox').style.display == ""){
		document.getElementById('loginBox').style.right = ((myWidth-1000)/2)+"px";
		document.getElementById('loginBox').style.top = "28px";
		document.getElementById('loginBox').style.display = "block";
		document.topLoginForm.account.focus();
	}else{
		document.getElementById('loginBox').style.display = "none";
	}
}

function closeLoginBox(){
	if(document.getElementById('loginBox').style.display == "block"){
		document.getElementById('loginBox').style.display = "none";
	}
}

function submitenter(myfield, e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13){	
		myfield.form.submit();	//IE8 don't work
   		return false;
   	}
	else
   		return true;
}
function copyToClipboard(txt) {
    var copied = false;
     if(window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
        copied = true;
     } 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 = txt;
        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);
        copied = true;
     }
     if (copied) alert('文字內容已複製到剪貼簿中!');
     else alert("使用的瀏覽器不支援文字複製功能!");
}  
