﻿
document.writeln("<table width=100% height=98% cellpadding=2 cellspacing=0>");
//document.writeln("<tr><td><select name='fontstyle' onChange=cmd_font()><option value='字体选择'>字体选择</option><option value='宋体'>宋体</option><option value='黑体'>黑体</option>");
//document.writeln("<select name='fontstyle' onChange=cmd_font()><option value='字体选择'>字体选择</option><option value='宋体'>宋体</option><option value='黑体'>黑体</option>");
//document.writeln("<option value='Arial'>Arial</option><option value='Book Antiqua'>Book Antiqua</option><option value='Century Gothic'>Century Gothic</option>");
//document.writeln("<option value='Courier New'>Courier New</option><option value='Georgia'>Georgia</option><option value='Impact'>Impact</option>");
//document.writeln("<option value='Tahoma'>Tahoma</option><option value='Times New Roman'>Times New Roman</option><option value='Verdana'>Verdana</option></select>&nbsp;");
//document.writeln("<select name='fontsize' onChange='cmd_size()'>");
//document.writeln("<option value='字体大小'>字体大小</option>");
//document.writeln("<option value='-2'>-2</option><option value='-1'>-1</option><option value='1'>1</option><option value='2'>2</option>");
//document.writeln("<option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option></select></td>");
//document.writeln("<option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option></select>");
//document.writeln("<tr><td align=left>");


