function UBBcode(temp,trans) {
if (trans==11){return ("×××已屏蔽×××")}
if (trans==10){return (temp);}
if (badwords!=''&&Ubad==1){    //过滤敏感字
var badword= badwords.split ('|'); 
for(i=0;i<badword.length;i=i+1) {
if (badword[i] !=""){temp = temp.replace(badword[i],"****");}
}

}

if (getCookie('UBBcode')!='0'){ //是否打开UBB代码
temp = temp.replace(/&amp;/ig,"&");
//自动识别URL
if (trans==0){
temp = temp.replace(/([^]='])(| |<br>)((http|https|ftp|rtsp|mms):(\/\/|\\\\)[^< ]+)(| |<br>)/ig,"$1$2<A TARGET=_blank HREF='$3'>$3</A>");
}
temp = temp.replace(/(\[HTML\])(.*)(\[\/HTML\])/ig,function($0,$1,$2){
$2 = $2.replace(/<BR>/ig,"\n");
$2 = $2.replace(/<P>/ig,"\n\r\n");
return "<span><TEXTAREA cols=70 rows=10 id='RUNCODE'>"+$2+"</TEXTAREA><br><INPUT onclick=runCode() type=button value=运行代码>[Ctrl+A 全部选择 提示：你可先修改部分代码，再按运行]</span>";
});

temp = temp.replace(/(\[TABLE)([^]]*)(\])(.*)(\[\/TABLE\])/ig,function(TA,TB,TC,TD,TE){
TE = TE.replace(/(\[TR)([^]]*)(\])/ig,"<TR $2>");
TE = TE.replace(/(\[TD)([^]]*)(\])/ig,"<TD $2>");
TE = TE.replace(/\[\/TR\]/ig,"</TR>");
TE = TE.replace(/\[\/TD\]/ig,"</TD>");
return "<table "+TC+" >"+TE+"</table>";
});


temp = temp.replace(/(\[code\])([^]]*)(\[\/code\])/ig,"<BLOCKQUOTE><strong>代码</strong>：<HR Size=1>$2<HR SIZE=1><\/BLOCKQUOTE>");
temp = temp.replace(/\[b\]/ig,"<b>");
temp = temp.replace(/\[\/b\]/ig,"<\/b>");
temp = temp.replace(/\[i\]/ig,"<i>");
temp = temp.replace(/\[\/i\]/ig,"<\/i>");
temp = temp.replace(/\[u\]/ig,"<u>");
temp = temp.replace(/\[\/u\]/ig,"<\/u>");
temp = temp.replace(/\[strike\]/ig,"<strike>");
temp = temp.replace(/\[\/strike\]/ig,"<\/strike>");
temp = temp.replace(/\[center\]/ig,"<center>");
temp = temp.replace(/\[\/center\]/ig,"<\/center>");
temp = temp.replace(/\[FLY\]/ig,"<marquee>");
temp = temp.replace(/\[\/FLY\]/ig,"<\/marquee>");
temp = temp.replace(/\[QUOTE\]/ig,"<BLOCKQUOTE><strong>引用</strong>：<HR Size=1>");
temp = temp.replace(/\[\/QUOTE\]/ig,"<HR SIZE=1><\/BLOCKQUOTE>");
temp = temp.replace(/(\[font=)([^.:;`'"=\]]*)(\])/ig,"<FONT face='$2'>");
temp = temp.replace(/\[\/font\]/ig,"<\/FONT>");
temp = temp.replace(/(\[COLOR=)([^.:;`'"=\]]*)(\])/ig,"<FONT COLOR='$2'>");
temp = temp.replace(/\[\/COLOR\]/ig,"<\/FONT>");
temp = temp.replace(/(\[size=)([0-9]*)(\])/ig,"<FONT size='$2'>");
temp = temp.replace(/\[\/size\]/ig,"<\/FONT>");

temp = temp.replace(/(\[URL\])([^]]*)(\[\/URL\])/ig,"<A TARGET=_blank HREF='$2'>$2</A>");
temp = temp.replace(/(\[URL=)([^]]*)(\])(\[IMG\])([^];]*)(\[\/IMG\])(\[\/URL\])/ig,"<A TARGET=_blank HREF='$2'><img alt='链接地址：$2' border=0 src='$5'  onload='javascript:if(this.width>body.clientHeight)this.width=body.clientHeight' onerror='this.src=\"images/errorlink.gif\"'><\/A>");
temp = temp.replace(/(\[URL=)([^]]*)(\])([^];]*)(\[\/URL\])/ig,"<A TARGET=_blank HREF='$2' title='链接地址:$2'>$4<\/A>");
temp = temp.replace(/链接地址:http:\/\//ig,"链接地址:");

//『雨丝』附件防盗链系统
temp = temp.replace(/(\[URLL\])([^]]*)(\[\/URLL\])/ig,"<a style=cursor:hand href=# onclick=javascript:open('$2','','width=250,height=120,resizable,scrollbars')>$2</A>");
temp = temp.replace(/(\[URLL=)([^]]*)(\])/ig,"<a style=cursor:hand href=# onclick=javascript:open('$2','','width=250,height=120,resizable,scrollbars')>");
temp = temp.replace(/\[\/URLL\]/ig,"<\/A>");
//『雨丝』附件防盗链系统



//后加入部分

