function ybbcode(temp) {
var regExp = /<img([^>]*) (src\s*=)(\s*([^\s|>])*)([^>]*)>/gi
temp = temp.replace(regExp,"<a href=$3 target=\"_blank\" ><img src=$3 border=0 onmousewheel='return yuzi_img(event,this)' onload='javascript:if(this.width>body.clientHeight)this.width=body.clientHeight-100'></a> ");
regExp = /<a([^>]*) href\s*=\s*([^\s|>]*)([^>]*)/gi
temp = temp.replace(regExp, "<a href=$2 target=\"_blank\" ");
temp = temp.replace(/(\[script\])([^]]*)(\[\/script\])/ig,"<div class=A4><br>$2</div>");
if (getCookie('ybbcode')!='0'){ //是否打开YBB代码
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(/\[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(/(\[QUOTE\])(.*)(\[\/QUOTE\])/ig,"<BLOCKQUOTE><strong>引用</strong>：<HR Size=1>$2<HR SIZE=1><\/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(/(\[fly\])(.[^\[]*)(\[\/fly\])/ig,"<MARQUEE scrollAmount=3 behavior=alternate width='90%'><font size='3'>$2<\/font><\/MARQUEE>");
temp = temp.replace(/(\[move\])(.[^\[]*)(\[\/move\])/ig,"<MARQUEE scrollAmount=3><font size='3'>$2<\/font><\/MARQUEE>");
temp = temp.replace(/(\[glow\])(.[^\[]*)(\[\/glow\])/ig,"<TABLE style='FILTER: glow(color=red, strength=2)' width=255><font size='3'>$2<\/font><\/TABLE>");
temp = temp.replace(/(\[shadow\])(.[^\[]*)(\[\/shadow\])/ig," <TABLE style='FILTER: shadow(color=blue, direction=1 ,strength=2)' width=255><font size='3'>$2<\/font><\/TABLE>");
temp = temp.replace(/(\[blue\])(.[^\[]*)(\[\/blue\])/ig,"<span STYLE='position:relative; width:100%; height:50; filter:glow(Color=#7ec0ee,Strength=2); margin-left:8px'>$2<\/span>");
temp = temp.replace(/(\[yellow\])(.[^\[]*)(\[\/yellow\])/ig,"<font style='cursor:hand;width:100%;color:ffff00;filter:glow(color=red, strength=2)'>$2<\/font>");
temp = temp.replace(/(\[black\])(.[^\[]*)(\[\/black\])/ig,"<SPAN style='FONT-SIZE: 9pt; FILTER: glow(color=#909090,strength=0) shadow(color:#000000,direction=125); WIDTH: 100%; COLOR: white; LINE-HEIGHT: 25pt; POSITION: relative'><SPAN class=shadow1><FONT size='3' color=#ffffff>$2<\/FONT><\/SPAN><\/SPAN>");
temp = temp.replace(/(\[white\])(.[^\[]*)(\[\/white\])/ig,"<table style='FILTER:glow(color=a4b6d7)'><b><font color=ffffff style=font-size:12pt>$2<\/font><\/b><\/table>");
temp = temp.replace(/(\[red\])(.[^\[]*)(\[\/red\])/ig,"<table width='86%' border='0' cellspacing='0' cellpadding='0' ><td align=left style='font-size: 12pt; COLOR: #ffffff; FILTER: glow(color=000000,strength=2) dropshadow(color=#ff0000,offx=1, offy=1, positive=2); HEIGHT: 20px; MARGIN: 0px; TEXT-DECORATION: none'>$2<\/td><\/tr><\/table>");
temp = temp.replace(/(\[black2\])(.[^\[]*)(\[\/black2\])/ig,"<TABLE ><TBODY><TD style='FILTER: glow(color=#000000,strength=2)'><FONT size='3' color=#ffffff>$2<\/FONT><\/TD><\/tbody><\/table>");
temp = temp.replace(/(\[glow2\])(.[^\[]*)(\[\/glow2\])/ig,"<TABLE width=255><span style='behavior:url(inc/font.htc)'>$2</span><\/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 "<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' wmode=transparent>");
}

if (getCookie('ybbimg')!='0'){  //是否打开[IMG]代码
temp = temp.replace(/(\[IMG\])([^]]*)(\[\/IMG\])/ig,"<A TARGET=_blank HREF='$2'><img border=0 src='$2' onmousewheel='return yuzi_img(event,this)' onload='javascript:if(this.width>body.clientHeight)this.width=body.clientHeight-100'></A> ");
temp = temp.replace(/(\[imgs\])([^]]*)(\[\/imgs\])/ig,"<img border=0 src='$2' onload='javascript:if(this.width>120)this.width=120;if(this.height>120)this.height=120;'> ");
}

if (getCookie('ybbbrow')!='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();
}

//放大缩小图片
function yuzi_img(e, o)
{
var zoom = parseInt(o.style.zoom, 10) || 100;
zoom += event.wheelDelta / 12;
if (zoom > 0) o.style.zoom = zoom + '%';
return false;
}

 

