document.writeln("<table width=100% height=100% cellpadding=2 cellspacing=0><tr><td align=left><select onChange=\"FormatText('FormatBlock',this[this.selectedIndex].value);\"><option selected>paragraph</option><option value=\"&lt;P&gt;\">BODY</option><option value=\"&lt;H1&gt;\">TITLE1</option><option value=\"&lt;H2&gt;\">TITLE2</option><option value=\"&lt;H3&gt;\">TITLE3</option><option value=\"&lt;H4&gt;\">TITLE4</option><option value=\"&lt;H5&gt;\">TITLE5</option><option value=\"&lt;H6&gt;\">TITLE6</option><option value=\"&lt;PRE&gt;\">DEFAULT</option></select> <select name=\"selectFont\" onChange=\"FormatText('fontname', selectFont.options[selectFont.selectedIndex].value);\"><option selected>Font<option value=\"removeFormat\">default<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>Font size<option value=1>1<option value=2>2<option value=3>3<option value=4>4<option value=5>5<option value=6>6<option value=7>7</option></select>");

document.writeln("<img src=/images/ybb/fgcolor.gif alt=\"font color\" align=absmiddle style=cursor:hand onClick=foreColor()>");
document.writeln("<img src=/images/ybb/replace.gif alt=\"replace\" align=absmiddle style=cursor:hand onClick=replace()>");
document.writeln("<img src=/images/ybb/img.gif alt=\"pic\" align=absmiddle style=cursor:hand onClick=img()>");
document.writeln("<img alt=\"FLASH\" src=/images/ybb/swf.gif align=absmiddle style=cursor:hand onclick=flash()>");
document.writeln("<img alt=\"Media Player\" src=/images/ybb/mp.gif align=absmiddle style=cursor:hand onclick=MediaPlayer()>");
document.writeln("<img alt=\"RealPlayer\" src=/images/ybb/rm.gif align=absmiddle style=cursor:hand onclick=RealPlay()>");
document.writeln("<img alt=\"face\" src=/images/ybb/em.gif align=absmiddle style=cursor:hand onclick=em()>");

var FormatTextlist="createLink createLink|Unlink Unlink|<br>|bold bold|italic italic|underline underline|superscript superscript|subscript subscript|strikethrough strikethrough|RemoveFormat RemoveFormat|Justifyleft Justifyleft|JustifyCenter JustifyCenter|JustifyRight JustifyRight|justifyfull justifyfull|insertorderedlist insertorderedlist|InsertUnorderedList InsertUnorderedList|Outdent Outdent|indent indent|InsertHorizontalRule InsertHorizontalRule|cut cut|copy copy|paste paste|undo undo|redo redo|selectAll selectAll|unselect unselect|Delete Delete"

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=/images/ybb/"+TextName[1]+".gif alt="+TextName[0]+" style=cursor:hand onClick=FormatText('"+TextName[1]+"')> ");
}
}
document.writeln("<img alt=\"cleancode\" src=/images/ybb/CleanCode.gif align=absmiddle style=cursor:hand onclick=CleanCode()>");
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 ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13 && i==0){i=1;parent.document.yuziform.content.value=document.body.innerHTML;parent.document.yuziform.submit();parent.document.yuziform.submit1.disabled=true;}}<\/script><body onkeydown=ctlent()>');
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.innerHTML=document.getElementById("content").value;
IframeID.document.body.style.fontSize="10pt";


function em(){
var arr = showModalDialog("inc/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("max "+50000+ " letter ,now there are "+IframeID.document.body.innerHTML.length+" letter");}

function emoticon(theSmilie){
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src=/images/images/Emotions/"+theSmilie+".gif>");
}

function DoTitle(addTitle) {
var revisedTitle;var currentTitle = document.yuziform.topic.value;revisedTitle = addTitle+currentTitle;document.yuziform.topic.value=revisedTitle;document.yuziform.topic.focus();
}



function Gopreview()
{
document.preview.content.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("please select a pic:","http://");
if(!url || url=="http://") return;
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src=/images/"+url+">");
}

function RealPlay(){
var arr = showModalDialog("inc/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("inc/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 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);
}
}