temp = temp.replace(/\[mp3\]([^]]*)\[\/mp3\]/ig,"<OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=55 width=400><PARAM NAME=SRC VALUE=$1><PARAM NAME=CONTROLS VALUE=ControlPanel,StatusBar><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=AUTOSTART VALUE=true><\/OBJECT><br>");
temp = temp.replace(/(\[BEI\])(.*)(\[\/BEI\])/ig,"<br><object classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 width=0 height=0><param name=ShowStatusBar value=-1><param name=PlayCount value=0><param name=Filename value=$2><\/object><br>");
temp = temp.replace(/(\[iframe\])(.*)(\[\/iframe\])/ig,"<iframe width=410 height=250 frameborder=0 scrolling=yes src=$2><\/iframe><br>");
temp = temp.replace(/(\[text6\])(.[^\[]*)(\[\/text\])/ig,"<span STYLE='position:relative;height:22px; FONT-SIZE:10pt;filter:glow(Color=#7ec0ee,Strength=3)'>$2<\/span>");
temp = temp.replace(/(\[text7\])(.[^\[]*)(\[\/text\])/ig,"<SPAN style='FONT-SIZE: 5pt; FILTER: glow(color=#909090,strength=3) shadow(color:#000000,direction=125);height:22px;COLOR: white;POSITION: relative'><SPAN class=shadow1><FONT size='2' color=#ffffff>$2<\/FONT><\/SPAN><\/SPAN>");
temp = temp.replace(/(\[text8\])(.[^\[]*)(\[\/text\])/ig,"<font style='FONT-SIZE: 10pt;cursor:hand;height:22px;color:ffff00;filter:glow(color=red,strength=3)'>$2<\/font>");

temp = temp.replace(/(\[text9\])(.[^\[]*)(\[\/text\])/ig,"<span style='FILTER: glow(color=red, strength=3);height:22px;font-size:10pt' >$2<\/span>");
temp = temp.replace(/(\[text10\])(.[^\[]*)(\[\/text\])/ig," <span style='FILTER: shadow(color=blue, direction=1 ,strength=1);height:22px;font-size:10pt'>$2<\/span>");
temp = temp.replace(/(\[text11\])(.[^\[]*)(\[\/text\])/ig,"<span style='FILTER: glow(color=#000000,strength=2);height:22px;font-size:10pt;color=#ffffff'>$2<\/span>");

temp = temp.replace(/(\[text12\])(.[^\[]*)(\[\/text\])/ig,"<MARQUEE scrollAmount=3 behavior=alternate width='100%'><font size='2'>$2<\/font><\/MARQUEE>");
temp = temp.replace(/(\[text13\])(.[^\[]*)(\[\/text\])/ig,"<MARQUEE scrollAmount=3><font size='2'>$2<\/font><\/MARQUEE>");
temp = temp.replace(/(\[text)(.[^\[]*)(\])(.[^\[]*)(\[\/text\])/ig,"<span style='height:22px;filter:glow(color=$2,strength=1);color:000000;font-size:10pt'>$4</span>");
temp = temp.replace(/(\[glow\])(.[^\[]*)(\[\/glow\])/ig,"<span style='behavior:url(inc/font.htc);height:22px'>$2</span>");
//后加入部分


temp = temp.replace(/(\[EMAIL\])(\S+\@[^]]*)(\[\/EMAIL\])/ig,"<a href=mailto:$2>$2</a>");
temp = temp.replace(/(\[RM=([0-9]*)\,([0-9]*)\,([A-Z]*)\])([^]]*)(\[\/RM\])/ig,"<OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA width=$2 height=$3><PARAM NAME=SRC VALUE=$5><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=$4><\/OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=60 width=$2><PARAM NAME=CONTROLS VALUE=ControlPanel,StatusBar><PARAM NAME=CONSOLE VALUE=Clip1><\/OBJECT>");
temp = temp.replace(/(\[MP=([0-9]*)\,([0-9]*)\,([A-Z]*)\])([^]]*)(\[\/MP\])/ig,"<object classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 width=$2 height=$3><PARAM NAME=AUTOSTART VALUE=$4><param name=ShowStatusBar value=-1><param name=Filename value=$5><\/object>");
}

if (getCookie('UBBflash')!='0'){  //是否打开[FLASH]代码
temp = temp.replace(/(\[FLASH=([0-9]*)\,([0-9]*)\])([^]]*)(\[\/FLASH\])/ig,"<embed width=$2 height=$3 src='$4' >");
}

if (getCookie('UBBimg')!='0'){  //是否打开[IMG]代码
temp = temp.replace(/(\[IMG\])([^];]*)(\[\/IMG\])/ig,"<A TARGET=_blank HREF='$2'><img alt='点击新窗口仔细浏览' border=0 src='$2'  onload='javascript:if(this.width>body.clientHeight)this.width=body.clientHeight' onerror='this.src=\"images/errorlink.gif\"'></a>");
}

if (getCookie('UBBbrow')!='0'){  //是否打开表情代码
temp = temp.replace(/(\[em)([0-9]*)(\])/ig,"<IMG border=0 SRC=images/Emotions/$2.gif>");
}


return (temp);
}


function runCode()
{
var code=event.srcElement.parentElement.children[0].value;
var newwin=window.open('','','');
newwin.opener=null;
newwin.document.write(code);
newwin.document.close();
}




