var sCurrMode
StyleEditorHeader = "<script>i=0;function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13 && i==0){i=1;parent.document.myform.menu.value=document.body.innerHTML;parent.document.myform.submit();parent.document.myform.B1.disabled=true;}}<\/script><style>p{margin-top:3;margin-bottom:3}</style><body onkeydown=ctlent()>" ;
//根据浏览器类型选择编辑器(飞天论坛编辑器作者:陈惠添)
if (navigator.appName == "Microsoft Internet Explorer"){
HtmlEdit()
var IframeID=frames["HtmlEditor"];
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){IframeID.document.designMode="On"}
IframeID.document.open();
IframeID.document.write (StyleEditorHeader);
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.innerHTML=document.getElementById("menu").value;
IframeID.document.body.style.fontSize="10pt";
}else{
document.write ('<iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></iframe>')
HtmlEditor=document.getElementById("HtmlEditor").contentWindow;
HtmlEditor.document.designMode="On"
HtmlEditor.document.open();
HtmlEditor.document.close();
HtmlEditor.document.body.contentEditable = "True";
}

function HtmlEdit(){
document.writeln("<table width=100% height=100% cellpadding=2 cellspacing=0>");
document.writeln("<tr id=EditButton style=DISPLAY:block class=\"maintbtr1\"><td align=left><select style=\"width:55px\" onChange=\"FormatText('FormatBlock',this[this.selectedIndex].value);\"><option selected>段落</option><option value=\"&lt;P&gt;\">正文</option><option value=\"&lt;H1&gt;\">标题一</option><option value=\"&lt;H2&gt;\">标题二</option><option value=\"&lt;H3&gt;\">标题三</option><option value=\"&lt;H4&gt;\">标题四</option><option value=\"&lt;H5&gt;\">标题五</option><option value=\"&lt;H6&gt;\">标题六</option><option value=\"&lt;PRE&gt;\">预设格式</option></select> <select style=\"width:110px\" name=\"selectFont\" onChange=\"FormatText('fontname', selectFont.options[selectFont.selectedIndex].value);\"><option selected>字体<option value=\"removeFormat\">默认字体<option value=\"宋体\">宋体<option value=\"黑体\">黑体<option value=\"隶书\">隶书<option value=\"幼圆\">幼圆<option value=\"楷体_GB2312\">楷体<option value=\"仿宋_GB2312\">仿宋<option value=\"新宋体\">新宋体<option value=\"华文彩云\">华文彩云<option value=\"华文仿宋\">华文仿宋<option value=\"华文新魏\">华文新魏<option value=\"Arial\">Arial<option value=\"Arial Black\">Arial Black<option value=\"Arial Narrow\">Arial Narrow<option value=\"Century\">Century<option value=\"Courier New\">Courier New<option value=\"Georgia\">Georgia<option value=\"Impact\">Impact<option value=\"Lucida Console\">Lucida Console<option value=\"MS Sans Serif\">MS Sans Serif<option value=\"System\">System<option value=\"Symbol\">Symbol<option value=\"Tahoma\">Tahoma<option value=\"Times New Roman\">Times New Roman&nbsp; &nbsp;<option value=\"Verdana\">Verdana<option value=\"Webdings\">Webdings<option value=\"Wingdings\">Wingdings</option></select> <select onChange=\"FormatText('fontsize',this[this.selectedIndex].value);\" name=\"D2\"><option class=\"heading\" selected>字体大小<option value=1>一号<option value=2>二号<option value=3>三号<option value=4>四号</option></select>");
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 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=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 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=RealPlay()>");
//document.writeln("<img alt=\"插入表情\" src=htmledit/images/qq.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=qq()>");
document.writeln("<img alt=\"插入表格\" src=htmledit/images/table.gif align=absmiddle style=cursor:hand  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=WBTB_fortable()>");
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=\"HTML编辑\" src=htmledit/images/ftbbshtml.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=html()><br>");

