var IframeID;
var IsHtmlEdit;
var IsCode
IsCode="No"
function HtmlEdit(){
IsHtmlEdit=1
document.writeln("<div id=\"EditorB\"><select 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>");
document.writeln("<select name=\"selectFont\" onChange=\"FormatText('fontname',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 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 value=5>五号<option value=6>六号<option value=7>七号</option></select>");
emblem()
document.writeln("<img id=\"backcolor\" src=pic\/edit\/fbcolor.gif alt=\"突出颜色\" title=\"突出颜色\" align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\" onClick=\"color(\'backcolor\')\">");
document.writeln("<img id=\"forecolor\"  src=pic\/edit\/fgcolor.gif alt=\"字体颜色\" title=\"字体颜色\" align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\"  onClick=\"color(\'forecolor\')\">");
document.writeln("<img src=pic\/edit\/replace.gif alt=\"替换\" title=\"替换\" align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\" onClick=replace()>");
document.writeln("<img align=absmiddle src=pic\/edit\/separator.gif>");
document.writeln("<img align=absmiddle src=pic\/edit\/table.gif alt=\"插入表格\" title=\"插入表格\" style=\"cursor:pointer;width:16px;height:16px;\" onClick=inserttable()>");
document.writeln("<img src=pic\/edit\/img.gif alt=\"插入图片\" title=\"插入图片\" align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\" onClick=img()>");
document.writeln("<img alt=\"插入FLASH文件\" src=pic\/edit\/swf.gif align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\" onclick=flash()>");
document.writeln("<img alt=\"插入Media Player文件\" src=pic\/edit\/mp.gif align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\" onclick=MediaPlayer()>");
document.writeln("<img alt=\"插入RealPlayer文件\" src=pic\/edit\/rm.gif align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\" onclick=RealPlay()>");
document.writeln("<img id=\"mood\" alt=\"插入表情\" src=pic\/edit\/em.gif align=absmiddle style=\"cursor:pointer;width:16px;height:16px;\" onclick=showpic()><br>");
FormatTextlist="撤消 undo|恢复 redo|剪切 cut|复制 copy|粘贴 paste|-|粗体 bold|倾斜 italic|下划线 underline|删除线 strikethrough|上标 superscript|下标 subscript|删除文字格式 RemoveFormat|-|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|-|编号 insertorderedlist|项目符号 InsertUnorderedList|减少缩进量 Outdent|增加缩进量 indent|-|插入超链接 createLink|去掉超链接 Unlink|普通水平线 InsertHorizontalRule|全选 selectAll|删除当前选中区 Delete"
list= FormatTextlist.split ('|'); 
for(i=0;i<list.length;i++){
if (list[i]=="-"){document.write("<img align=\"absmiddle\" src=\"pic\/edit\/separator.gif\" />");
}else{
var TextName= list[i].split (' '); 
if ((i==2 || i==3 ||i==4)&&(ns6)){
//document.write(" <img align=absmiddle src=pic\/edit\/"+TextName[1]+"1.gif alt="+TextName[0]+" style=\"width:16px;height:16px;\" >");
}
else{
document.write(" <img align=\"absmiddle\" src=\"pic\/edit\/"+TextName[1]+".gif\" alt=\""+TextName[0]+"\" title=\""+TextName[0]+"\" style=\"cursor:pointer;width:16px;height:16px;\" onClick=\"FormatText('"+TextName[1]+"')\" \/> ");
}
}
}

document.writeln("<script type='text/javascript' src='http://union.bokecc.com/ccplugin.bo?userID=34477&type=94kk'></script>");





document.writeln("<img alt=\"清理代码\" src=\"pic\/edit\/CleanCode.gif\" align=\"absmiddle\" style=\"cursor:pointer;width:16px;height:16px;\" onclick=\"CleanCode()\" \/><\/div>");
ContinueShow()
}
function UbbEdit(){
IsHtmlEdit=0
document.writeln("<div style=\"height:25px\" id=\"EditorB\">");
document.writeln("<select onChange=\"if(this.options[this.selectedIndex].value!=\'\'){ybbsize(this.options[this.selectedIndex].value);this.options[0].selected=true;}\">");
document.writeln("<option selected>文字大小<\/option><option value=1>1号字<\/option><option value=2>2号字<\/option><option value=3>3号字<\/option><option value=4>4号字<\/option><\/select> ");
document.writeln("<select onChange=\"if(this.options[this.selectedIndex].value!=\'\'){UBBCOLOR(this.options[this.selectedIndex].value);this.options[0].selected=true;}\">");
document.writeln("<option>文字颜色<\/option><option style=\"COLOR:#000;BACKGROUND-COLOR:#000\" value=\"#000\">黑色<\/option><option style=\"COLOR:#FFF;BACKGROUND-COLOR:#FFF\" value=\"#FFF\">白色<\/option><option style=\"COLOR:#008000;BACKGROUND-COLOR:#008000\" value=\"#008000\">绿色<\/option><option style=\"COLOR:#800000;BACKGROUND-COLOR:#800000\" value=\"#800000\">褐色<\/option><option style=\"COLOR:#808000;BACKGROUND-COLOR:#808000\" value=\"#808000\">橄榄色<\/option><option style=\"COLOR:#000080;BACKGROUND-COLOR:#000080\" value=\"#000080\">深蓝色<\/option><option style=\"COLOR:#800080;BACKGROUND-COLOR:#800080\" value=\"#800080\">紫色<\/option>");
document.writeln("<option style=\"COLOR:#808080;BACKGROUND-COLOR:#808080\" value=\"#808080\">灰色<\/option><option style=\"COLOR:#FF0;BACKGROUND-COLOR:#FF0\" value=\"#FFFF00\">黄色<\/option><option style=\"COLOR:#0F0;BACKGROUND-COLOR:#0F0\" value=\"0F0\">浅绿色<\/option><option style=\"COLOR:#0FF;BACKGROUND-COLOR:#0FF\" value=\"#00FFFF\">浅蓝色<\/option><option style=\"COLOR:#F0F;BACKGROUND-COLOR:#F0F\" value=#FF00FF>粉红色<\/option><option style=\"COLOR:#C0C0C0;BACKGROUND-COLOR:#C0C0C0\" value=\"#C0C0C0\">银白色<\/option><option style=\"COLOR:#F00;BACKGROUND-COLOR:#F00\" value=\"#FF0000\">红色<\/option><option style=\"COLOR:#00F;BACKGROUND-COLOR:#00F\" value=\"#0000FF\">蓝色<\/option><option style=\"COLOR:#008080;BACKGROUND-COLOR:#008080\" value=\"#008080\">蓝绿色<\/option><\/select>");
emblem()
document.writeln("<input type=button value=插入代码 Class=Butt onClick=Code()> <input type=button value=上标 Class=Butt onClick=Especial(\"[sup]\",\"[\/sup]\")> <input type=button value=下标 Class=Butt onClick=Especial(\"[sub]\",\"[\/sub]\")>");
document.writeln("<br><img onClick=Cbold() src=\"Pic\/Ubb\/U_1.gif\"  border=0 alt=粗体字> <img src=\"Pic\/Ubb\/U_2.gif\" onClick=Citalic() border=0 alt=斜体字 > <img src=\"Pic\/Ubb\/U_3.gif\" onClick=Cunder() border=0 alt=下划线>");
document.writeln("<img src=\"Pic\/Ubb\/U_4.gif\" onClick=center() border=\"0\" alt=\"居中\"> <img src=\"Pic\/Ubb\/U_5.gif\" style=\"\" onClick=\"fly()\" border=0 alt=飞行字> <img src=\"Pic\/Ubb\/U_6.gif\" style=\"cursor:pointer\" onClick=\"move()\" alt=\"移动字\" /> <img src=\"Pic\/Ubb\/U_7.gif\" onClick=LIGHT() alt=\"发光字\" style=\"cursor:pointer\" /> <img src=\"Pic\/Ubb\/U_8.gif\" onClick=\"ying()\" style=\"cursor:pointer\" alt=\"阴影字\" /> <img src=\"Pic\/Ubb\/U_9.gif\" onClick=\"FormatText('createLink')\" style=\"cursor:pointer\" alt=\"超连接\"> <img src=\"Pic\/Ubb\/U_10.gif\" onClick=\"Cemail()\" style=\"cursor:pointer\" alt=\"Email连接\"> <img src=\"Pic\/Ubb\/U_12.gif\" onClick=\"img()\" style=\"cursor:pointer\" alt=\"图片\" /> <img src=\"Pic\/Ubb\/U_13.gif\" onClick=\"flash()\" style=\"cursor:pointer\" alt=\"Flash动画\" /> <img onClick=MediaPlayer()  src=\"Pic\/Ubb\/U_14.gif\" style=\"cursor:pointer\" alt=\"Media Player视频文件\" /> <img src=\"Pic\/Ubb\/U_15.gif\" onClick=\"RealPlay()\" border=0 alt=realplay视频文件> <img onClick=Csound() src=\"Pic\/Ubb\/U_16.gif\" border=\"0\" alt=\"插入背景音乐\"> <img id=\"mood\" src=\"Pic\/Ubb\/U_11.gif\" onClick=\"showpic(event)\" style=\"cursor:pointer\" alt=\"更多的心情图片\" /><\/div>");
ContinueShow()
}
function ContinueShow(){
document.writeln("<div><iframe ID=\"edit\" MARGINHEIGHT=\"5\" MARGINWIDTH=\"5\" width=\"99%\" height=\"250\"><\/iframe><\/div>");
document.writeln("<div style=\"float:right;\"><span id=\"CNo\" style=\"height:21\" ><img id=\"CNo\" width=\"52\" height=\"21\" src=\"pic\/ubb\/codeA.gif\" onClick=\"setCode(\'No\')\" ></span><span style=\"height:21\" id=\"CYes\"><img src=\"pic\/ubb\/codeB.gif\" width=\"52\" height=\"21\" onClick=setCode(\'Yes\')></span> <img src=\"Images\/plus.gif\" style=\"cursor:pointer\" onclick=\"textarea_Size(250,document.getElementById(\'edit\'))\" alt=\"增加编辑框的高度\" \/> <img src=\"Images\/minus.gif\" style=\"cursor:pointer\" onclick=\"textarea_Size(-250,document.getElementById(\'edit\'))\" alt=\"减小输入框的高度\" \/><\/div>");
document.writeln("<div id=\"MaoDiv\" style=\"background:#FFFFFF;position: absolute; width:570px; height:160px; display:none;\"><iframe id=\"MView\" name=\"MView\" src=\"about:blank\" frameborder=\"0\" scrolling=\"no\" valign=\"top\" width=\"100%\" height=\"100%\"><\/iframe><\/div>");
if (ns6){
	IframeID=document.getElementById("edit").contentWindow;
	document.writeln("<div id=\"colorpalette\" style=\"position: absolute;visibility: hidden;width:201px;height:151px;left:400px;top:350px\" ><iframe src=\"pic/edit/colors.htm\" frameborder=\"0\" scrolling=\"no\"  width=\"100%\" height=\"100%\" ><\/iframe><\/div>");
	document.addEventListener("mousedown", dismisscolorpalette, true);
	IframeID.document.addEventListener("mousedown", dismisscolorpalette, true);
	document.addEventListener("keypress", dismisscolorpalette, true);
	IframeID.document.addEventListener("keypress", dismisscolorpalette, true);
}else{
	IframeID=frames["edit"];
	}
	document.getElementById("CYes").style.border="1px outset"
	document.getElementById("CNo").style.border="1px inset"
	document.getElementById("CYes").style.cursor="pointer"
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){IframeID.document.designMode="On"}
	IframeID.document.open();
	IframeID.document.write ('<html><head><style type=text/css>.quote{margin:5px 20px;padding:5px; background:#EEEEEF;border:1px solid #CCC ;}\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;}</style><script language=\"JavaScript\">i=0;function ctlent(event){if((event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83))if(i==0){i=1;parent.checkform()}}<\/script></head><body onkeydown=\"ctlent(event)\"></body></html>');
	IframeID.document.close();
	IframeID.document.body.style.fontSize="14px";
	IframeID.document.body.style.background="#FFFFFF"
	IframeID.document.body.contentEditable = "True";
	IframeID.document.body.innerHTML=document.getElementById("content").value;
}
function dismisscolorpalette(){document.getElementById("colorpalette").style.visibility="hidden";}

