function Dvbbs_CopyData(hiddenid)
{
	ischeck=true
	document.Dvform.Submit.disabled=true;
	d = IframeID.document;
	if(Dvbbs_bTextMode!=1){
		cont=d.body.innerText;
	}else{cont = d.body.innerHTML;}
	cont = Dvbbs_correctUrl(cont);
	cont = Dvbbs_cleanHtml(cont);
	//代码过滤及JS提取

	document.getElementById(hiddenid).value = cont;
	//alert(document.getElementById(hiddenid).value)
}
function Dvbbs_formatimg()
{
	if (Dvbbs_bIsIE5){
		var tmp=IframeID.document.body.all.tags("IMG");
	}else{
		var tmp=IframeID.document.getElementsByTagName("IMG");
	}
	for(var i=0;i<tmp.length;i++){
		var tempstr='';
		if(tmp[i].align!=''){tempstr=" align="+tmp[i].align;}
		if(tmp[i].border!=''){tempstr=tempstr+" border="+tmp[i].border;}
		tmp[i].outerHTML="<IMG src=\""+tmp[i].src+"\""+tempstr+">"
	}
}
function Dvbbs_correctUrl(cont)
{
	var regExp;
	//var url=location.href.substring(0,location.href.lastIndexOf("/")+1);
	//cont=Dvbbs_rCode(cont,location.href+"#","#");
	//cont=Dvbbs_rCode(cont,url,"");
	regExp = /<a([^>]*) href\s*=\s*([^\s|>]*)([^>]*)/gi
	cont = cont.replace(regExp, "<a href=$2 target=\"_blank\" ");
	regExp = /<a([^>]*)><\/a>/gi
	cont = cont.replace(regExp, "");
	return cont;
}
function Dvbbs_FilterScript(content)
{
	//content = Dvbbs_rCode(content, 'javascript:', '<b>javascript</b> :');
	content = content.replace(/<(\w[^div|>]*) class\s*=\s*([^>|\s]*)([^>]*)/gi,"<$1$3") ;
	content = content.replace(/<(\w[^font|>]*) style\s*=\s*\"[^\"]*\"([^>]*>)/gi,"<$1 $2") ;
	content = content.replace(/<(\w[^>]*) lang\s*=\s*([^>|\s]*)([^>]*)/gi,"<$1$3") ;
	var RegExp = /<(script[^>]*)>(.*)<\/script>/gi;
	content = content.replace(RegExp, "[code]&lt;$1&gt;<br>$2<br>&lt;script&gt;[\/code]");
	RegExp = /<(\w[^>|\s]*)([^>]*)(on(finish|mouse|Exit|error|click|key|load|change|focus|blur))(.[^>]*)/gi;
	content = content.replace(RegExp, "<$1")
	RegExp = /<(\w[^>|\s]*)([^>]*)(&#|window\.|javascript:|js:|about:|file:|Document\.|vbs:|cookie| name| id)(.[^>]*)/gi;
	content = content.replace(RegExp, "<$1")
	//alert(content);
	return content;
}
function Checkpostdata()
{
	if (ischeck==false)
	{
		return false
	}
}
function Checkdata(){
	document.getElementById("constr").innerHTML="";
	ischeck=true;
	CheckUbbUse('UserName',1,document.getElementById('Body').value)	//定员帖检查
	if(Diary){
		document.getElementById("titlestr").innerHTML="";
		if (document.Dvform.title.value.length==0){
			document.getElementById("titlestr").innerHTML=" <font color=\"#FF0000\">←您忘记填写标题</font>"
			document.Dvform.title.focus();
			ischeck=false
		}
		if (document.Dvform.sTime.value.length==0){
			document.getElementById("Timestr").innerHTML=" <font color=\"#FF0000\">←您忘记填写日期</font>"
			document.Dvform.sTime.focus();
			ischeck=false
		}
		if (document.Dvform.title.value.length>Maxtitlelength){
			document.getElementById("titlestr").innerHTML=" <font color=\"#FF0000\">←标题长度不能大于"+Maxtitlelength+"</font>"
			document.Dvform.title.focus();
			ischeck=false
		}
	}
	if (document.getElementById('Body').value.length==0){
		document.getElementById("constr").innerHTML=" <font color=\"#FF0000\">←请填写内容</font>"
		IframeID.focus();
		ischeck=false
	}else if (document.getElementById('Body').value.length>MaxConlength){
		document.getElementById("constr").innerHTML=" <font color=\"#FF0000\">←内容长度不能大于"+MaxConlength+",您已经输入了"+document.getElementById('body').value.length+"个字</font>"
		IframeID.focus();
		ischeck=false
	}
	if (ischeck==false){
		document.Dvform.Submit.disabled=false;
		document.Dvform.Submit2.disabled=false;
	}
}

function Dvbbs_cleanHtml(content)
{
	content = content.replace(/<p>&nbsp;<\/p>/gi,"")
	content = content.replace(/<p><\/p>/gi,"<p>")
	content = content.replace(/<div><\/\1>/gi,"")
	content = content.replace(/<p>/,"<br>")
	content = content.replace(/(<(meta|iframe|frame|span|tbody|layer)[^>]*>|<\/(iframe|frame|meta|span|tbody|layer)>)/gi, "");
	content = content.replace(/<\\?\?xml[^>]*>/gi, "") ;
	content = content.replace(/o:/gi, "");
	content = content.replace(/&nbsp;/gi, " ");
	if(Dvbbs_bTextMode!=1){
	content = content.replace(/<img([^>]*) (src\s*=\s*([^\s|>])*)([^>]*)>/gi,"<img $2>");
	}
	//content = content.replace(/\r\n/g, '');
    //content = content.replace(/\n/g, '');
    //content = content.replace(/\r/g, '');
	//alert(content);
return content;
}

//选择内容替换文本
function Dvbbs_InsertSymbol(str1)
{
	IframeID.focus();
	if (Dvbbs_bIsIE5) Dvbbs_selectRange();
	Dvbbs_edit.pasteHTML(str1);
}
//选择事件
function Dvbbs_selectRange(){
	Dvbbs_selection =	IframeID.document.selection;
	Dvbbs_edit		=	Dvbbs_selection.createRange();
	Dvbbs_RangeType =	Dvbbs_selection.type;
}
function insertSpecialChar()
{
	var arr = showModalDialog("images/specialchar.html", "","dialogWidth:25em; dialogHeight:15em; status:0; help:0");
	if (arr != null) Dvbbs_InsertSymbol(arr);
	IframeID.focus() ;
}
function Dvbbs_replace()
{
	var arr = showModalDialog("images/replace.html", "", "dialogWidth:16.5em; dialogHeight:13em; status:0; help:0");
	if (arr != null){
		var ss;
		ss = arr.split("*")
		a = ss[0];
		b = ss[1];
		i = ss[2];
		con = IframeID.document.body.innerHTML;
		if (i == 1)
		{
			con = Dvbbs_rCode(con,a,b,true);
		}else{
			con = Dvbbs_rCode(con,a,b);
		}
		IframeID.document.body.innerHTML = con;
	}
	else IframeID.focus();
}
function Dvbbs_rCode(s,a,b,i){
	//s原字串，a要换掉pattern，b换成字串，i是否区分大小写
	a = a.replace("?","\\?");
	if (i==null)
	{
		var r = new RegExp(a,"gi");
	}else if (i) {
		var r = new RegExp(a,"g");
	}
	else{
		var r = new RegExp(a,"gi");
	}
	return s.replace(r,b); 
}
//预览
function Dvbbs_View(){
	if (Dvbbs_bTextMode!==1) {
		cont=IframeID.document.body.innerText;
	} else {
		cont=IframeID.document.body.innerHTML;
	}
	bodyTag="<html><head><style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\" >";
	preWin=window.open('preview','','left=0,top=0,width=550,height=400,resizable=1,scrollbars=1, status=1, toolbar=1, menubar=0');
	preWin.document.open();
	preWin.document.write(bodyTag);
	preWin.document.write(cont);
	preWin.document.write("</body></html>");
	preWin.document.close();
	preWin.document.title="Preview";
	preWin.document.charset=Dvbbs_charset;
}
function Dvbbs_forurl()
{
	var arr = showModalDialog("images/url.htm", "", "dialogWidth:30em; dialogHeight:10em; status:0; help:0");
	if (arr != null){
		var ss;
		ss=arr.split("*")
		path=ss[0];
		row=ss[1];
		var string;

		if (row!="")
		{
			string="[url="+path+"]"+row+"[/url]"
		}
		 else 
		{
			string="[url]"+path+"[/url]"
		} 
		IframeID.document.body.innerHTML+=string;
	}
	else IframeID.focus();
}
function Dvbbs_forimg()
{
	var arr = showModalDialog("images/img.htm", "", "dialogWidth:30em; dialogHeight:10em; status:0; help:0");
	if (arr != null){
		var ss;
		ss=arr.split("*")
		path=ss;
		var string;

			string="[img]"+path+"[/img]"

		IframeID.document.body.innerHTML+=string;
	}
	else IframeID.focus();
}