var FormatTextlist="全选 selectAll|取消选择 unselect|剪切 cut|复制 copy|粘贴 paste|删除当前选中区 Delete|插入超链接 createLink|去掉超链接 Unlink|粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 RemoveFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|两端对齐 justifyfull|编号 insertorderedlist|项目符号 InsertUnorderedList|减少缩进量 Outdent|增加缩进量 indent|撤消 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=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';\" 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 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()>");

//UBB Editor
document.writeln("<tr id=EditButton2 style=DISPLAY:none class=\"maintbtr1\"><td align=left><select style=\"width:110px\" name=\"FontName\" id=\"FontName\" onChange=\"ftbbs_ubb('face',this[this.selectedIndex].value);\"><option selected>字体<option value=\"removeFormat\">默认字体<option value=\"宋体\">宋体<option value=\"黑体\">黑体<option value=\"隶书\">隶书<option value=\"幼圆\">幼圆<option value=\"楷体_GB2312\">楷体<option value=\"仿宋_GB2312\">仿宋<option value=\"新宋体\">新宋体<option value=\"华文彩云\">华文彩云<option value=\"华文仿宋\">华文仿宋<option value=\"华文新魏\">华文新魏<option value=\"Arial\">Arial<option value=\"Arial Black\">Arial Black<option value=\"Arial Narrow\">Arial Narrow<option value=\"Century\">Century<option value=\"Courier New\">Courier New<option value=\"Georgia\">Georgia<option value=\"Impact\">Impact<option value=\"Lucida Console\">Lucida Console<option value=\"MS Sans Serif\">MS Sans Serif<option value=\"System\">System<option value=\"Symbol\">Symbol<option value=\"Tahoma\">Tahoma<option value=\"Times New Roman\">Times New Roman&nbsp; &nbsp;<option value=\"Verdana\">Verdana<option value=\"Webdings\">Webdings<option value=\"Wingdings\">Wingdings</option></select> <select id=\"Fontsize\" onchange=\"ftbbs_ubb('size',this[this.selectedIndex].value);\" name=\"D2\"><option class=\"heading\" selected>字体大小<option value=1>一号<option value=2>二号<option value=3>三号<option value=4>四号</option></select>");

var FormatTextlist="粗体 bold b|倾斜 italic i|下划线 underline u|左对齐 Justifyleft left|居中 JustifyCenter center|右对齐 JustifyRight right"
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';\" 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=ftbbs_ubb('"+TextName[2]+"')> ");
}
}
//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/createLink.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=Curl()>");
document.writeln("<img src=htmledit/images/email.gif alt=\"插入email链接\" 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=ftbbs_Signal('EMAIL')>");
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=ftbbs_Signal('IMG')>");
document.writeln("<img alt=\"插入FLASH文件\" src=htmledit/images/swf.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=Cswf()>");
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=Cwmv()>");
document.writeln("<img alt=\"插入RealPlayer文件\" src=htmledit/images/rm.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=Crm()>");
document.writeln("<img alt=\"移动字\" src=htmledit/images/maquee.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=ftbbs_ubb('move')>");
document.writeln("<img alt=\"引用\" src=htmledit/images/quote.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=ftbbs_ubb('QUOTE')>");

//UBB Editor End

//document.writeln("</td></tr><tr><td height=200%><iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></iframe></td></tr><tr></tr></table>");
document.writeln("</td></tr><tr><td height=100% colspan=6><iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></iframe></td></tr>");