function cleanHtml(){
	if(IsCode=="Yes")setCode("No");
	s94kk=IframeID.document.body.innerHTML
	s94kk = s94kk.replace(/<a([^>]*) href\s*=\s*([^\s|>]*)([^>]*)/gi, "<a href=$2 target=\"_blank\" ");
	s94kk = s94kk.replace(/<a([^>]*)><\/a>/gi, "")
	s94kk = s94kk.replace(/<p>&nbsp;<\/p>/gi,"")
	s94kk = s94kk.replace(/<p><\/p>/gi,"<p>")
	s94kk = s94kk.replace(/<div><\/\1>/gi,"")
	s94kk = s94kk.replace(/(\r\n){10,}/gi,"$1")
	s94kk = s94kk.replace(/(<br>\s*){10,}/gi,"<br>")
	s94kk = s94kk.replace(/(<(meta|iframe|frame|span|tbody|layer)[^>]*>|<\/(iframe|frame|meta|span|tbody|layer)>)/gi, "");
	s94kk = s94kk.replace(/<\\?\?xml[^>]*>/gi, "") ;
	s94kk = s94kk.replace(/&nbsp;/gi, " ");
	s94kk = s94kk.replace(/.width>/gi, ".width@94kk@");
	s94kk = s94kk.replace(/.height>/gi, ".height@94kk@");
	s94kk = s94kk.replace(/<img([^>]*) (src\s*=([^\s|>])*)([^>]*)>/gi,"<img $2>");
	s94kk = s94kk.replace(/.width@94kk@/gi, ".width>");
	s94kk = s94kk.replace(/.height@94kk@/gi, ".height>");
	s94kk = s94kk.replace(/<([^>]*) id\s*=\s*(content|caption)([^>]*)>/gi,"<$1$3>");
	s94kk = s94kk.replace(/(<(div|span|table) style\s*=\s*[^>]*)(position\s*:\s*absolute)([^>]*>)/gi, "$1$4");
return s94kk;
}
function setHTML(html) {
	switch (IsCode){
	case "Yes":
		if(ns6){
		var KK=document.createTextNode(html);
		IframeID.document.body.innerHTML = "";
		IframeID.document.body.appendChild(KK);
		}
	else{
		IframeID.document.body.innerText=html;
	}
    	document.getElementById("CNo").style.border="1px outset"
		document.getElementById("CNo").style.cursor="pointer"
 		document.getElementById("CYes").style.border="1px inset"
		document.getElementById("CYes").style.cursor=""
		document.getElementById("EditorB").style.display = 'none';
   break;
	case "No":
	if(ns6){
		var KK= IframeID.document.body.ownerDocument.createRange();
		KK.selectNodeContents(IframeID.document.body);
		IframeID.document.body.innerHTML = KK.toString();
		}else{
		IframeID.document.body.innerHTML = html;
		}
		document.getElementById("CYes").style.cursor="pointer"
		document.getElementById("CYes").style.border="1px outset"
		document.getElementById("CNo").style.border="1px inset"
        document.getElementById("CNo").style.cursor=""
		document.getElementById("EditorB").style.display = 'block';
	break;
	}
}
function setCode(ast){
	if (ast!=IsCode){
		switch(IsCode){
		case "Yes":
			KK=IframeID.document.body.innerText;
			 break;
		case "No":
		     KK = IframeID.document.body.innerHTML;
		      break;
		}
		IsCode = ast;
		setHTML(KK)
	}
}

