function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}
function getCookieVal (offset) {var endstr=document.cookie.indexOf (";",offset);if (endstr==-1) endstr=document.cookie.length;return unescape(document.cookie.substring(offset, endstr));} 
function GetCookie (name){var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i = 0;while (i<clen){var j=i+alen;if (document.cookie.substring(i,j)==arg) return getCookieVal (j);i = document.cookie.indexOf(" ",i)+1;if (i==0) break;} return null;} 
function DeleteCookie (name) {var exp=new Date(); exp.setTime (exp.getTime()-1); var cval=GetCookie (name); document.cookie=name+"="+cval+"; expires="+exp.toGMTString();}
var currentpos,timer; 
function initialize() { timer=setInterval("scrollwindow()",20);} 
//function sc(){clearInterval(timer);}
function scrollwindow() {currentpos=document.body.scrollTop;window.scroll(0,++currentpos);if (currentpos != document.body.scrollTop) sc();} 
//document.onmousedown=sc
//document.ondblclick=initialize
ie = (document.all)? true:false
if (ie){function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.FORM.submit();}}}
clckcnt = 0;
function clckcntr() {clckcnt++;if(clckcnt > 1) {if(clckcnt > 2) { return false; }alert('贴子已经发出了......\n\n' + '请等待片刻......\n\n' + '不要重复按提交键，谢谢！');return false;}return true;}
var nn = !!document.layers;
var ie = !!document.all;
if (nn) {netscape.security.PrivilegeManager.enablePrivilege("UniversalSystemClipboardAccess");  var fr=new java.awt.Frame();  var Zwischenablage = fr.getToolkit().getSystemClipboard();}
function copy(textarea){if (nn) {textarea.select();Zwischenablage.setContents(new java.awt.datatransfer.StringSelection(textarea.value), null);} else if (ie) {textarea.select();cbBuffer=textarea.createTextRange();cbBuffer.execCommand('Copy');}}
function paste(textarea){ if (nn) {var Inhalt=Zwischenablage.getContents(null); if (Inhalt!=null) textarea.value=Inhalt.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor);} else if (ie) {textarea.select(); cbBuffer=textarea.createTextRange(); cbBuffer.execCommand('Paste');}}
function openScript(url, width, height){var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=yes,status=yes' );}
function runEx(){var winEx = window.open("", "winEx", "width=300,height=200,status=yes,menubar=yes,scrollbars=yes,resizable=yes"); winEx.document.open("text/html", "replace"); winEx.document.write(unescape(event.srcElement.parentElement.children[2].value)); winEx.document.close(); }
//******************************默认设置定义******************************
tPopWait=50;		//停留tWait豪秒后显示提示
tPopShow=5000;		//显示tShow豪秒后关闭提示，1000为1秒
showPopStep=20;
popOpacity=90;		//提示框的透明度,百分比，数字越小越透明
fontcolor="#000000";
bgcolor="#ffffff";
bordercolor="#cccccc";

//******************************内部变量定义******************************
sPop=null;curShow=null;tFadeOut=null;tFadeIn=null;tFadeWaiting=null;

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText {  background-color: " + bgcolor + ";color:" + fontcolor + "; border: 2px " + bordercolor + " solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>");

function showPopupText()
{
  var o=event.srcElement;MouseX=event.x;MouseY=event.y;
  if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
    if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
  if(o.dypop!=sPop)
  {
    sPop=o.dypop;clearTimeout(curShow);clearTimeout(tFadeOut);clearTimeout(tFadeIn);clearTimeout(tFadeWaiting);  
    if(sPop==null || sPop=="")
    {
      dypopLayer.innerHTML="";dypopLayer.style.filter="Alpha()";dypopLayer.filters.Alpha.opacity=0;  
    }
    else
    {
      if(o.dyclass!=null) popStyle=o.dyclass 
      else popStyle="cPopText";
        curShow=setTimeout("showIt()",tPopWait);
    }
  }
}

function showIt()
{
  dypopLayer.className=popStyle;dypopLayer.innerHTML=sPop;
  popWidth=dypopLayer.clientWidth;popHeight=dypopLayer.clientHeight;
  if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
  else popLeftAdjust=0;
  if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
  else popTopAdjust=0;
  dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
  dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
  dypopLayer.style.filter="Alpha(Opacity=0)";fadeOut();
}

function fadeOut()
{
  if(dypopLayer.filters.Alpha.opacity<popOpacity)
  { dypopLayer.filters.Alpha.opacity+=showPopStep;tFadeOut=setTimeout("fadeOut()",1); }
  else
  { dypopLayer.filters.Alpha.opacity=popOpacity;tFadeWaiting=setTimeout("fadeIn()",tPopShow); }
}

function fadeIn()
{
  if(dypopLayer.filters.Alpha.opacity>0)
  { dypopLayer.filters.Alpha.opacity-=1;tFadeIn=setTimeout("fadeIn()",1); }
}
document.onmouseover=showPopupText;

function quickpost(event)
{
	if((event.ctrlKey && event.keyCode == 13)||(event.altKey && event.keyCode == 83))
	{
			document.form1.submit();
	}	
}


function EbbToPlayMv(url,width,height,playarea){
	var filetype;
	var str;
	filetype=EbbGetPlayMvFiletype(url);
	if(height==0||height==''||height=='undefined')
	{
		height=80;
	}
	if(width==0||width==''||width=='undefined')
	{
		width=400;
	}
	if(filetype=='swf')
	{
		str=EbbPlayFlash(url,width,height);
	}
	else if(filetype=='mp3'||filetype=='wmv'||filetype=='asf'||filetype=='wma'||filetype=='asx'||filetype=='mid'||filetype=='midi')
	{
		str=EbbPlayMediaplayer(url,width,height);
	}
	else if(filetype=='rm'||filetype=='ra'||filetype=='rmvb'||filetype=='mp4'||filetype=='mov'||filetype=='avi'||filetype=='wav'||filetype=='ram'||filetype=='mpg'||filetype=='mpeg')
	{
		str=EbbPlayRealplayer(url,width,height);
	}
	else if(filetype=='flv')
	{
		str=EbbPlayFlv(url,width,height);
	}
	else
	{
		str="不支持此格式影片";
	}
	document.getElementById(playarea).innerHTML=str;
	//window.ebbplayarea.innerHTML=str;
}

//取得扩展名
function EbbGetPlayMvFiletype(url){
	pos=url.lastIndexOf(".")+1;
	len=url.length;
	ext=url.substring(pos,len);
	return ext;
}

//返回说明文字
function EbbReturnPlaySay(url){
	var filetype;
	var say;
	filetype=EbbGetPlayMvFiletype(url);
	if(filetype=='swf')
	{
		say="&nbsp;<img src='../ebb_data/images/playswf.gif' border=0>&nbsp;<b>FLASH文件</b>";
	}
	else if(filetype=='mp3'||filetype=='wmv'||filetype=='asf'||filetype=='wma'||filetype=='asx'||filetype=='mid'||filetype=='midi')
	{
		say="&nbsp;<img src='../ebb_data/images/playwmp.gif' border=0>&nbsp;<b>Windows Media Player文件</b>";
	}
	else if(filetype=='rm'||filetype=='ra'||filetype=='rmvb'||filetype=='mp4'||filetype=='mov'||filetype=='avi'||filetype=='wav'||filetype=='ram'||filetype=='mpg'||filetype=='mpeg')
	{
		say="&nbsp;<img src='../ebb_data/images/playreal.gif' border=0>&nbsp;<b>Real Player文件</b>";
	}
	else if(filetype=='flv')
	{
		say="&nbsp;<img src='../ebb_data/images/playswf.gif' border=0>&nbsp;<b>FLV文件</b>";
	}
	else
	{
		say="&nbsp;<b>不支持此格式影片</b>";
	}
	return say;
}

//播放FLASH
function EbbPlayFlash(url,width,height){
	var p;
	p="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+url+"\"><param name=\"quality\" value=\"high\"><embed src=\""+url+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"></embed></object>";
	return p;
}

//播放mediaplayer
function EbbPlayMediaplayer(url,width,height){
	var p;
	var autostart=true;
	p="<object align=middle classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" class=\"OBJECT\" id=\"MediaPlayer\" width=\""+width+"\" height=\""+height+"\"><PARAM NAME=\"AUTOSTART\" VALUE=\""+autostart+"\"><param name=\"ShowStatusBar\" value=\"-1\"><param name=\"Filename\" value=\""+url+"\"><param name=\"volume\" value=\"0\"><embed type=\"application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" flename=\"mp\" src=\""+url+"\" width=\""+width+"\" height=\""+height+"\"></embed></object>";
	return p;
}

//播放realplayer
function EbbPlayRealplayer(url,width,height){
	var p;
	var autostart=true;
	p="<object classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" HEIGHT=\""+height+"\" ID=\"Player\" WIDTH=\""+width+"\" VIEWASTEXT><param NAME=\"_ExtentX\" VALUE=\"12726\"><param NAME=\"_ExtentY\" VALUE=\"8520\"><param NAME=\"AUTOSTART\" VALUE=\""+autostart+"\"><param NAME=\"SHUFFLE\" VALUE=\"0\"><param NAME=\"PREFETCH\" VALUE=\"0\"><param NAME=\"NOLABELS\" VALUE=0><param NAME=CONTROLS VALUE=ImageWindow><param NAME=CONSOLE VALUE=_master><param NAME=LOOP VALUE=0><param NAME=NUMLOOP VALUE=0><param NAME=CENTER VALUE=0><param NAME=MAINTAINASPECT VALUE=\""+url+"\"><param NAME=BACKGROUNDCOLOR VALUE=\"#000000\"></object><br><object CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" HEIGHT=32 ID=\"Player\" WIDTH=\""+width+"\" VIEWASTEXT><param NAME=_ExtentX VALUE=18256><param NAME=_ExtentY VALUE=794><param NAME=AUTOSTART VALUE=\""+autostart+"\"><param NAME=SHUFFLE VALUE=0><param NAME=PREFETCH VALUE=0><param NAME=NOLABELS VALUE=0><param NAME=CONTROLS VALUE=controlpanel><param NAME=CONSOLE VALUE=_master><param NAME=LOOP VALUE=0><param NAME=NUMLOOP VALUE=0><param NAME=CENTER VALUE=0><param NAME=MAINTAINASPECT VALUE=0><param NAME=BACKGROUNDCOLOR VALUE=\"#000000\"><param NAME=SRC VALUE=\""+url+"\"></object>";
	return p;
}

//播放flv
function EbbPlayFlv(url,width,height){
	var p;
	var autostart=true;
	p="<object type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\" wmode=\"transparent\" data=\""+url+"\"><param name=\"movie\" value=\""+url+"\" /><param name=\"wmode\" value=\"transparent\" /> </object>";
	return p;
}

//播放器界面
function EbbPlayTemp(url,width,height,playarea){
	document.write("<table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#DDDDDD'><tr><td width='76%' height='25'>&nbsp;"+EbbReturnPlaySay(url)+"</td><td width='24%'><div align='right'>[<a href='"+url+"'><b>点击下载</b></a>]&nbsp;&nbsp;</div></td></tr><tr><td height='36' colspan='2' bgcolor='#FFFFFF'><div align='center' id='"+playarea+"'><a href='#EmpireCMS' onclick=\"javascript:EbbToPlayMv('"+url+"','"+width+"','"+height+"','"+playarea+"');\"><font color=red>点击播放</font></a></div></td></tr></table>");
}

function EbbInStr(obj,str){
	var ie=(document.all)?true:false;
	if(ie)
	{
		obj.focus();
		var r=document.selection.createRange();
		r.text=str;
	}
	else
	{
		document.form1.threadtext.value+=str;
	}
}


//运行代码
var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function copycode(obj) {
	if(is_ie && obj.style.display != 'none') {
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		rng.scrollIntoView();
		rng.select();
		rng.execCommand("Copy");
		rng.collapse(false);
	}
}
function runCode(obj) {
        var winname = window.open('', "_blank", '');
        winname.document.open('text/html', 'replace');
		winname.opener = null // 防止代码对论坛页面修改
        winname.document.write(obj.value);
        winname.document.close();
}
function saveCode(obj) {
        var winname = window.open('', '_blank', 'top=10000');
        winname.document.open('text/html', 'replace');
        winname.document.write(obj.value);
        winname.document.execCommand('saveas','','code.htm');
        winname.close();
}