
function ybbcode(temp) {

if (badwords!=''){    //过滤敏感字
var badword= badwords.split ('|'); 
for(i=0;i<badword.length;i=i+1) {
if (badword[i] !=""){temp = temp.replace(badword[i],"<font color=gray>***</font>");}
}
}

if (getCookie('ybbcode')!='0'){ //是否打开YBB代码
temp = temp.replace(/(\[glow\])(.[^\[]*)(\[\/glow\])/ig,"<span style='behavior:url(inc/font.htc)'>$2</span>");
temp = temp.replace(/&amp;/ig,"&");
temp = temp.replace(/  /ig,"　");
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(/\[move\]/ig,"<marquee behavior=alternate style=cursor:hand width=80%>");
temp = temp.replace(/\[\/move\]/ig,"<\/marquee>");
temp = temp.replace(/\[up\]/ig,"<br><marquee width=80% height=200 direction=up scrollamount=1 onmouseover='this.stop()' onmouseout='this.start()' style='background-image:url(images/back.gif);'>");
temp = temp.replace(/\[\/up\]/ig,"<\/marquee>");
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(/\[marquee\]/ig,"<marquee>");
temp = temp.replace(/\[\/marquee\]/ig,"<\/marquee>");
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=)([^]]*)(\])/ig,"<A TARGET=_blank HREF='$2'>");
temp = temp.replace(/\[\/URL\]/ig,"<\/A>");
temp = temp.replace(/(\[EMAIL\])(\S+\@[^]]*)(\[\/EMAIL\])/ig,"<a href=mailto:$2>$2</a>");
temp = temp.replace(/(\[code\])([^]]*)(\[\/code\])/ig,"<BLOCKQUOTE><strong>代码</strong>：<HR Size=1>$2<HR SIZE=1><\/BLOCKQUOTE>");
temp = temp.replace(/\[br\]/ig,"<br>");
temp = temp.replace(/\[w1\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/01.swf><\/OBJECT><b>就这事啊？地球人都知道</b></form></span> ");
temp = temp.replace(/\[w2\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/02.swf><\/OBJECT><b>嘿嘿！逗你玩~~`</b></form></span> ");
temp = temp.replace(/\[w3\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/03.swf><\/OBJECT><b>年轻人！做人要厚道！</b></form></span> ");
temp = temp.replace(/\[w4\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/04.swf><\/OBJECT><b>在干吗？这不是跟我打岔吗?</b></form></span> ");
temp = temp.replace(/\[w5\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/05.swf><\/OBJECT><b>一定要幸福噢~~~</b></form></span> ");
temp = temp.replace(/\[w6\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/06.swf><\/OBJECT><b>你好可爱噢~~~~~~</b></form></span> ");
temp = temp.replace(/\[w7\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/07.swf><\/OBJECT><b>加油哦！！！</b></form></span> ");
temp = temp.replace(/\[w8\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/08.swf><\/OBJECT><b>我好想你哦~~`</b></form></span> ");
temp = temp.replace(/\[w9\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/09.swf><\/OBJECT><b>你~不要这样嘛?</b></form></span> ");
temp = temp.replace(/\[w10\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/10.swf><\/OBJECT><b>我真的好感激你哦~~</b></form></span> ");
temp = temp.replace(/\[w11\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/11.swf><\/OBJECT><b>你简直~~~太让我感动了~~</b></form></span> ");
temp = temp.replace(/\[w12\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/12.swf><\/OBJECT><b>过来~~~近点~~再近点~~波！！</b></form></span> ");
temp = temp.replace(/\[w13\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/13.swf><\/OBJECT><b>强！！实在是强！！！</b></form></span> ");
temp = temp.replace(/\[w14\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/14.swf><\/OBJECT><b>真、真、真的么？？我要晕了！</b></form></span> ");
temp = temp.replace(/\[w15\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/15.swf><\/OBJECT><b>最近真的好想你哦！</b></form></span> ");
temp = temp.replace(/\[w16\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/16.swf><\/OBJECT><b>啊！你是中邪喔！</b></form></span> ");
temp = temp.replace(/\[w17\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/17.swf><\/OBJECT><b>你好讨厌哦~~~</b></form></span> ");
temp = temp.replace(/\[w18\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/18.swf><\/OBJECT><b>抽根嘏吧！</b></form></span> ");
temp = temp.replace(/\[w19\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/19.swf><\/OBJECT><b>不干不干就是不干！！！</b></form></span> ");
temp = temp.replace(/\[w20\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/20.swf><\/OBJECT><b>饿不饿请你吃东西~~</b></form></span> ");
temp = temp.replace(/\[w21\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/21.swf><\/OBJECT><b>听见了吗?那是我肚子在叫~~</b></form></span> ");
temp = temp.replace(/\[w22\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/22.swf><\/OBJECT><b>哼！小样，我看你还真是找扁~</b></form></span> ");
temp = temp.replace(/\[w23\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/23.swf><\/OBJECT><b>坦白从宽，我看你还是交代了吧~</b></form></span> ");
temp = temp.replace(/\[w24\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/24.swf><\/OBJECT><b>哼！你这骗子~</b></form></span> ");
temp = temp.replace(/\[w25\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/25.swf><\/OBJECT><b>我就是喜欢你动作非常慢的时候~~~</b></form></span> ");
temp = temp.replace(/\[w26\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/26.swf><\/OBJECT><b>hi！是你吧，我知道你在，我可看见你了！</b></form></span> ");
temp = temp.replace(/\[w27\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/27.swf><\/OBJECT><b>哎！看来你可真寂寞！</b></form></span> ");
temp = temp.replace(/\[w28\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/28.swf><\/OBJECT><b>年轻人，虚心点没错！</b></form></span> ");
temp = temp.replace(/\[w29\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/29.swf><\/OBJECT><b>这么说你还不明白，你猪头啊！</b></form></span> ");
temp = temp.replace(/\[w30\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/30.swf><\/OBJECT><b>掰掰落~~~</b></form></span> ");
temp = temp.replace(/\[w31\]/ig,"<span id=wawa><form  onmouseover=javascript:this.wawa.play()><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  WIDTH=36 HEIGHT=36 name=wawa><PARAM NAME=movie VALUE=images/wawa/31.swf><\/OBJECT><b>拜拜了您那~~</b></form></span>");
temp = temp.replace(/(\[QUOTE\])(.*)(\[\/QUOTE\])/ig,"<BLOCKQUOTE><strong>引用</strong>：<br><span style='border:1 gray solid;width:95%;PADDING-RIGHT: 10px;PADDING-LEFT: 10px;'>$2<\/span><\/BLOCKQUOTE>");
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]*)\])([^]]*)(\[\/MP\])/ig,"<object classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 width=$2 height=$3><param name=ShowStatusBar value=-1><param name=Filename value=$4><\/object>");
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>";});
}


if (getCookie('ybbflash')!='0'){  //是否打开[FLASH]代码
temp = temp.replace(/(\[FLASH=([0-9]*)\,([0-9]*)\])([^]]*)(\[\/FLASH\])/ig,"<embed width=$2 height=$3 src='$4' >");
}

if (getCookie('ybbimg')!='0'){  //是否打开[IMG]代码
temp = temp.replace(/(\[IMG\])([^]]*)(\[\/IMG\])/ig,"<a target=_blank href=$2><img border=0 src='$2' onload='javascript:if(this.width>body.clientHeight)this.width=body.clientHeight' title='点击图片在新窗口中浏览'></a> ");
}

if (getCookie('ybbbrow')!='0'){  //是否打开表情代码
temp = temp.replace(/(\[em)([0-9]*)(\])/ig,"<IMG border=0 SRC=images/Emotions/$2.gif>");
temp = temp.replace(/(\[dm)([0-9]*)(\])/ig,"<IMG border=0 SRC=images/dongzuo/em$2.gif>");
}

//自动识别URL
temp = temp.replace(/([^]='])(| |<br>)((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9\./=\?%\-&_~`@[\]\',:+!]+)(| |<br>)/ig,"$1$2<img src=images/ybb/ie.gif border=0><A TARGET=_blank HREF='$3'>$3</A>");


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();
}
function level(experience,membercode,username,moderated)
{
if (membercode=='0'){levelname="尚未激活";levelimage="<img src=images/level/1.gif>";}
else
if (membercode=='2'){levelname="VIP会员";levelimage="<img src=images/level/20.gif>";}
else
if (membercode=='4'){levelname="管 理 员";levelimage="<img src=images/level/19.gif>";}
else
if (membercode=='5'){levelname="社区区长";levelimage="<img src=images/level/20.gif>";}
else
if (membercode=='3'){levelname="论坛版主";levelimage="<img src=images/level/18.gif>";}
else
if(moderated.indexOf("|"+username+"|") != -1 && moderated!=""){levelname="论坛版主";levelimage="<img src=images/level/18.gif>";}
else
if (experience< 100){levelname="列 兵";levelimage="<img src=images/level/1.gif>";}
else
if (experience< 501){levelname="上等兵";levelimage="<img src=images/level/2.gif>";}
else
if (experience< 1301){levelname="下 士";levelimage="<img src=images/level/3.gif>";}
else
if (experience< 2601){levelname="中 士";levelimage="<img src=images/level/4.gif>";}
else
if (experience< 4501){levelname="上 士";levelimage="<img src=images/level/5.gif>";}
else
if (experience< 7001){levelname="少 尉";levelimage="<img src=images/level/6.gif>";}
else
if (experience< 11001){levelname="中 卫";levelimage="<img src=images/level/7.gif>";}
else
if (experience< 19001){levelname="上 尉";levelimage="<img src=images/level/8.gif>";}
else
if (experience< 30001){levelname="少 校";levelimage="<img src=images/level/9.gif>";}
else
if (experience< 45001){levelname="中 校";levelimage="<img src=images/level/10.gif>";}
else
if (experience< 65001){levelname="上 校";levelimage="<img src=images/level/11.gif>";}
else
if (experience< 90001){levelname="大 校";levelimage="<img src=images/level/12.gif>";}
else
if (experience> 90000){levelname="少 将";levelimage="<img src=images/level/13.gif>";}
return('');
}

//读取COOKIE
function getCookie (CookieName) { 
var CookieString = document.cookie; 
var CookieSet = CookieString.split (';'); 
var SetSize = CookieSet.length; 
var CookiePieces 
var ReturnValue = ""; 
var x = 0; 
for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) { 
CookiePieces = CookieSet[x].split ('='); 

if (CookiePieces[0].substring (0,1) == ' ') { 
CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length); 
}

if (CookiePieces[0] == CookieName) {
ReturnValue = CookiePieces[1];
var value =ReturnValue
}


}
return value;
}