function Insert(theSmilie){
IframeID.focus();
if(ns6){
IframeID.document.body.innerHTML+=theSmilie
}else{
sel=IframeID.document.selection.createRange();
sel.pasteHTML(theSmilie);
}
}

function emblem(){
document.writeln("<select onchange=\"Insert(this[this.selectedIndex].value);this.selectedIndex=0;\"><option selected=\"selected\">符号<\/option>");
var FormatTextlist="&radic;|&#8240;|&times;|&larr;|&uarr;|&rarr;|&darr;|&#162;|&#163;|&#165;|&#166;|&#169;|&#171;|&#174;|&#176;|&#177;|&#183;|&#188;|&#189;|&#247;|＄|￥|☆|★|○|●|◇|▲|■|□|△|◆"
var list= FormatTextlist.split('|');
for(i=0;i<list.length;i++){document.writeln("<option value=\""+list[i]+"\">"+list[i]+"<\/option>");}
document.writeln("<\/select>");
}


function showpic() {
	var MaoDiv=document.getElementById("MaoDiv").style
	buttonElement = document.getElementById("mood");
	if(MView.location=='about:blank'){MView.location.replace('pic/moodpic.htm')}
	MaoDiv.top=getOffsetTop(buttonElement) - 160+"px";
	MaoDiv.left=getOffsetLeft(buttonElement)-550+"px";
	if(MaoDiv.left<"0px")MaoDiv.left="0px";
	if(MaoDiv.top<"0px")MaoDiv.top="0px";
	if(MaoDiv.display=='block'){MaoDiv.display='none'}
	else{MaoDiv.display='block'}
	}
	

