// JavaScript Document
var emoteData=[]
function zoneEncode(text){
	text=text.toHTML()
	for(var i=0; i<=90; i++){
		eval("text=text.replace(/\\[em\\]e"+i+"\\[\\/em\\]/g,'<img src=\"/img/em/e"+i+".gif\"/>')")
	}
	for(var i=0; i<emoteData.length; i++){
		eval("text=text.replace(/\\[em\\]e"+(100+i)+"\\[\\/em\\]/g,'<img src=\"/img/em/"+i+".gif\"/>')")
	}
	text=text.replace(/\[ftf=([^]]+)\]/g,'<font_lycode face="$1">')
	text=text.replace(/\[fts=([^]]+)\]/g,'<font_lycode size="$1" style="line-height: 1.3me">')
	text=text.replace(/\[ftc=([^]]+)\]/g,'<font_lycode color="$1">')
	text=text.replace(/\[ffg,([^,]+),([^]]+)\]/g,'<font_lycode style="display: inline-block; filter: glow(color=$1,strength=3); color: $2; padding: 1px; height: 10px;">')
	text=text.replace(/\[B\]/g,'<b_lycode>')
	text=text.replace(/\[I\]/g,'<i_lycode>')
	text=text.replace(/\[U\]/g,'<u_lycode>')
	text=text.replace(/\[M\]/g,'<center_lycode>')
	text=text.replace(/\[R\]/g,'<center_lycode style="text-align: right">')
	
	text=text.replace(/\[\/ft\]/g,'</font_lycode>')
	text=text.replace(/\[\/B\]/g,'</b_lycode>')
	text=text.replace(/\[\/I\]/g,'</i_lycode>')
	text=text.replace(/\[\/U\]/g,'</u_lycode>')
	text=text.replace(/\[\/M\]/g,'</center_lycode>')
	text=text.replace(/\[\/R\]/g,'</center_lycode>')
	var testData=new Array("font","b","i","u","center")
	for(var i=0; i<testData.length; i++){
		var nStart=text.split("<"+testData[i]+"_lycode").length-1
		var nEnd=text.split("</"+testData[i]+"_lycode").length-1
		for(var o=nStart; o>nEnd; o--){
			text+='</'+testData[i]+'_lycode>'
		}
	}
	return text.replace(/\_lycode/g,"")+"&nbsp;"
}




String.prototype.toNum=function(){
	var n=this.match(/\d+/,"")
	if(n) return parseInt(n)
	else return 0
}
String.prototype.toDate=function(){
	var d=this.split(/\D+/)
	--d[1]
	return new Date(d[0],d[1],d[2],d[3],d[4],d[5])
}
String.prototype.toHTML=function(){
	return this.replace(/&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/"/g,"&quot;").replace(/\r\n|\r|\n/g,"<br/>").replace(/[\s\xa0]/g,"&nbsp;")
}
String.prototype.toAttribute=function(){
	return this.replace(/&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/"/g,"&quot;").replace(/\r\n|\r|\n/g,"&#13;&#10;").replace(/[\s\xa0]/g,"&nbsp;")
}
String.prototype.toURL=function(){
	return encodeURIComponent(this)
}
Date.prototype.toString=function(){
	return String(this.getFullYear()+"-0"+(this.getMonth()+1)+"-0"+this.getDate()+" 0"+this.getHours()+":0"+this.getMinutes()+":0"+this.getSeconds()).replace(/(\D)0(\d{2})/g,"$1$2")
}
var $=function(id){return document.getElementById(id)}











function copyCode(id){
	var testCode=document.getElementById(id).value;
	if(copy2Clipboard(testCode)!=false){
		alert("生成的代码已经复制到粘贴板，你可以使用Ctrl+V 贴到需要的地方去了哦！  ");
	}
}
copy2Clipboard=function(txt){
	if(window.clipboardData){
		window.clipboardData.clearData();
		window.clipboardData.setData("Text",txt);
	}
	else if(navigator.userAgent.indexOf("Opera")!=-1){
		window.location=txt;
	}
	else if(window.netscape){
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}
		catch(e){
			alert("您的firefox安全限制限制您进行剪贴板操作，请打开’about:config’将signed.applets.codebase_principal_support’设置为true’之后重试，相对路径为firefox根目录/greprefs/all.js");
			return false;
		}
		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);
	}
}