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Ҫpatternbִ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();
}