function inserttable(){
if(ns6){
 e = document.getElementById("edit");
    rowstext = prompt("创建表格，请输入表格的行数：",2);
    colstext = prompt("创建表格，请输入表格的列数：",2);
    rows = parseInt(rowstext);
	cols = parseInt(colstext);
    if ((rows > 0) && (cols > 0)) {
      table = e.contentWindow.document.createElement("table");
      table.setAttribute("border", "1");
      table.setAttribute("cellpadding", "2");
      table.setAttribute("cellspacing", "2");
      tbody = e.contentWindow.document.createElement("tbody");
      for (var i=0; i < rows; i++) {
        tr =e.contentWindow.document.createElement("tr");
        for (var j=0; j < cols; j++) {
          td =e.contentWindow.document.createElement("td");
          br =e.contentWindow.document.createElement("br");
          td.appendChild(br);
          tr.appendChild(td);
        }
        tbody.appendChild(tr);
      }
      table.appendChild(tbody);      
      insertNodeAtSelection(e.contentWindow, table);
    }
	IframeID.focus();
}else{
	var arr = showModalDialog("pic/edit/table.html", window, "dialogWidth:22em; dialogHeight:22em; status:0; help:0;scroll:no;");
	if (arr)
	{
		IframeID.document.body.innerHTML+=arr;
	}
	IframeID.focus();
}
}
  