document.writeln("<tr><td><table border=0 cellpadding=0 cellspacing=0 height=20>");
document.writeln("<tr class=\"maintbtr1\">");
document.writeln("<td width=5></td>");
document.writeln("<td class=StatusBarBtnON id=HtmlEditor_EDIT onclick=setMode('EDIT')><img style=cursor:pointer border=0 src=htmledit/images/ftbbsmodeedit.gif align=absmiddle></td>");
document.writeln("<td width=5></td>");
document.writeln("<td class=StatusBarBtnOff id=HtmlEditor_UBB onclick=setMode('UBB')><img style=cursor:pointer border=0 src=htmledit/images/ftbbsmodeubb.gif align=absmiddle></td>");
document.writeln("<td width=5></td>");
document.writeln("<td class=StatusBarBtnOff id=HtmlEditor_CODE onclick=setMode('CODE')><img style=cursor:pointer border=0 src=htmledit/images/ftbbsmodecode.gif align=absmiddle></td>");
document.writeln("<td width=5></td>");
document.writeln("<td class=StatusBarBtnOff id=HtmlEditor_VIEW onclick=setMode('VIEW')><img style=cursor:pointer border=0 src=htmledit/images/ftbbsmodepreview.gif width=50 height=15 align=absmiddle></td>");
document.writeln("<td width=5></td>");
document.writeln("<td align=right width=100%><a href=\"#\" title=\"恢复上次提交的数据\" onclick=copytohtml()>恢复数据</a> <img border=0 src=htmledit/images/+.gif align=absmiddle onclick=sizeChange(100) style=cursor:pointer alt='增大编辑区'> <img border=0 src=htmledit/images/-.gif align=absmiddle onclick=sizeChange(-100) style=cursor:pointer alt='减小编辑区'></td>");
document.writeln("</tr></table>");
document.writeln("</td></tr>");	
document.writeln("</table>");
}

// 调整编辑器的大小
function sizeChange(size){
	var obj=document.getElementById("HtmlEditor");
	obj.height = (parseInt(obj.offsetHeight) + size);
	if (parseInt(obj.offsetHeight)< 200 ){obj.height ="100%"}
}

// 设置编辑器的内容
function setHTML(html) {
	IframeID.document.body.innerText = html;
	switch (sCurrMode){
	case "CODE":
		HtmlEditor.document.open();
		HtmlEditor.document.write(html);
		HtmlEditor.document.close();
		HtmlEditor.document.body.innerText=html;
        HtmlEditor.document.body.style.fontSize="10pt";
		HtmlEditor.document.body.contentEditable="true";
		EditButton.style.display = 'none';
        EditButton2.style.display = 'none';
        break;
	case "UBB":
		HtmlEditor.document.open();
		HtmlEditor.document.write(html);
		HtmlEditor.document.close();
		HtmlEditor.document.body.innerText=html;
        HtmlEditor.document.body.style.fontSize="10pt";
		HtmlEditor.document.body.contentEditable="true";
		EditButton.style.display = 'none';
        EditButton2.style.display = 'block';
        break;
	case "EDIT":
		HtmlEditor.document.open();
		HtmlEditor.document.write(StyleEditorHeader+html);
        HtmlEditor.document.body.style.fontSize="10pt";
		HtmlEditor.document.close();
		HtmlEditor.document.body.contentEditable="true";
		EditButton.style.display = 'block';
        EditButton2.style.display = 'none';
        break;
	case "VIEW":
		HtmlEditor.document.open();
		HtmlEditor.document.write(StyleEditorHeader+html);
        HtmlEditor.document.body.style.fontSize="10pt";
		HtmlEditor.document.close();
		HtmlEditor.document.body.contentEditable="false";
		EditButton.style.display = 'none';
        EditButton2.style.display = 'none';
		break;

	}
}

// 改变模式：代码、编辑、预览
function setMode(NewMode){
	if (NewMode!=sCurrMode){
		switch(sCurrMode){
		case "CODE":
		     sBody = HtmlEditor.document.body.innerText;
			 break;
		case "UBB":
		     sBody = HtmlEditor.document.body.innerText;
			 break;
		case "EDIT":
		     sBody = HtmlEditor.document.body.innerHTML;
		      break;
		case "VIEW":
		     sBody = HtmlEditor.document.body.innerHTML;
		     break;
		default:
			sBody = IframeID.document.body.innerHTML;
			break;
		}
		// 换图片
		try{
			document.all["HtmlEditor_CODE"].className = "StatusBarBtnOff";
            document.all["HtmlEditor_UBB"].className = "StatusBarBtnOff";
			document.all["HtmlEditor_EDIT"].className = "StatusBarBtnOff";
			document.all["HtmlEditor_VIEW"].className = "StatusBarBtnOff";
			document.all["HtmlEditor_"+NewMode].className = "StatusBarBtnOn";
			}
		catch(e){
			}
		sCurrMode = NewMode;
		setHTML(sBody);
		
	}
}
// 取编辑器的内容
function getHTML() {
	var html;
	if(sCurrMode=="CODE"||sCurrMode=="UBB"){
		html = HtmlEditor.document.body.innerText;
        }else{
		html = HtmlEditor.document.body.innerHTML;
	}
	return html;
}

