document.writeln("<table width=100% height=100% cellpadding=2 cellspacing=0><tr><td align=left>");
var FormatTextlist="粗体 bold|倾斜 italic|下划线 underline|删除线 strikethrough|删除文字格式 RemoveFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|两端对齐 justifyfull|剪切 cut|复制 copy|粘贴 paste|撤消 undo|恢复 redo"
var list= FormatTextlist.split ('|'); 
for(i=0;i<list.length;i++) {
if (list[i]=="<br>"){document.write("<br>");
}else{
var TextName= list[i].split (' '); 
document.write(" <img align=absmiddle src=images2/ybb/"+TextName[1]+".gif alt="+TextName[0]+" style=cursor:hand onClick=FormatText('"+TextName[1]+"')> ");
}
}
document.writeln("<img src=images2/ybb/img.gif alt=\"插入图片\" align=absmiddle style=cursor:hand onClick=img()>");
document.writeln("<img alt=\"插入表情\" src=images2/ybb/em.gif align=absmiddle style=cursor:hand onclick=em()>");
document.writeln("<img alt=\"清理代码\" src=images2/ybb/CleanCode.gif align=absmiddle style=cursor:hand onclick=CleanCode()>");
document.writeln("</td></tr><tr><td height=100%><iframe ID=HtmlEditor width=99% height=100% marginwidth=1 marginheight=1 border=0 frameborder=0 STYLE='border:#a4b6d7 1px solid;'></iframe></td></tr><tr></tr></table>");

if (document.all){var IframeID=frames["HtmlEditor"];}else{var IframeID=document.getElementById("HtmlEditor").contentWindow;}
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){IframeID.document.designMode="On"}
var s="<body style='background-image: URL(/cmzxw/images2/end_n_bg9.gif);background-position: center;background-repeat: no-repeat; background-attachment: fixed;'></body>";
IframeID.document.open();
IframeID.document.write (s);
IframeID.document.write ('<script>i=0;function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13 && i==0){i=1;parent.document.form1.nl.value=document.body.innerHTML;parent.document.form1.submit();parent.document.form1.submit1.disabled=true;}}<\/script><body onkeydown=ctlent()>');
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.innerHTML=document.getElementById("nl").value;
IframeID.document.body.style.fontSize="10pt";


function em(){
var arr = showModalDialog("Emotion.htm", "", "dialogWidth:20em; dialogHeight:9.5em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}


function CleanCode(){
var body = IframeID.document.body;
var html = IframeID.document.body.innerHTML;
html = html.replace(/\<p>/gi,"[$p]");
html = html.replace(/\<\/p>/gi,"[$\/p]");
html = html.replace(/\<br>/gi,"[$br]");
html = html.replace(/\<[^>]*>/g,"");
html = html.replace(/\[\$p\]/gi,"<p>");
html = html.replace(/\[\$\/p\]/gi,"<\/p>");
html = html.replace(/\[\$br\]/gi,"<br>");
IframeID.document.body.innerHTML = html;
}


function FormatText(command,option){IframeID.focus();IframeID.document.execCommand(command,true,option);}

function CheckLength(){alert("最大字符为 "+3000+ " 字节\n您的内容已有 "+IframeID.document.body.innerHTML.length+" 字节");}

function emoticon(theSmilie){
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src=images2/Emotions/"+theSmilie+".gif>");
}

function DoTitle(addTitle) {
var revisedTitle;var currentTitle = document.form1.topic.value;revisedTitle = addTitle+currentTitle;document.form1.topic.value=revisedTitle;document.form1.topic.focus();
}

function CheckForm(form){
form.nl.value=IframeID.document.body.innerHTML;
MessageLength=IframeID.document.body.innerHTML.length;
if(MessageLength<10){alert("文章内容不能小于5个字！");return false;}
if(MessageLength>3000){alert("文章内容不能超过3000个字！");return false;}
}

function Gopreview()
{
document.preview.nl.value=IframeID.document.body.innerHTML; 
window.open('', 'preview_page', 'resizable,scrollbars,width=750,height=450');
document.preview.submit()
}

function BackColor()
{
  var arr = showModalDialog("inc/selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
  if (arr != null) FormatText('BackColor', arr);
  else IframeID.focus();
}

function foreColor()
{
  var arr = showModalDialog("inc/selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
  if (arr != null) FormatText('forecolor', arr);
  else IframeID.focus();
}

//////替换内容
function replace()
{
  var arr = showModalDialog("inc/replace.html", "", "dialogWidth:22em;dialogHeight:10em;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 = bbsxp_rCode(con,a,b,true);
		}else{
			con = bbsxp_rCode(con,a,b);
		}
		IframeID.document.body.innerHTML = con;
	}
	else IframeID.focus();
}
function bbsxp_rCode(s,a,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 img(){
url=prompt("请输入图片文件地址:","http://");
if(!url || url=="http://") return;
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src='"+url+"'>");
}

function RealPlay(){
var arr = showModalDialog("inc/RealPlay.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function MediaPlayer(){
var arr = showModalDialog("inc/MediaPlayer.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function flash(){
var arr = showModalDialog("inc/flash.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
function hh()
		{
		window.open("voidlist.aspx?id=<%=Label8.Text%>","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=300,height=500,left=100,top=80");
		return false;
		}
		function resizepic(thispic)
{
if(thispic.width>500) thispic.width=500;
}
//无级缩放图片大小
function bbimg(o)
{
  var zoom=parseInt(o.style.zoom, 10)||100;
  zoom+=event.wheelDelta/12;
  
  if (zoom>0) o.style.zoom=zoom+'%';
	return false;
  //o.style.width=10%;
  
}
function copy(ob){
//var obj=findObj(ob); if (obj) { 
//obj.select();js=obj.createTextRange();js.execCommand("Copy");}
window.clipboardData.setData("Text",ob); 
alert("复制成功！！你可以通过QQ或其它方式发送给你朋友");
}
function cut(ob){
var obj=findObj(ob); if (obj) { 
obj.select();js=obj.createTextRange();js.execCommand("Cut");}
}
function findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