function insertNodeAtSelection(win, insertNode)
  {
      var sel = win.getSelection();
      var range = sel.getRangeAt(0);
      sel.removeAllRanges();
      range.deleteContents();
      var container = range.startContainer;
      var pos = range.startOffset;
      range=document.createRange();

      if (container.nodeType==3 && insertNode.nodeType==3) {
        container.insertData(pos, insertNode.nodeValue);
        range.setEnd(container, pos+insertNode.length);
        range.setStart(container, pos+insertNode.length);

      } else {

        var afterNode;
        if (container.nodeType==3) {
          var textNode = container;
          container = textNode.parentNode;
          var text = textNode.nodeValue;
          var textBefore = text.substr(0,pos);
          var textAfter = text.substr(pos);

          var beforeNode = document.createTextNode(textBefore);
          afterNode = document.createTextNode(textAfter);
          container.insertBefore(afterNode, textNode);
          container.insertBefore(insertNode, afterNode);
          container.insertBefore(beforeNode, insertNode);
          container.removeChild(textNode);

        } else {
          afterNode = container.childNodes[pos];
          container.insertBefore(insertNode, afterNode);
        }
        range.setEnd(afterNode, 0);
        range.setStart(afterNode, 0);
      }

      sel.addRange(range);
  };

function color(str){
	if(ns6){
	parent.command = str;
	if(str=="backcolor"){parent.command = "hilitecolor";};
    buttonElement = document.getElementById(str);
    document.getElementById("colorpalette").style.left = getOffsetLeft(buttonElement)+"px";
    document.getElementById("colorpalette").style.top = getOffsetTop(buttonElement) + buttonElement.offsetHeight+"px";
    document.getElementById("colorpalette").style.visibility="visible";
	}
else{
	var arr = showModalDialog("pic/edit/selcolor.htm", "", "dialogWidth:18em; dialogHeight:19em; status:0;help:0;scroll:no;");
  if (arr != null) FormatText(str, arr);
  else IframeID.focus();
	}
	
	}


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){
	if(command == "createLink"){if(ns6)option = prompt("请输入网址 URL:", "http://");}
	IframeID.focus();
	IframeID.document.execCommand(command,false,option);
	}


