document.writeln("<table width=98% height=100% cellpadding=2 cellspacing=0><tr><td align=left>");

//var FormatTextlist="粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 RemoveFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|插入超链接 createLink|去掉超链接 Unlink|"
var FormatTextlist="粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 RemoveFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|插入超链接 createLink|去掉超链接 Unlink"
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=htmledit/images/"+TextName[1]+".gif alt="+TextName[0]+" style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\" onClick=FormatText('"+TextName[1]+"')> ");
}
}

document.writeln("<img src=htmledit/images/fbcolor.gif alt=\"突出颜色\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\" onClick=BackColor()>");
document.writeln("<img src=htmledit/images/fgcolor.gif alt=\"字体颜色\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onClick=foreColor()>");
document.writeln("<img src=htmledit/images/replace.gif alt=\"替换\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onClick=replace()>");
document.writeln("<img src=htmledit/images/img.gif alt=\"插入图片\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onClick=img()>");
//document.writeln("<img alt=\"插入FLASH文件\" src=htmledit/images/swf.gif align=absmiddle style=cursor:hand onclick=flash()>");
document.writeln("<img alt=\"插入Media Player文件\" src=htmledit/images/wmv.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=MediaPlayer()>");
//document.writeln("<img alt=\"插入RealPlayer文件\" src=htmledit/images/rm.gif align=absmiddle style=cursor:hand onclick=RealPlay()>");
document.writeln("<img alt=\"插入表情\" src=htmledit/images/em.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=em()>");
document.writeln("<img alt=\"清理代码\" src=htmledit/images/CleanCode.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=CleanCode()>");
//document.writeln("<img alt=\"在线帮助\" src=htmledit/images/help.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=help()>");
document.writeln("</td></tr><tr><td height=100%><iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></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"}
IframeID.document.open();
IframeID.document.write ('<script>i=0;function ctrlenterkey(eventobject){if(event.ctrlKey && window.event.keyCode==13 && i==0){i=1;parent.document.form1.remenu.value=document.body.innerHTML;parent.document.form1.submit();parent.document.form1.submit1.disabled=true;}}<\/script><body onkeydown=ctrlenterkey()>');
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.innerHTML=document.getElementById("remenu").value;
IframeID.document.body.style.fontSize="10pt";


function em(){
var arr = showModalDialog("htmledit/Emotion.htm", "", "dialogWidth:18em; dialogHeight:11em; 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("最大字符为 "+5000000+ " 字节\n您的内容已有 "+IframeID.document.body.innerHTML.length+" 字节");}

function CheckForm(form){
var title;
title=form1.blogtitle.value;
title=title.replace(/(^\s*)|(\s*$)/g,"");  //去除标题左右两边的空格


if (title.length<=5||title.length>=45){alert("日记标题范围5到45个字符！");form1.blogtitle.focus();return false;}
if (form1.writedate.value.length<=0){alert("时间不能为空！");form1.writedate.focus();return false;}
if (form1.blogtag.value.length<=0){alert("标签不能为空！");form1.blogtag.focus();return false;}
form.remenu.value=IframeID.document.body.innerHTML; 
MessageLength=IframeID.document.body.innerHTML.length;
copyText1(form.remenu); //新增复制内容到剪贴板中
if(MessageLength<2){alert("文章内容不能小于2个字符！");return false;}
if(MessageLength>5000000){alert("文章内容不能超过5000000个字符！");return false;}
document.form1.submit1.disabled = true;
}
//以下新加
function copyText1(obj) {
	clipboardData.setData('Text',obj.value);
}
//以上新加

function yinyong(obj) {
	IframeID.document.body.innerHTML="[quote]"+obj+"[/quote]";
	IframeID.focus();
}

function BackColor()
{
  var arr = showModalDialog("htmledit/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("htmledit/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("htmledit/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 = Ftbbs_code(con,a,b,true);
		}else{
			con = Ftbbs_code(con,a,b);
		}
		IframeID.document.body.innerHTML = con;
	}
	else IframeID.focus();
}
function Ftbbs_code(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("请输入图片文件URL地址:","http://");
//if(!url || url=="http://") return;
//IframeID.focus();
//sel=IframeID.document.selection.createRange();
//sel.pasteHTML("<img src="+url+" border=0 resize=1 vspace=5>");
//}
function img()
{
  var range = IframeID.document.selection.createRange();
  var arr = showModalDialog("htmledit/img.htm", "", "dialogWidth:31em; dialogHeight:13em; help: no; scroll: no; status: no");  
  if (arr != null){
    IframeID.focus()
    var ss=arr.split("$$$");
	content=IframeID.document.body.innerHTML;
	content=content+ss[0];
	IframeID.document.body.innerHTML=content;
	IframeID.focus();
  }
  IframeID.focus();
}

function RealPlay(){
var arr = showModalDialog("htmledit/RealPlay.htm", "", "dialogWidth:22em; dialogHeight:10em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function MediaPlayer(){
var arr = showModalDialog("htmledit/MediaPlayer.htm", "", "dialogWidth:22em; dialogHeight:10em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function flash(){
var arr = showModalDialog("htmledit/flash.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function help()
{
	var arr=showModalDialog("htmledit/help.html",window, "dialogWidth:23em; dialogHeight:11em; status:0; help:0");
}