function em(){
var arr = showModalDialog("htmledit/Emotion.htm", "", "dialogWidth:20em; 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 emoticon(theSmilie){
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src=htmledit/Emotions/"+theSmilie+".gif>");
}

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

if (myform.BoardID_1.value==""){alert("请选择主论坛！");myform.BoardID_1.focus();return false;}
if (myform.BoardID_2.value==""){alert("请选择分论坛！");myform.BoardID_2.focus();return false;}
if (myform.title.value==""){alert("请填写主题！");myform.title.focus();return false;}
if (title.length<6){alert("贴子标题最少要6个字！");myform.title.focus();return false;}
if (title.length>45){alert("贴子标题最长是45个字！");myform.title.focus();return false;}
form.menu.value = getHTML();
//form.menu.value=IframeID.document.body.innerHTML; 
MessageLength=IframeID.document.body.innerHTML.length;
if(MessageLength<2){alert("文章内容不能小于2个字符！");IframeID.focus();return false;}
if(MessageLength>5000000){alert("文章内容不能超过5000000个字符！");return false;}
copyText1(HtmlEditor.document.body.innerText); //新增以文本形式复制内容到剪贴板中
document.myform.B1.disabled = true;
}

function CheckReForm(form){
form.menu.value = getHTML();
//form.menu.value=IframeID.document.body.innerHTML; 
MessageLength=IframeID.document.body.innerHTML.length;
if(MessageLength<2){alert("文章内容不能小于2个字符！");IframeID.focus();return false;}
if(MessageLength>5000000){alert("文章内容不能超过5000000个字符！");return false;}
copyText1(HtmlEditor.document.body.innerText); //新增以文本形式复制内容到剪贴板中
document.myform.B1.disabled = true;
}

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