function DoTitle(addTitle){
document.getElementById("caption").value=addTitle+document.getElementById("caption").value;
document.getElementById("caption").focus();
document.getElementById("caption").value+="";
}

function checkform(maxnum){
contentLength=IframeID.document.body.innerHTML.length;
if(contentLength<1){alert("您还没有填写内容!");IframeID.focus();return false;}
if(document.getElementById("caption").value.length<1){alert("呵呵，您忘了填写标题啦！");document.getElementById("caption").focus();return false;};
if(document.getElementById("caption").value.length>70){alert("对不起，标题的字符超出了限制！");document.getElementById("caption").focus();return false;};
if(document.getElementById("safecode").value.length<1){alert("您还没有填写验证码！");document.getElementById("safecode").focus();return false;};
if(contentLength<2){alert("文章内容不能小于2个字符！");IframeID.focus();return false;}
if(contentLength>maxnum){alert("文章内容不能超过"+maxnum+"个字符！");IframeID.focus();return false;}
document.getElementById("sayb").disabled=true;
document.getElementById("sayb").value="正在发送"
document.getElementById("content").value=cleanHtml(); 
document.say.submit()
}
function Gopreview()
{
if(IsHtmlEdit==0){
	var content=IframeID.document.body.innerHTML
	document.preview.pcontent.value=replaceHtml(content)
	}
else{
	document.preview.pcontent.value=cleanHtml()
	}
document.preview.pcaption.value=document.say.caption.value;
//openwin('preview',750,450);
document.preview.submit()
}

function Goreset(){IframeID.document.body.innerHTML=document.say.content.value;}



function replaceHtml(str){
str = str.replace(/\<p>/gi,"[$p]");
str = str.replace(/\<\/p>/gi,"[$\/p]");
str = str.replace(/\<br>/gi,"[$br]");
str = str.replace(/\<[^>]*>/g,"");
str = str.replace(/\[\$p\]/gi,"<p>");
str = str.replace(/\[\$\/p\]/gi,"<\/p>");
str = str.replace(/\[\$br\]/gi,"<br>");
return str
}
//---替换内容
function replace()
{
if(ns6)return false;
  var arr = showModalDialog("pic/edit/replace.html", "", "dialogWidth:22em;dialogHeight:13em;status:0;help:0;scroll:no;");
	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 = KK_rCode(con,a,b,true);
		}else{
			con = KK_rCode(con,a,b);
		}
		IframeID.document.body.innerHTML = con;
	}
	else IframeID.focus();
}
function KK_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;
FormatText('InsertImage',url)
}