//var FormatTextlist="粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 RemoveFormat|左对齐 aleft|居中 Center|右对齐 aRight|两端对齐 lralign|剪切 cut|复制 copy|粘贴 paste|撤消 undo|恢复 redo|插入超链接 wlink|去掉超链接 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{
//alert(list[10].split (' '));
var TextName= list[i].split (' ');
document.write(" <img align=absmiddle src=/js/jscomp/htmledit/wbTextBox/images/"+TextName[1]+".gif alt="+TextName[0]+" style=cursor:hand onClick=FormatText('"+TextName[1]+"')> ");
}
}
document.writeln("<img src=/js/jscomp/htmledit/wbTextBox/images/fbcolor.gif alt=\"突出颜色\" align=absmiddle style=cursor:hand onClick=BackColor()>");
document.writeln("<img src=/js/jscomp/htmledit/wbTextBox/images/fgcolor.gif alt=\"字体颜色\" align=absmiddle style=cursor:hand onClick=foreColor()>");
//document.writeln("<img src=/js/jscomp//htmledit/wbTextBox/images/replace.gif alt=\"替换\" align=absmiddle style=cursor:hand onClick=replace()>");
document.writeln("<img src=/js/jscomp/htmledit/wbTextBox/images/img.gif alt=\"插入图片\" align=absmiddle style=cursor:hand onClick=img()>");
//document.writeln("<img alt=\"插入FLASH文件\" src=/js/jscomp//htmledit/wbTextBox/images/swf.gif align=absmiddle style=cursor:hand onclick=flash()>");
//document.writeln("<img alt=\"插入Media Player文件\" src=/js/jscomp//htmledit/wbTextBox/images/wmv.gif align=absmiddle style=cursor:hand onclick=MediaPlayer()>");
//document.writeln("<img alt=\"插入RealPlayer文件\" src=/js/jscomp//htmledit/wbTextBox/images/rm.gif align=absmiddle style=cursor:hand onclick=RealPlay()>");
//document.writeln("<img alt=\"插入表情\" src=/js/jscomp//htmledit/wbTextBox/images/em.gif align=absmiddle style=cursor:hand onclick=em()>");
//document.writeln("<img alt=\"清理代码\" src=/js/jscomp//htmledit/wbTextBox/images/CleanCode.gif align=absmiddle style=cursor:hand onclick=CleanCode()>");
document.writeln("</td></tr><tr><td height=100%><iframe class='test' ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=99% height=100% ></iframe></td></tr>");
document.writeln("</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.bbsFrm.remenu.value=document.body.innerHTML;parent.document.bbsFrm.submit();parent.document.bbsFrm.submit1.disabled=true;}}<\/script><body>');
//alert(document.getElementById("remenu").value);
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.innerHTML=document.getElementById("remenu").value;
//alert(IframeID.document.body.innerHTML);
IframeID.document.body.style.fontSize="11pt";


function innerHTML(arr){
//var str = new String;
//var p = body.firstChild.firstChild;
var p=IframeID.document.body;
p.innerHTML=arr;
p.innerHTML=p.innerHTML.substring(0,p.length);
return p.innerHTML;
}

function cmd_font(){
	//alert(11);
	var style= window.document.getElementById('fontstyle').value;
	//alert(style);
	if(style=="字体选择"){
		return false;
	}
	IframeID.focus();
	IframeID.document.execCommand("FontName",true,style);
}

function cmd_size(){
	var size= window.document.getElementById('fontsize').value;
	//alert(size);
	if(size=="字体大小"){
		return false;
	}
	IframeID.focus();
	//var sel=IframeID.document.selection.createRange();
	IframeID.document.execCommand("FontSize",true,size);
}



function em(){
var arr = showModalDialog("/js/jscomp//htmledit/inc/emot.jsp", "", "dialogWidth:28em; dialogHeight:15em; status:70;help:0;center:1;");
if (arr != null){
		IframeID.focus()
		sel=IframeID.document.selection.createRange();
		sel.pasteHTML(arr);
	}
}

function wordcount(){
MessageLength=IframeID.document.body.innerHTML.length;
alert("当前长度:"+MessageLength+"字节\r\n\r\n系统限制:6 到 4000 字节");
}


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(/\<[^<IMG]*>/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 CleanCode_auto(){
var body = IframeID.document.body;
var html = IframeID.document.body.innerHTML;

//alert(html);

html = html.replace(/\<p/gi,"[$p]");
html = html.replace(/\<\/p>/gi,"[$\/p]");
html = html.replace(/\<br>/gi,"[$br]");

html = html.replace(/\<FONT/gi,"[$font]");
html = html.replace(/\<\/FONT/gi,"[$\/font]");

html = html.replace(/\<SUP/gi,"[$sup]");
html = html.replace(/\<\/SUP/gi,"[$\/sup]");

html = html.replace(/\<SUB/gi,"[$sub]");
html = html.replace(/\<\/SUB/gi,"[$\/sub]");

html = html.replace(/\<STRIKE/gi,"[$strike]");
html = html.replace(/\<\/STRIKE/gi,"[$\/strike]");

html = html.replace(/\<A/gi,"[$a]");
html = html.replace(/\<\/A/gi,"[$\/a]");

html = html.replace(/\<STRONG/gi,"[$strong]");
html = html.replace(/\<\/STRONG/gi,"[$\/strong]");

html = html.replace(/\<EM/gi,"[$em]");
html = html.replace(/\<\/EM/gi,"[$\/em]");

html = html.replace(/\<U/gi,"[$u]");
html = html.replace(/\<\/U/gi,"[$\/u]");


html = html.replace(/\<IMG/gi,"[$IMG]");

//alert(html)

html = html.replace(/\<[^>]*>/g,"");

//html = html.replace(/\A>*/g,"");

html = html.replace(/\<INPUT>*/g,"");
html = html.replace(/\<OPTION>*/g,"");
html = html.replace(/\<SELECT>*/g,"");

//html = html.replace(/\<[^IMG>]*>/g,"");

html = html.replace(/\[\$IMG\]/gi,"<IMG");

html = html.replace(/\[\$a\]/gi,"<A");
html = html.replace(/\[\$\/a\]/gi,"<\/A");

html = html.replace(/\[\$u\]/gi,"<U");
html = html.replace(/\[\$\/u\]/gi,"<\/U");

html = html.replace(/\[\$em\]/gi,"<EM");
html = html.replace(/\[\$\/em\]/gi,"<\/EM");

html = html.replace(/\[\$strong\]/gi,"<STRONG");
html = html.replace(/\[\$\/strong\]/gi,"<\/STRONG");

html = html.replace(/\[\$strike\]/gi,"<STRIKE");
html = html.replace(/\[\$\/strike\]/gi,"<\/STRIKE");

html = html.replace(/\[\$sub\]/gi,"<SUB");
html = html.replace(/\[\$\/sub\]/gi,"<\/SUB");

html = html.replace(/\[\$sup\]/gi,"<SUP");
html = html.replace(/\[\$\/sup\]/gi,"<\/SUP");

html = html.replace(/\[\$font\]/gi,"<FONT");
html = html.replace(/\[\$\/font\]/gi,"<\/FONT");

html = html.replace(/\[\$p\]/gi,"<p");
html = html.replace(/\[\$\/p\]/gi,"<\/p>");

html = html.replace(/\[\$br\]/gi,"<br>");
IframeID.document.body.innerHTML = html;

//alert(html);
}


function FormatText(command,option){
	//alert(command);
	IframeID.focus();
	IframeID.document.execCommand(command,true,option);
	IframeID.document.body.innerHTML=IframeID.document.body.innerHTML.replace("<A","<A target=\"_blank\"");
}

function CheckLength(){alert("最大字符为 "+5000000+ " 字节\n您的内容已有 "+IframeID.document.body.innerHTML.length+" 字节");}

function CheckForm_Ex(form){
	CleanCode_auto();
	form.remenu.value=IframeID.document.body.innerHTML;
	MessageLength=IframeID.document.body.innerHTML.length;
	return true;
}

function CheckForm_parent(form){
CleanCode_auto();
var picwidth=form.imgWidth.value;
var picheight=form.imgHeight.value;
form.remenu.value=IframeID.document.body.innerHTML;

MessageLength=IframeID.document.body.innerHTML.length;

if(MessageLength<6){alert("文章内容不能小于6个字节！");return false;}

else if(MessageLength>3900){
	alert("文章内容不能超过4000个字节！");
	form.remenu.value = "";
	return false;
}
//omit 060509, not needed
//copyText1(form.remenu); //新增复制内容到剪贴板中

if(form.bname.value.length == 0)
   {
      alert("请填写文章主题，谢谢！");
      return false;   
   }    

 if(form.bbs_img.value.length!=0){
	if(picwidth==0||picheight==0){
		alert("您上传的附件有问题,请重新选择，谢谢！");
		return false;
	}else if(form.bbs_img.value.indexOf(":")==-1)
   {
      alert("上传附件格式不标准，谢谢！");
	  return false;   
   }
 }
	document.getElementById("waitting").style.display="block";
	//return false;
   //window.open("","parentSaveWin","height=50,width=200,top=0,left=0");
   //window.open ('/js/jscomp//js/jscomp/_waiting.htm', 'parentSaveWin', 'height=50, width=200, top=0, left=0') 
   //return false;
}

function CheckForm_child(form){

CleanCode_auto();
var level=form.i_level.value;
var picwidth=form.imgWidth.value;
var picheight=form.imgHeight.value;



form.remenu.value=IframeID.document.body.innerHTML;

//alert(form.remenu.value);

MessageLength=IframeID.document.body.innerHTML.length;

//alert(MessageLength);

if(form.remenu.value.indexOf("[/quote]")!=-1&&form.remenu.value.indexOf("[quote]")!=-1){
	var len=form.remenu.value.lastIndexOf("[/quote]");
	MessageLength=MessageLength-len-8;
}
//alert(form.remenu.value.indexOf("/n"));
//omit 060509, not needed
//copyText1(form.remenu); //新增复制内容到剪贴板中
if(MessageLength<6){alert("文章内容不能小于6个字节！");
return false;
}



else if(MessageLength>3900){
	alert("文章内容不能超过4000个字节！");
	form.remenu.value="";
	return false;}

if(form.bname.value.length == 0)
   {
      alert("请填写文章主题，谢谢！");
      return false;   
   }

if(level>100){
 if(form.bbs_img.value.length!=0){
	if(picwidth==0||picheight==0){
		alert("您上传的附件有问题,请重新选择，谢谢！");
		return false;
	}else if(form.bbs_img.value.indexOf(":")==-1)
   {
      alert("上传附件格式不标准，谢谢！");
	  return false;   
   }
 }
}
	document.getElementById("waitting").style.display="block";
	//window.open ('bbs_waiting.jsp', 'newwindow', 'height=50, width=200, top=0, left=0') 
	//window.open("bbs_waiting.htm","childSaveWin","height=50,width=200,top=0,left=0");
	//return false;
}
//以下新加
function copyText1(obj) {
	clipboardData.setData('Text',obj.value);
}
//以上新加

function yinyong(obj) {
	IframeID.document.body.innerHTML="[quote]"+obj+"[/quote]";
	IframeID.focus();
}

function Gopreview()
{
document.preview.remenu.value=IframeID.document.body.innerHTML;
window.open('', 'preview_page', 'resizable,scrollbars,width=750,height=450');
document.preview.submit()
}

function BackColor()
{
  var arr = showModalDialog("/js/jscomp//htmledit/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("/js/jscomp//htmledit/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("/js/jscomp//htmledit/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("请输入图片文件URL地址:","http://");
if(!url || url=="http://") return;
IframeID.focus();
sel=IframeID.document.selection.createRange();
//alert(document.getElementById("remenu").value);
sel.pasteHTML("<p><img src="+url+" width='400'></p>");
}

function RealPlay(){
	//var arr = showModalDialog("htmledit/inc/RealPlay.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
	var arr = showModalDialog("/js/jscomp/htmledit/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("/js/jscomp/htmledit/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("/js/jscomp/htmledit/inc/flash.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
//sel.pasteHTML("<a href="+arr+">"+arr+"</a>");
}
}