if (myform.BoardID_1.value==""){alert("请选择主论坛！");myform.BoardID_1.focus();return false;}
if (myform.BoardID_2.value==""){alert("请选择分论坛！");myform.BoardID_2.focus();return false;}
if (myform.title.value==""){alert("请填写主题！");myform.title.focus();return false;}
if (title.length<6){alert("贴子标题最少要6个字！");myform.title.focus();return false;}
if (title.length>45){alert("贴子标题最长是45个字！");myform.title.focus();return false;}
if (myform.daynum.value==""){alert("有效期不能为空！");myform.daynum.focus();return false;}
if(isNaN(myform.daynum.value)){ alert("输入格式错误:天数只能输入数字.");myform.daynum.focus();myform.daynum.select();return false;}
form.menu.value = getHTML();
//form.menu.value=IframeID.document.body.innerHTML; 
MessageLength=IframeID.document.body.innerHTML.length;
if(MessageLength<2){alert("文章内容不能小于2个字符！");IframeID.focus();return false;}
if(MessageLength>5000000){alert("文章内容不能超过5000000个字符！");return false;}
copyText1(HtmlEditor.document.body.innerText); //新增以文本形式复制内容到剪贴板中
document.myform.B1.disabled = true;
}
//以下新加
function copyText1(obj) {
	clipboardData.setData('Text',obj);
}
function copytohtml() {
   var nl=clipboardData.getData("text");
   if(nl!=null){
   IframeID.document.body.innerHTML=nl;
   }else{
   IframeID.document.body.innerHTML="";
   }
}
//以上新加
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);
     if(sCurrMode=="UBB"){
	ftbbs_ubb("color",arr);
     }else{
	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("请输入图片文件地址:","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()
{
  IframeID.focus()
  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("$$$");
    range.pasteHTML(ss[0]);
  }
}

function RealPlay(){
var arr = showModalDialog("htmledit/RealPlay.htm", "", "dialogWidth:22em; dialogHeight:10.5em; 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:10.5em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function WBTB_fortable()
{
	//if (!WBTB_validateMode())	return;
	var arr = showModalDialog("htmledit/table.html", "", "dialogWidth:14.5em; dialogHeight:19em; status:0; help:0");
	
	if (arr != null)
	{
		var ss;
		ss=arr.split("*")
		row=ss[0];
		if (row=="") row=1;
		col=ss[1];
		if (col=="") col=1;
		tbwidth=ss[2];
		if (tbwidth=="") tbwidth=500;
		tbborder=ss[3];
		if (tbborder=="") tbborder=1;
		celpadding=ss[4];
		if (celpadding=="") celpadding=2;
		bdcolor=ss[5];
		if (bdcolor=="") bdcolor="#CCCCCC";
		bgcolor=ss[6];
		if (bgcolor=="") bgcolor="#FFFFFF";
		tbalign=ss[7];
		if (tbalign=="") tbalign="center";
		var string;
		string="<table border="+ tbborder +" cellspacing=0 width="+tbwidth+" cellpadding="+ celpadding +" align="+tbalign+" bgcolor='"+ bgcolor +"' bordercolor="+ bdcolor +" style='border-collapse:collapse'>";
		for(i=1;i<=row;i++){
			string=string+"<tr>";
			for(j=1;j<=col;j++){
				string=string+"<td>&nbsp;</td>";
			}
			string=string+"</tr>";
		}
		string=string+"</table>";
		content=IframeID.document.body.innerHTML;
		content=content+string;
		IframeID.document.body.innerHTML=content;
		IframeID.focus();
	}
	else
		IframeID.focus();
}

function html(){
var arr = showModalDialog("htmledit/htmledit.htm", "", "dialogWidth:30.5em; dialogHeight:25em; 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);
}
}

//ubb begin
var UbbUsed=0;
var ftbbsbbs_bIsIE5		= document.all;
var text_enter_url      = "请输入连接网址";			var error_no_useuserName= "请输入定员用户名";				var error_no_points		= "您必须输入数值,如：1000";		var text_enter_usemoney	= "请输入数值,如：1000 (即只有用户支付了1000点金钱才能浏览该内容!)";
var text_enter_txt		= "请输入连接说明";			var text_enter_image	= "请输入图片网址";				var text_enter_sound	= "请输入声音文件网址";			var text_enter_money	= "请输入数值,如：1000 (即限制金钱在1000点以下的用户不能浏览该内容!)";
var text_enter_swf		= "请输入FLASH动画网址";		var text_enter_ra		= "请输入Real音乐网址";			var text_enter_rm		= "请输入Real影片网址";			var text_enter_points	= "请输入数值,如：1000 (即限制积分在1000点以下的用户不能浏览该内容!)";
var text_enter_wmv		= "请输入Media影片网址";		var text_enter_wma		= "请输入Media音乐网址";			var text_enter_mov		= "请输入QuickTime音乐网址";		var text_enter_usercp	= "请输入数值,如：1000 (即限制魅力值在1000点以下的用户不能浏览该内容!)";
var text_enter_sw		= "请输入shockwave音乐网址";	var text_enter_email    = "请输入邮件网址";				var error_no_url		= "您必须输入网址";				var text_enter_power	= "请输入数值,如：1000 (即限制威望在1000点以下的用户不能浏览该内容!)";
var error_no_txt        = "您必须连接说明";			var error_no_title      = "您必须输入首页标题";			var error_no_email		= "您必须输入邮件网址";			var text_enter_post		= "请输入数值,如：1000 (即限制发表文章在1000点以下的用户不能浏览该内容!)";
var error_no_gtxt		= "必须输入文字！";			var text_enter_guang1	= "文字的长度、颜色和边界大小";		var text_enter_guang2	= "要产生效果的文字！";			var text_enter_useuserName	= "请输入定员用户名(多个的用英文豆号分开)";
var error_no_gset		= "必须正确按照各式输入！";

function AddText(text) {
	if (IframeID.document.body.createTextRange && IframeID.document.body.caretPos) {      
		var caretPos = IframeID.document.body.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else IframeID.document.body.innerHTML += text;
	IframeID.focus(caretPos);
}

function Curl() {
	var FoundErrors = '';
	var enterURL   = prompt(text_enter_url, "http://");
	var enterTxT   = prompt(text_enter_txt, enterURL);
	if (!enterURL)    {
	FoundErrors += "\n" + error_no_url;
	}
	if (!enterTxT)    {
	FoundErrors += "\n" + error_no_txt;
	}
	if (FoundErrors)  {
	alert("错误！"+FoundErrors);
	return;
	}
	var ToAdd = "[URL="+enterURL+"]"+enterTxT+"[/URL]";
	IframeID.document.body.innerHTML+=ToAdd;
	IframeID.focus();
}

//ubb标记
function ftbbs_ubb(code,value) {
	if (value)
	{
		fontbegin="["+code+"="+value+"]";
	}else{
		fontbegin="["+code+"]";
	}
	fontend="[/"+code+"]";
	fontchuli();
}

//img
function ftbbs_Signal(code,addtype) {
	var promptinfo='';
	var error_info='';
	var default_info='1000';
	var addtype=0;
	switch (code)
	{
		case 'SOUND':
			addtype=1;
			promptinfo=text_enter_sound;
			error_info=error_no_url;
			default_info="http://";
			break;
		case 'IMG':
			addtype=1;
			promptinfo=text_enter_image;
			error_info=error_no_url;
			default_info="http://";
			break;
		case 'EMAIL':
			addtype=1;
			promptinfo=text_enter_email;
			error_info=error_no_email;
			default_info="";
			break;
	}
    var enter_prompt  =prompt(promptinfo,default_info);
	IframeID.focus()
    sel=IframeID.document.selection.createRange();
	if (!enter_prompt) {
		alert("错误！" + "\n" + error_info);
		return;
	}
	if (addtype==1)
	{
		var ToAdd = "[" + code + "]" + enter_prompt + "[\/" + code + "]";
		sel.pasteHTML(ToAdd);
	}else{
		var ToAdd = "[" + code + "=" + enter_prompt + "]" + IframeID.document.body.innerHTML + "[\/" + code + "]";
		sel.pasteHTML(ToAdd);
	}
}

function Cswf() {    
	txt2=prompt("flash宽度，高度","500,350"); 
	if (txt2!=null) {
		txt=prompt("Flash 文件的地址","http://");
		if (txt!=null) {
			if (txt2=="") {             
			AddTxt="[flash=500,350]"+txt;
			AddText(AddTxt);
			AddTxt="[/flash]";
			AddText(AddTxt);
			} else {
			AddTxt="[flash="+txt2+"]"+txt;
			AddText(AddTxt);
			AddTxt="[/flash]";
			AddText(AddTxt);
			}
	    }
    }
}

function Crm() {
	txt2=prompt("视频的宽度，高度，播放参数\r(播放参数：false＝手动播放，true＝自动播放)","500,350,true"); 
	if (txt2!=null) {
		txt=prompt("视频文件的地址","请输入");
		if (txt!=null) {
			if (txt2=="") {
				AddTxt="[RM=500,350,false]"+txt;
				AddText(AddTxt);
				AddTxt="[/RM]";
				AddText(AddTxt);
			} else {
				AddTxt="[RM="+txt2+"]"+txt;
				AddText(AddTxt);
				AddTxt="[/RM]";
				AddText(AddTxt);
			}
		}
	}
}

function Cwmv() {
	txt2=prompt("视频的宽度，高度，播放参数\r(播放参数：false＝手动播放，true＝自动播放)","500,350,true"); 
	if (txt2!=null) {
		txt=prompt("视频文件的地址","请输入");
		if (txt!=null) {
			if (txt2=="") {
			AddTxt="[MP=500,350,false]"+txt;
			AddText(AddTxt);
			AddTxt="[/MP]";
			AddText(AddTxt);
			} else {
			AddTxt="[MP="+txt2+"]"+txt;
			AddText(AddTxt);
			AddTxt="[/MP]";
			AddText(AddTxt);
			}
		}
	}
}

function Cmov() {
	txt2=prompt("视频的宽度，高度","500,350"); 
	if (txt2!=null) {
		txt=prompt("视频文件的地址","请输入");
		if (txt!=null) {
			if (txt2=="") {
			AddTxt="[qt=500,350]"+txt;
			AddText(AddTxt);
			AddTxt="[/qt]";
			AddText(AddTxt);
			} else {
			AddTxt="[qt="+txt2+"]"+txt;
			AddText(AddTxt);
			AddTxt="[/qt]";
			AddText(AddTxt);
			}
		}
	}
}

function Cdir() {
	txt2=prompt("Shockwave文件的宽度，高度","500,350"); 
	if (txt2!=null) {
		txt=prompt("Shockwave文件的地址","请输入地址");
		if (txt!=null) {
			if (txt2=="") {
			AddTxt="[dir=500,350]"+txt;
			AddText(AddTxt);
			AddTxt="[/dir]";
			AddText(AddTxt);
			} else {
			AddTxt="[dir="+txt2+"]"+txt;
			AddText(AddTxt);
			AddTxt="[/dir]";
			AddText(AddTxt);
			}
		}
	}
}

function Cfanzi() {
fontbegin="[xray]";
fontend="[/xray]";
fontchuli();
}

function paste(text) {
	if (opener.IframeID.document.body.createTextRange && opener.IframeID.document.body.caretPos) {      
		var caretPos = opener.IframeID.document.body.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else opener.IframeID.document.body.innerHTML += text;
	opener.IframeID.document.body.focus(caretPos);
}

function fontchuli(){
	if ((IframeID.document.selection)&&(IframeID.document.selection.type == "Text")) {
	var range = IframeID.document.selection.createRange();
	var ch_text=range.text;
	range.text = fontbegin + ch_text + fontend;
	} 
	else {
	IframeID.document.body.innerHTML=fontbegin+IframeID.document.body.innerHTML+fontend;
	IframeID.focus();
	}
}

function Cguang() {
	var FoundErrors = '';
	var enterSET   = prompt(text_enter_guang1, "255,red,2");
	var enterTxT   = prompt(text_enter_guang2, "文字");
	if (!enterSET)    {
	FoundErrors += "\n" + error_no_gset;
	}
	if (!enterTxT)    {
	FoundErrors += "\n" + error_no_gtxt;
	}
	if (FoundErrors)  {
	alert("错误！"+FoundErrors);
	return;
	}
	var ToAdd = "[glow="+enterSET+"]"+enterTxT+"[/glow]";
	IframeID.document.body.innerHTML+=ToAdd;
	IframeID.focus();
}
function Cying() {
	var FoundErrors = '';
	var enterSET   = prompt(text_enter_guang1, "255,blue,1");
	var enterTxT   = prompt(text_enter_guang2, "文字");
	if (!enterSET)    {
	FoundErrors += "\n" + error_no_gset;
	}
	if (!enterTxT)    {
	FoundErrors += "\n" + error_no_gtxt;
	}
	if (FoundErrors)  {
	alert("错误！"+FoundErrors);
	return;
	}
	var ToAdd = "[SHADOW="+enterSET+"]"+enterTxT+"[/SHADOW]";
	IframeID.document.body.innerHTML+=ToAdd;
	IframeID.focus();
}

//清除表单
function ClearReset()
{
	IframeID.document.body.innerHTML='';
	IframeID.focus();
}

function fixtag(text)
{
	text = text.replace(/&|\/|<|>|\*|#|:|;|=|\?|\)|\(|%|\[|\]|\$| /g, "") ;
	return text ;
}