function RealPlay(){
if(ns6){
var enter = prompt("请输入网上RealPlay播放文件的地址","http://");
if (!enter || enter=="http://")return;
Insert("[RM]"+enter+"[/RM]")
}else{	
var arr = showModalDialog("pic/edit/RealPlay.htm", "", "dialogWidth:22em; dialogHeight:11em;status:0;help:0;scroll:no;");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
}
function MediaPlayer(){
if(ns6){
var enter = prompt("请输入网上MediaPlayer文件的地址","http://");
if (!enter || enter=="http://")return;
Insert("[MP]"+enter+"[/MP]")
}else{
var arr = showModalDialog("pic/edit/MediaPlayer.htm", "", "dialogWidth:22em; dialogHeight:11em; status:0;help:0;scroll:no;");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
}

function flash(){
if(ns6){
var enter = prompt("请输入网上 Flash 文件的地址","http://");
if (!enter || enter=="http://")return;
Insert("[FLASH]"+enter+"[/FLASH]")
}else{
var arr = showModalDialog("pic/edit/flash.htm", "", "dialogWidth:22em; dialogHeight:11em; status:0;help:0;scroll:no;");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
}
function Csound() {
var enter  = prompt("文件后缀名：mid、rmi\n请输入背景音乐地址", "http://");
if (!enter || enter=="http://")return;
Insert("[SOUND]"+enter+"[/SOUND]")
}

//投票...>>>
function SetNum(obj){
	str = '';
	if(!obj.value){
		obj.value = 1;
	}
	for(i=1;i<=obj.value;i++){
		str += '<div>选项'+i+'：<input type="text" name="votes'+i+'" style="width:70%" \/><\/div>';
	}
	document.getElementById("optionid").innerHTML=str+'<input type="hidden" name="autovalue" value="'+obj.value+'" \/>';
}
//..<<

//控制文本框
function textarea_Size(num,obj)
{
	if (parseInt(obj.height)+num>=250) {
		obj.height = parseInt(obj.height) + num;	
	}
	if (num>0)
	{
		obj.width="99%";	
	}
}
function CheckLength(maxnum){alert("最大字符为 "+maxnum+ " 字节\n您的内容已有 "+IframeID.document.body.innerHTML.length+" 字节");}

//----------特殊帖
function Grade() {
var enter  =prompt("请输入级别数值","1");
if (enter){if (isNaN(enter) || enter<1 || enter>20) {alert("错误！" + "\n" + "您必须输入等级1到20的数值");return;}
Especial("[GRADE="+enter+"]","[/GRADE]")}
}
function Name() {
var FoundErrors = '';
var enter  =prompt("请输入指定读者的名称","随冰");
if (enter){Especial("[USERNAME="+enter+"]","[/USERNAME]")}
}	
function Coin() {
var enter  =prompt("请输入拥有多少钱才可以看帖","1000");
if (isNaN(enter)) {alert("错误！\n您必须输入金钱的数值");return;}
if (enter){Especial("[COIN="+enter+"]","[/COIN]")}
}

function Buypost() {
var enter =prompt("注意：只可以发表有价值的帖子赚取金钱，否则会被管理员开除账号！\n请输入您的帖子出售价格","100");
if (isNaN(enter)){alert("错误！\n您必须输入数值价格");return;}
if (enter){Especial("[BUYPOST="+enter+"]","[/BUYPOST]");}
}
function Mark() {
var enter =prompt("请输入可以看帖所需达到的积分","3");
if (isNaN(enter)){alert("错误！\n您必须输入数值积分");return};
if (enter){Especial("[MARK="+enter+"]","[/MARK]")}
}
function Showdate() {
var enter=prompt("请输入日期按这样格式2006-10-1,该帖将这天以后方能浏览","2006-10-1");
if (enter){Especial("[DATE="+enter+"]","[/DATE]")}
}
function Sex() {
var enter=prompt("请输入您指定的性别 男:1  女:0","1");
if (isNaN(enter) || enter>1 || enter<0) {
alert("错误！\n请输入正确性别的数字1或0");return;
}
if(enter){Especial("[SEX="+enter+"]","[/SEX]")}
}

//---------------UBB-------------------------
function Cemail() {
var enter = prompt("请输入邮件地址","");
if (enter){
var p=enter.indexOf('@');
if (p<1 || p==(enter.length-1)){ 
alert("请输入正确的email地址"); return; 
}
Insert("[EMAIL]"+enter+"[/EMAIL]")
}
}
function ybbsize(theSmilie){
var text=prompt("请输入文字", "");
if(text){Insert('[SIZE=' + theSmilie + ']'+ text + '[/SIZE]');}
}
function UBBCOLOR(color){Especial("[COLOR="+color+"]","[/COLOR]")}
function fly() {Especial("[FLY]","[/FLY]")}
function move() {Especial("[MOVE]","[/MOVE]");}
function center() {Especial("[ALIGN=center]","[/ALIGN]")}
function LIGHT() {Especial("[LIGHT]","[/LIGHT]")}
function Cbold() {Especial("[B]","[/B]")}
function Citalic() {Especial("[I]","[/I]")}
function Cunder() {Especial("[U]","[/U]")}
function ying() {Especial("[SHADOW=255,yellow,1]","[/SHADOW]")}
function Code() {Especial("[code]","[/code]")}

function Especial(A,B){
fontbegin=A
fontend=B
fontchuli();
}
function fontchuli(){
if(ns6){
	sel=IframeID.getSelection()
	var html = IframeID.document.body.innerHTML;
	if (sel!=""){
		html = html.replace(sel,fontbegin + sel + fontend);
		IframeID.document.body.innerHTML=html}
	else
		{IframeID.document.body.innerHTML+=(fontbegin +"内容" +  fontend)}
	IframeID.focus()
}else{
	IframeID.focus()
	sel=IframeID.document.selection.createRange();
	if (sel.text!=""){sel.pasteHTML(fontbegin + sel.text + fontend);}
	else{sel.pasteHTML(fontbegin + "内容" + fontend);}
}
}
