function UBBcode(temp,trans) {

if (trans==11){return ("<font color=red><b>×××该帖已被管理员屏蔽×××</b></font>")}
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,"&");



//QQ表情
if (getCookie('UBBysQQ')!='0'){  //是否打开QQ代码
temp = temp.replace(/(\[YSQQ)([0-9]*)(\])(.*?)(\[\/YSQQ\])/ig,"<SPAN onmouseover=ShowQQ($2) hand><IMG height=41 src='images/YSQQ/$2.gif' width=41 border=0><iframe src=images/YSQQ/$2.htm frameborder=0 height=41 width=140 scrolling=no></iframe></SPAN>");
temp = temp.replace(/(\[YSQQ)([0-9]*)(\])/ig,"<SPAN onmouseover=ShowQQ($2) hand><table border=0 cellspacing=1 cellpadding=0 bgcolor=#cc99ff><tr><td width=45 height=45 bgcolor=#FFFFFF align=center><IMG height=41 src='images/YSQQ/$2.gif' width=41 border=0></td><td bgcolor=#FFFFFF><iframe src=images/YSQQ/$2.htm frameborder=0 height=41 width=140 scrolling=no></iframe></td></tr></table></SPAN><table width=10% border=0 cellspacing=0 cellpadding=0><tr><td height=2></td></tr></table>");
}
//QQ表情

//巧嘴娃娃表情

if (getCookie('UBBYSWW')!='0'){  //是否打开QQ代码
temp = temp.replace(/(\[YSWW)([0-9]*)(\])(.*?)(\[\/YSWW\])/ig,"<span id=YSWW style='FONT-SIZE: 9pt;'><form  onmouseover=javascript:this.YSWW.play()><EMBED name=YSWW src=images/YSWW/$2.swf width=50 height=50 type=application/x-shockwave-flash><iframe src=images/YSWW/$2.htm frameborder=0 height=50 width=140></iframe></form></span> ");
temp = temp.replace(/(\[YSWW)([0-9]*)(\])/ig,"<span id=YSWW><table border=0 cellspacing=1 cellpadding=0 bgcolor=#cc99ff><form  onmouseover=javascript:this.YSWW.play()><tr><td width=55 height=55 bgcolor=#FFFFFF align=center><EMBED name=YSWW src=images/YSWW/$2.swf width=50 height=50 type=application/x-shockwave-flash></td><td bgcolor=#FFFFFF><iframe src=images/YSWW/$2.htm frameborder=0 height=50 width=140 scrolling=no></iframe></td></tr></form></table></span><table width=10% border=0 cellspacing=0 cellpadding=0><tr><td height=2></td></tr></table>");
}
//巧嘴娃娃表情



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 "<div><TEXTAREA cols=70 rows=10>"+$2+"</TEXTAREA><br><INPUT onclick=runCode() type=button value=运行代码>[Ctrl+A 全部选择 提示：你可先修改部分代码，再按运行]</div>";
});

temp = temp.replace(/(\[TABLE)([^]]*)(\])(.*?)(\[\/TABLE\])/ig,function(TA,TB,TC,TD,TE){
if (TC.toLowerCase().indexOf("on")>=0||TC.toLowerCase().indexOf("st")>=0){TC='';}
TE = TE.replace(/(\[TR)([^]]*)(\])/ig,function ($1,$2,$3){if ($3.toLowerCase().indexOf("on")>=0||$3.toLowerCase().indexOf("st")>=0){$3='';}return "<TR "+$3+">"});
TE = TE.replace(/(\[TD)([^]]*)(\])/ig,function ($1,$2,$3){if ($3.toLowerCase().indexOf("on")>=0||$3.toLowerCase().indexOf("st")>=0){$3='';}return "<TD "+$3+">"});
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\](.*?)\[\/b\])/ig,"<b>$2<\/b>");
temp = temp.replace(/(\[i\](.*?)\[\/i\])/ig,"<i>$2<\/i>")
temp = temp.replace(/(\[u\](.*?)\[\/u\])/ig,"<u>$2<\/u>")
temp = temp.replace(/(\[strike\](.*?)\[\/strike\])/ig,"<strike>$2<\/strike>")
temp = temp.replace(/(\[center\](.*?)\[\/center\])/ig,"<center>$2<\/center>")
temp = temp.replace(/(\[FLY\](.*?)\[\/FLY\])/ig,"<marquee>$2<\/marquee>")
temp = temp.replace(/(\[QUOTE\](.*?)\[\/QUOTE\])/ig,"<BLOCKQUOTE><strong>引用</strong>：<HR Size=1>$2<HR SIZE=1><\/BLOCKQUOTE>")


temp = temp.replace(/(\[font=([^.:;`'"=\]]*?)\](.*?)\[\/font\])/ig,"<FONT face='$2'>$3<\/FONT>");
temp = temp.replace(/(\[COLOR=([^.:;`'"=\]]*?)\](.*?)\[\/COLOR\])/ig,"<FONT COLOR='$2'>$3<\/FONT>");
temp = temp.replace(/(\[size=([0-9]*?)\](.*?)\[\/size\])/ig,"<FONT size='$2'>$3<\/FONT>");


//自动识别URL
if (trans==0){
temp = temp.replace(/([^]='])(| |<br>)(http|https|ftp|rtsp|mms):\/\/([^\s<\[]+(| |<br>)?)/ig,"$1$2<A TARGET=_blank HREF=\"$3://$4\">$3://$4</A>");
}


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\">$3<\/A>");
temp = temp.replace(/链接地址:http:\/\//ig,"访问此链接");

temp = temp.replace(/(\[mp3\]([^]]*?)\[\/mp3\])/ig,"<object classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 width=450 height=70><param name=ShowStatusBar value=-1><param name=Filename value=$2><\/object>");
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'>$3</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>");
temp = temp.replace(/(\[DRAW\])(\d*)(\[\/DRAW\])/ig,"<iframe width=530 height=300 frameborder=0 scrolling=auto src='myshow.asp?id=$2'><\/iframe><br>");
temp = temp.replace(/(\[DRAW\]images\/upfile\/updraw\/)([^];.'"<]*)\_(\d*)\.htm(\[\/DRAW\])/ig,"<iframe width=530 height=300 frameborder=0 scrolling=auto src='images\/upfile\/updraw\/$2\_$3\.htm'><\/iframe><br>");
}

if (getCookie('UBBbrow')!='0'){  //是否打开表情代码
temp = temp.replace(/(\[em([0-9]*)\](.*?)\[\/em\])/ig,"<TABLE align=left><TR><TD Background=images/plus/CEback.gif height=133px valign=top style=Background-repeat:no-repeat><div style=width:227px;height:113px;margin:6px;overflow:auto>$3</div></TD></TR><TR><TD>  <IMG border=0 SRC=images/Emotions/$2.gif></TD></TR></TABLE>");
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();
}




