<%dim bodyid,htmlableID,tmp_uppath:bodyid=trim(request.querystring("bodyid")):htmlableID=trim(request.querystring("htmlableID")):tmp_uppath=trim(request.querystring("uppath"))%>
<head>
<title>HTML 编辑器</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="html_edit/html_edit.css" type="text/css">
<script language="JavaScript">
<!--
var bodyid="<%response.write bodyid%>"
var htmlableID="<%response.write htmlableID%>"

var BrowserInfo = new Object() ;
BrowserInfo.MajorVer = navigator.appVersion.match(/MSIE (.)/)[1];
BrowserInfo.MinorVer = navigator.appVersion.match(/MSIE .\.(.)/)[1];
BrowserInfo.IsIE55OrMore = BrowserInfo.MajorVer >= 6 || ( BrowserInfo.MajorVer >= 5 && BrowserInfo.MinorVer >= 5 );
var is_ie4 = ((parseInt(navigator.appVersion)  == 4) && (navigator.userAgent.toLowerCase().indexOf("msie 5")==-1) && (navigator.userAgent.toLowerCase().indexOf("msie 6")==-1) );

aeObjects = new Array();
var aeFieldnames = new Array();
var DHTMLSafe;
var jk_edit_olddocmd;
var jk_edit_count;
var jk_edit_hot;
var jk_edit_sourceview=false;
var jk_edit_oldfontfamily='';
var jk_edit_oldfontsize='';
var jk_edit_HTMLMode = new Array();

var tableparamobj=new ActiveXObject("DEInsertTableParam.DEInsertTableParam");
tableparamobj.NumRows=3;
tableparamobj.NumCols=3;
tableparamobj.Caption="";
tableparamobj.TableAttrs="border=0 cellpadding=0 cellspacing=0 width=75%";
tableparamobj.CellAttrs="";

var alloweditsource = new Array();
var tabview = new Array();
var jk_edit_defaultfont = new Array();
var jk_edit_baseurl = new Array();
var jk_edit_breakonenter = new Array();
jk_edit_breakonenter[1] = true;
jk_edit_baseurl[1] = document.location;
jk_edit_defaultfont[1] ="" ;
tabview[1] = false;
alloweditsource[1] = true;

function jk_edit_init(num)
{
  <%if bodyid="" or htmlableID="" then response.write "return;"%>
  if (bodyid=="2")
  { eval("document.all.jk_word.value=self.opener."+htmlableID+".value;"); }
  else
  { eval("document.all.jk_word.value=ubb2html(self.opener."+htmlableID+".value);"); }
}

function jk_edit_save(num)
{
  eval("self.opener."+htmlableID+".value=DHTMLSafe.DOM.body.innerHTML;");
  self.close();
}

function jk_edit_initialize(num)
{
  jk_edit_count=num;
  thisContentItem=eval("document.all.jk_word");
  thisForm=thisContentItem;
  while(thisForm.tagName!="FORM"&&thisForm.tagName!="HTML") { thisForm=thisForm.parentElement; }
  if(thisForm.tagName!="HTML")
  {
    DHTMLSafe = eval("thisForm.DHTMLSafe"+num);
    aeObjects[num] = DHTMLSafe;
    aeObjects[thisContentItem.name] = DHTMLSafe;
    aeFieldnames[num] = thisContentItem.name;
    thisForm.onsubmit = jk_edit_onSubmit;
  }
  else
  {
    alert("对不起，操作出错。", "", true);
    return;
  }
  DHTMLSafe.NewDocument();
  DHTMLSafe.BaseURL=jk_edit_baseurl[num];
  set_tbstates(num);
  jk_edit_onLoad(num);
  jk_edit_HTMLMode[num] = false;
}

function jk_edit_onerror(msg, detail, popup)
{
  errwin = this;
  if(popup) errwin = window.open("","","scrollbars=yes,width=500,height=400,resizable=yes", true);
  errwin.document.write("<HR>对不起，操作出错。</H4><P>");
  errwin.document.write(msg);
  errwin.document.write(detail);
  errwin.document.write("<P><P></TD></TR></TABLE><P><HR>");
}

function jk_edit_previewNewWin(p)
{
  prevWin = window.open("", "", "left=40,top=10,width=720,height=540,menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes");
  if (jk_edit_HTMLMode[1] == true) { prevWin.document.write("<body size=2>" + DHTMLSafe.DOM.body.innerText);  }
  else { prevWin.document.write("<body size=2>" + DHTMLSafe.DOM.body.innerHTML);  }
  if (p==0)
  { prevWin.document.title = "内容预览"; }
  else
  {
    prevWin.document.write ("\n<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0></OBJECT>\n<scr"+"ipt language=JavaS"+"cript>WB.ExecWB(7,1);\<\/scr"+"ipt>");
    prevWin.document.close;
  }
}

function jk_edit_onLoad(num)
{
  DHTMLSafe=aeObjects[num];
  if(DHTMLSafe.Busy)
  {
    setTimeout("jk_edit_onLoad("+num+");", 100);
    return;
  }
  if(num==1) window.onunload = jk_edit_onUnload;
  if(jk_edit_defaultfont[num].length)
  { DHTMLSafe.DOM.body.style.font=jk_edit_defaultfont[num]; }
  else
  {
    DHTMLSafe.DOM.body.style.fontFamily="宋体";
    DHTMLSafe.DOM.body.style.fontSize="12px";
  }
  if(oSel=eval('document.all.oQuickFormat'+num))
  {
    var f=new ActiveXObject("DEGetBlockFmtNamesParam.DEGetBlockFmtNamesParam");
    DHTMLSafe.ExecCommand(5012,0,f);
    vbarr = new VBArray(f.Names);
    arr = vbarr.toArray();
    for (var i=0;i<arr.length;i++)
    {
      oOption = document.createElement("OPTION");
      oSel.options.add(oOption);
      oOption.text=arr[i];
      oOption.name=arr[i];
    }
  }
  thisContentItem=eval("document.all.jk_word");
  if(thisContentItem.value.length) { aeObjects[num].DOM.body.innerHTML = thisContentItem.value; }
  else { aeObjects[num].DOM.body.innerHTML = " "; }
  set_tbstates(num);
  if(typeof(aeapi_local_onLoad)=='function') { aeapi_local_onLoad(DHTMLSafe, aeFieldnames[num]); }
  if (typeof(aeapi_onLoad)=='function') { aeapi_onLoad(DHTMLSafe, aeFieldnames[num]); }
}

function jk_edit_onUnload()
{
  var jk_edit_content = "";
  var i;
  for(i=1;i<=jk_edit_count;i++)
  {
    DHTMLSafe=aeObjects[i];
    thisContentItem = eval("document.all.jk_word");
    if(jk_edit_sourceview) jk_edit_editsourceinline(i,false);
    var content = DHTMLSafe.DOM.body.innerHTML;
    thisContentItem.value = content;
  }
}

function jk_edit_onSubmit()
{
  var jk_edit_content = "";
  var i;
  for(i=1;i<=jk_edit_count;i++)
  {
    DHTMLSafe=aeObjects[i];
    if(jk_edit_sourceview) jk_edit_editsourceinline(i,false);
    thisContentItem = eval("document.all.jk_word");
    if(typeof(aeapi_local_onBeforeSave)=='function')
    { jk_edit_content = aeapi_local_onBeforeSave(DHTMLSafe, aeFieldnames[i]); }
    else if (typeof(aeapi_onBeforeSave)=='function')
    { jk_edit_content = aeapi_onBeforeSave(DHTMLSafe, aeFieldnames[i]); }
    else
    { jk_edit_content = jk_edit_onBeforeSave(DHTMLSafe, aeFieldnames[i]); }
    thisContentItem.value = jk_edit_content;
  }
}

function jk_edit_onkeypress(num)
{
  var sel;
  DHTMLSafe=aeObjects[num];
  if(jk_edit_breakonenter[num]||jk_edit_sourceview)
  {
    switch(DHTMLSafe.DOM.parentWindow.event.keyCode)
    {
      case 10:
        DHTMLSafe.DOM.parentWindow.event.keyCode = 13;
        break;
      case 13:
        if(DHTMLSafe.QueryStatus(5051)!=7)
        {
          DHTMLSafe.DOM.parentWindow.event.returnValue = false;
          sel = DHTMLSafe.DOM.selection.createRange();
          sel.pasteHTML("<BR>");
          sel.collapse(false);
          sel.select();
        }
        break;
      default:
        break;
    }
  }
}

function jk_edit_clear()
{
  if (confirm("您真的要清除所写的内容吗？")) { DHTMLSafe.DOM.body.innerHTML=""; }
  DHTMLSafe.focus();
  DHTMLSafe.DOM.body.focus();
}

function jk_edit_onmousedown(num)
{
  if(typeof(document.all.jk_edit_frame) != "undefined")
  {
    if(document.all.jk_edit_frame.style.visibility == "visible")
    {
      cancelTable(false);
      return;
    }
  }
}

function jk_edit_onclick(num) { set_tbstates(num); }

function jk_edit_ondisplaychange(num)
{
  if(DHTMLSafe.Busy) { return; }
  set_tbstates(num);
}

function jk_edit_onmenuaction(itemIndex, num) { jk_edit_onCommand(ContextMenu[itemIndex].cmdId, num); }

function jk_edit_Clear(cmdId, num) { }

function jk_edit_onCommand(cmdId, num)
{
  if (jk_edit_HTMLMode[num]) { alert("请先切换到可视编辑模式。");return; }
  if(typeof(num)=="undefined") { num=jk_edit_hot; }
  DHTMLSafe=aeObjects[num];
  if(cmdId==null) { cmdid=eval(window.event.srcElement.cid); }
  else { cmdid=cmdId; }
  doFocus=true;
  switch(parseInt(cmdid))
  {
    case 5017:
      oSel = DHTMLSafe.DOM.selection;
      if (oSel.type == "Control")
      { jk_edit_imageProperties(num); }
      else
      {
        DHTMLSafe.DOM.selection.createRange().collapse(false);
        onImagewin(num);
      }
      doFocus=false;
      break;
    case 5022:
      onTableWin(num);
      doFocus=false;
      break;
    case 6001:
      if(tabview[num])
      { jk_edit_editsourceinline(num); }
      else
      {
        jk_edit_editsource(num);
        doFocus=false;
      }
      break;
    case 6002:
      jk_edit_about();
      doFocus=false;
      break;
    case 6004:
      jk_edit_onToggleDetails(null, num);
      break;
    case 6006:
      editTableWin(num);
      doFocus=false;
      break;
    case 5016:
      jk_edit_hyperlinkwin(num);
      doFocus=false;
      break;
    case 6007:
      jk_edit_spellcheckwin(num);
      doFocus=false;
      break;
    case 6008:
      jk_edit_specialchars();
      doFocus=false;
      break;
    case 6009:
      oSel = DHTMLSafe.DOM.selection.createRange();
      for (i=0; i<oSel.length; i++)
      {
        if (oSel(i).tagName == "IMG")
        {
          jk_edit_imageProperties(num);
          doFocus=false;
        }
      }
      break;
    case 5032:
      jk_edit_onPaste(num);
      doFocus=false;
      break;
    case 6010:
      oSel = DHTMLSafe.DOM.selection;
      if (oSel.type == "Control")
      {
        alert("您已选中水平线。\n如需插入新的水平线，请先取消选择。");
        return;
      }
      else
      {
        jk_edit_onHr(num);
        doFocus=false;
      }
      break;
    default:
      if(DHTMLSafe.QueryStatus(cmdid)!=1) { DHTMLSafe.ExecCommand(cmdid, 0); }
      break;
  }
  if (doFocus)
  {
    DHTMLSafe.focus();
    DHTMLSafe.DOM.body.focus();
  }
}

function jk_edit_indate()
{
  insertHtml("<%response.write FormatDateTime(now,1)%>");
}

function jk_edit_intime()
{
  insertHtml("<%response.write FormatDateTime(now,3)%>");
}

function jk_edit_inbr()
{
  insertHtml("<br>");
}

function jk_edit_onHr(num)
{
  DHTMLSafe=aeObjects[num];
  DHTMLSafe.focus();
  if (typeof(jk_edit_hrwin) == "undefined" || jk_edit_hrwin.closed) { jk_edit_hrwin = edit_open("win_hr.asp?instance="+num,window,355,205,"s"); }
}

function jk_edit_imageProperties(num)
{
  DHTMLSafe=aeObjects[num];
  DHTMLSafe.focus();
  if (typeof(jk_edit_imgpropwin) == "undefined" || jk_edit_imgpropwin.closed)
  {
    jk_edit_imgpropwin = edit_open("win_img_edit.asp?instance=" + num,window,350,215,"s");
  }
}

function replaceFontsWithSpans(aeObject, oElement, sNewClass)
{
  for(var i=0;i<oElement.childNodes.length;i++) { replaceFontsWithSpans(aeObject, oElement.childNodes[i], sNewClass); }
  if(oElement.tagName=="FONT")
  {
    if(oElement.face=="jk_edit_newclass")
    {
      sPreserve=oElement.innerHTML;
      oNewNode=aeObject.DOM.createElement("SPAN");
      oElement.replaceNode(oNewNode);
      oNewNode.innerHTML=sPreserve;
      oNewNode.className=sNewClass;
    }
    if(oElement.xclass!=null)
    {
      sPreserve=oElement.innerHTML;
      sClass=oElement.xclass;
      oNewNode=aeObject.DOM.createElement("SPAN");
      oElement.replaceNode(oNewNode);
      oNewNode.innerHTML=sPreserve;
      oNewNode.className=sClass;
    }
    else
    {
      var style = "";
      if (oElement.face.length) { style += "font-family: " + oElement.face + ";"; }
      if (oElement.size.length)
      {
        var sizeMap = new Array(7,7,9,12,14,18,24,36);
        var size = oElement.size;
        if (size > 7) size = 7;
        if (size==-1) size = 2;
        if (size==-2) size = 1;
        if (size < -2) size = 1;
        var ptsize = sizeMap[size];
        style += "font-size: " + ptsize + "pt;";
      }
      if (oElement.color.length) { style += "color: " + oElement.color + ";"; }
      if (style.length)
      {
        sPreserve=oElement.innerHTML;
        oNewNode=aeObject.DOM.createElement("SPAN");
        oElement.replaceNode(oNewNode);
        oNewNode.innerHTML=sPreserve;
        oNewNode.style.cssText=style;
      }
    }
  }
}

function condenseSpans(aeObject, oElement, oPrevious)
{
  for(var i=0;i<oElement.childNodes.length;i++)
  {
    var child = oElement.childNodes[i];
    oElement = condenseSpans(aeObject, child, oElement);
  }
  if (oElement.tagName=="SPAN" && oPrevious != null && oPrevious.tagName =="SPAN")
  {
    if (oElement.innerText == oPrevious.innerText)
    {
      cClass=oElement.className;
      pClass=oPrevious.className;
      if(pClass.length && !cClass.length) { oElement.setAttribute("class", pClass); }
      var css = oPrevious.style.cssText;
      var styleProps = css.split("; ");
      var curStyleProps = oElement.style.cssText.split("; ");
      for (var i=0;i<styleProps.length;i++)
      {
        var kv = styleProps[i].split(":");
        var key = kv[0];
        var value = kv[1];
        var hasProp = false;
        for (var k=0;k<curStyleProps.length;k++)
        {
          var ckv = curStyleProps[k].split(":");
          var cProp = ckv[0];
          var cValue = ckv[1];
          if (cProp == key)
          {
            hasProp = true;
            break;
          }
        }
        if (!hasProp) { oElement.style.cssText = oElement.style.cssText + ";" + key + ":" + value; }
      }
      oPrevious.removeNode(false);
      return oElement;
    }
  }
  return oPrevious;
}

function removeExtraniousSpans(aeObject, oElement, oPrevious)
{
  for(var i=0;i<oElement.childNodes.length;i++) { removeExtraniousSpans(aeObject, oElement.childNodes[i], oElement); }
  if (oElement.tagName=="SPAN" && oPrevious != null && oPrevious.tagName =="P")
  {
    if (oElement.innerText == oPrevious.innerText)
    {
      cClass=oElement.className;
      pClass=oPrevious.className;
      if(cClass.length) { oPrevious.setAttribute("class", pClass); }
      var css = oPrevious.style.cssText;
      var styleProps = css.split("; ");
      var curStyleProps = oElement.style.cssText.split("; ");
      for (var i=0;i<curStyleProps.length;i++)
      {
        var kv = curStyleProps[i].split(":");
        var cProp = kv[0];
        var cValue = kv[1];
        var hasProp = false;
        for (var k=0;k<styleProps.length;k++)
        {
          var pkv = styleProps[k].split(":");
          var pProp = pkv[0];
          var pValue = pkv[1];
          if (cProp == pProp)
          {
            hasProp = true;
            break;
          }
        }
        if (!hasProp) { oPrevious.style.cssText = oPrevious.style.cssText + ";" + cProp + ":" + cValue; }
      }
      oElement.removeNode(false);
    }
  }
}

function jk_edit_onPaste(num)
{
  DHTMLSafe=aeObjects[num];
  //window.event.returnValue = true;
  var tmp_frm=document.frames("jk_tmp_frame");
  //var tmp_frm=frames["jk_tmp_frame"];
  //var tmp_frm=document.getElementById("jk_tmp_frame").contentWindow;
  //tmp_frm.document.open();
  //tmp_frm.document.close();
  tmp_frm.document.body.contentEditable = "True";
  tmp_frm.document.charset="GB2312";
  tmp_frm.document.execCommand("Paste");
  var tmppaste=tmp_frm.document.body.innerHTML;	//outerHTML
  tmp_frm.document.clear();
  insertHtml(tmppaste);
  //var tr = DHTMLSafe.DOM.selection.createRange();
  //tr.execCommand("Paste");
  //replaceFontsWithSpans(DHTMLSafe, DHTMLSafe.DOM.body, null);
  //condenseSpans(DHTMLSafe, DHTMLSafe.DOM.body, null);
}

function jk_edit_onPasteWord()
{
  if (BrowserInfo.IsIE55OrMore)
  { cleanAndPaste(GetClipboardHTML()); }
  else if (confirm("这个操作需要Internet Explorer version 5.5 或以上版本. 你需要粘贴它而不去除格式吗?"))
  { decCommand(DECMD_PASTE); }
}

function jk_edit_onPastetext()
{
  var sText = HTMLEncode(clipboardData.getData("Text"));
  sText = sText.replace(/\n/g,'<BR>');
  insertHtml(sText);
}

function HTMLEncode(text)
{
  text = text.replace(/&/g, "&amp;") ;
  text = text.replace(/"/g, "&quot;") ;
  text = text.replace(/</g, "&lt;") ;
  text = text.replace(/>/g, "&gt;") ;
  text = text.replace(/'/g, "&#146;") ;
  return text ;
}

function GetClipboardHTML()
{
  var oDiv = document.getElementById("divTemp")
  oDiv.innerHTML = "";
  var oTextRange = document.body.createTextRange();
  oTextRange.moveToElementText(oDiv);
  oTextRange.execCommand("Paste");
  var sData = oDiv.innerHTML;
  oDiv.innerHTML = "";
  return sData;
}

function cleanAndPaste( html )
{
  html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
  html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
  html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3");
  html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
  html = html.replace(/<\\?\?xml[^>]*>/gi, "");
  html = html.replace(/<\/?\w+:[^>]*>/gi, "");
  html = html.replace(/&nbsp;/, " " );
  var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi");
  html = html.replace( re, "<div>$2</div>" );
  insertHtml( html );
}

function jk_edit_onToggleDetails(bVal, num)
{
  DHTMLSafe=aeObjects[num];
  if (bVal == null) { DHTMLSafe.ShowDetails = !(DHTMLSafe.ShowDetails); }
  else { DHTMLSafe.ShowDetails = bVal; }
}

function editTableWin(num) { ditTbl = edit_open("win_table_edit.asp",window,290,355,"s"); }

function onTableWin(num)
{
  DHTMLSafe=aeObjects[num];
  if(DHTMLSafe.QueryStatus(5022) == 1)
  {
    DHTMLSafe.focus();
    return;
  }
  jk_edit_hot = num;
  arr = edit_open("win_table.asp",window,350,250,"s");
}

function onTable(num)
{
  if (jk_edit_HTMLMode[num]) { return; }
  DHTMLSafe=aeObjects[num];
  if(DHTMLSafe.QueryStatus(5022) == 1)
  {
    DHTMLSafe.focus();
    return;
  }
  if(  document.all.jk_edit_frame.style.visibility == "visible" )
  {
    cancelTable();
    return;
  }
  var str = "<div id=\"tblsel\" style=\"background-color:#000066;position:absolute;";
  str = str + "width:0;height:0;z-index:-1;\"></div>";
  str = str + makeTable(4, 5);
  str = str + "<div style=\"text-align:center;background-color:menu;font-size: 12px\" id=\"tblstat\">插入表格</div>";
  var ifrm = document.frames("jk_edit_frame");
  var obj=eval("document.all.jk_edit_tbtn"+num);
  var x=0,y=0;
  ifrm.document.body.innerHTML=str;
  while(obj.tagName!="BODY")
  {
    x+=obj.offsetLeft;
    y+=obj.offsetTop;
    obj=obj.offsetParent;
  }
  document.all.jk_edit_frame.style.pixelTop = y + 24;
  document.all.jk_edit_frame.style.pixelLeft = x;
  document.all.jk_edit_frame.style.pixelWidth = 0;
  document.all.jk_edit_frame.style.pixelHeight = 0;
  document.all.jk_edit_frame.style.visibility = "visible";
  jk_edit_hot=num;
  document.frames("jk_edit_frame").document.body.onmouseover = paintTable;
  document.frames("jk_edit_frame").document.body.onclick = insertTable;
  if(typeof(document.onmousedown)=="function") { jk_edit_olddocmd = document.onmousedown; }
  else { jk_edit_olddoccmd=null; }
  document.onmousedown = cancelTable;
  DHTMLSafe.onmousedown = cancelTable;
  event.cancelBubble = true;
  ifrm.document.body.onselectstart=new Function("return false;");
  document.all.jk_edit_frame.style.pixelWidth = ifrm.document.all.oTable.offsetWidth + 3
  document.all.jk_edit_frame.style.pixelHeight = ifrm.document.all.oTable.offsetHeight + 3 + ifrm.document.all.tblstat.offsetHeight;
}

function insertTable(rows, cols, attrs, num)
{
  if(typeof(num)=="undefined") { num=jk_edit_hot; }
  DHTMLSafe=aeObjects[num];
  if (typeof(rows) == "undefined")
  {
    var se = document.frames('jk_edit_frame').window.event.srcElement;
    if(se.tagName!='TD')
    {
      cancelTable();
      return;
    }
    tableparamobj.NumRows = se.parentElement.rowIndex + 1;
    tableparamobj.NumCols = se.cellIndex + 1;
    tableparamobj.TableAttrs = "style='border-collapse:collapse;' border=1 bordercolor=#000000 cellPadding=1 cellSpacing=0 width=98% align=center";
    cancelTable();
  }
  else
  {
    tableparamobj.NumRows = rows;
    tableparamobj.NumCols = cols;
    tableparamobj.TableAttrs = attrs;
  }
  DHTMLSafe.ExecCommand(5022,0, tableparamobj);
  DHTMLSafe.focus();
}

function paintTable()
{
  var se = document.frames('jk_edit_frame').window.event.srcElement;
  var sr, sc, tbl, fAll;
  fAll = document.frames('jk_edit_frame').document.all;
  if(se.tagName!='TD')
  {
    sr = 0;
    sc = 0;
    var str="&nbsp;Cancel";
    fAll.tblsel.style.width = 0;
    fAll.tblsel.style.height = 0;
    return;
  }
  tbl=fAll.oTable;
  sr=se.parentElement.rowIndex;
  sc=se.cellIndex;
  if(!is_ie4)
  {
    if(tbl.rows.length == sr+1)
    {
      var r = tbl.insertRow(-1);
      var td;
      for(var i=0;i<tbl.rows(1).cells.length;i++)
      {
        td = r.insertCell(-1);
        td.innerHTML = "&nbsp;";
        td.style.pixelWidth = 20;
        td.style.pixelHeight = 20;
      }
      var bdy = document.frames("jk_edit_frame").document.body;
      var ifrm = document.frames("jk_edit_frame");
      document.all.jk_edit_frame.style.pixelWidth = ifrm.document.all.oTable.offsetWidth + 3
      document.all.jk_edit_frame.style.pixelHeight = ifrm.document.all.oTable.offsetHeight + 3 +
      ifrm.document.all.tblstat.offsetHeight;
    }
    if(tbl.rows(1).cells.length == sc+1)
    {
      var td;
      for(var i=0;i<tbl.rows.length;i++)
      {
        td = tbl.rows(i).insertCell(-1);
        td.innerHTML = "&nbsp;";
        td.style.pixelWidth = 20;
        td.style.pixelHeight = 20;
      }
      var bdy = document.frames("jk_edit_frame").document.body;
      document.all.jk_edit_frame.style.pixelWidth = bdy.createTextRange().boundingWidth + 5;
      document.all.jk_edit_frame.style.pixelHeight = bdy.createTextRange().boundingHeight + 5;
    }
  }
  var str=(sr+1) + "×" + (sc+1) + "表格";
  fAll.tblsel.style.width = se.offsetWidth*(sc+1)+5;
  fAll.tblsel.style.height = se.offsetHeight*(sr+1)+5;
  fAll.tblstat.innerHTML = str;
}

function makeTable(rows, cols)
{
  var a, b, str, n;
  str = "<table style=\"table-layout:fixed;border-style:solid; cursor:default;\" ";
  str = str + "id=\"oTable\" cellpadding=\"0\" ";
  str = str + "cellspacing=\"0\" cols=" + cols;
  str = str + " border=6>\n";
  for (a=0;a<rows;a++)
  {
    str = str + "<tr>\n";
    for(b=0;b<cols;b++)
    {
      str = str + "<td width=\"20\">"
      str = str + "&nbsp;</td>\n";
    }
    str = str + "</tr>\n";
  }
  str = str + "</table>"
  return str;
}

function cancelTable(a)
{
  document.onmousedown=null;
  document.all.jk_edit_frame.style.visibility = "hidden";
  document.all.jk_edit_frame.style.pixelWidth = 0;
  document.all.jk_edit_frame.style.pixelHeight = 0;
  if(a==false) return;
  if(typeof(jk_edit_olddocmd)=="function")
  {
    jk_edit_olddocmd(false);
    document.onmousedown = jk_edit_olddocmd;
  }
  jk_edit_olddocmd = null;
  document.all.jk_edit_frame.style.pixelWidth = 10;
  document.all.jk_edit_frame.style.pixelHeight = 10;
}

function jk_edit_insertPage()
{
  DHTMLSafe.DOM.selection.createRange().pasteHTML("<br>[pagecute]<br>");
  DHTMLSafe.focus();
  DHTMLSafe.DOM.body.focus();
}

function onFilewin() { edit_open("win_file.asp?<%response.write tmp_uppath%>","win_file",400,160,""); }

function jk_edit_insertFile(ftmp,num)
{
  DHTMLSafe.DOM.selection.createRange().pasteHTML(ftmp);
  DHTMLSafe.focus();
  DHTMLSafe.DOM.body.focus();
}

function onImagewin(num)
{
  DHTMLSafe=aeObjects[num];
  DHTMLSafe.focus();
  if (typeof(jk_edit_imgwin) == "undefined" || jk_edit_imgwin.closed)
  {
    var szURL;
    szURL= "win_img.asp?<%response.write tmp_uppath%>";
    jk_edit_imgwin = edit_open(szURL,"wim_img",400,235,"");
  }
}

function onImage(oimg,num)
{
  DHTMLSafe=aeObjects[num];
  DHTMLSafe.DOM.selection.createRange().pasteHTML(oimg);
}

function jk_edit_onBeforeSave(aeObject)
{
  for (var i=0;i<aeObject.DOM.images.length;i++)
  {
    hs=aeObject.DOM.images[i].getAttribute("STYLE",0).height;
    ws=aeObject.DOM.images[i].getAttribute("STYLE",0).width;
    if(hs.length)
    {
      aeObject.DOM.images[i].removeAttribute("HEIGHT", 0);
      aeObject.DOM.images[i].setAttribute("HEIGHT", replaceString("px", "", hs),0);
      aeObject.DOM.images[i].getAttribute("STYLE",0).removeAttribute("HEIGHT",0);
    }
    if(ws.length)
    {
      aeObject.DOM.images[i].removeAttribute("WIDTH", 0);
      aeObject.DOM.images[i].setAttribute("WIDTH", replaceString("px", "", ws),0);
      aeObject.DOM.images[i].getAttribute("STYLE",0).removeAttribute("WIDTH",0);
    }
  }
  for (var k=0;k<aeObject.DOM.all.tags("TABLE").length;k++)
  {
    hs=aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).height;
    ws=aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).width;
    if(hs.length)
    {
      aeObject.DOM.all.tags("TABLE").item(k).removeAttribute("HEIGHT", 0);
      aeObject.DOM.all.tags("TABLE").item(k).setAttribute("HEIGHT", replaceString("px", "", hs),0);
      aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).removeAttribute("HEIGHT",0);
    }
    if(ws.length)
    {
      aeObject.DOM.all.tags("TABLE").item(k).removeAttribute("WIDTH", 0);
      aeObject.DOM.all.tags("TABLE").item(k).setAttribute("WIDTH", replaceString("px", "", ws),0);
      aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).removeAttribute("WIDTH",0);
    }
  }
  var content = aeObject.DOM.body.innerHTML;
  if(content.length) { content = aeObject.FilterSourceCode(content); }
  replaceString("&#65279;", " ", content);
  return content;
}

function jk_edit_submit_form(obj, field)
{
  var i;
  for(i=1;i<=jk_edit_count;i++)
  {
    DHTMLSafe=aeObjects[i];
    if (typeof(aeapi_local_onBeforeSave) == "function") { var jk_edit_content = aeapi_local_onBeforeSave(DHTMLSafe, aeFieldnames[num]); }
    else if (typeof(aeapi_onBeforeSave) == "function") { var jk_edit_content = aeapi_onBeforeSave(DHTMLSafe, aeFieldnames[num]); }
    else { var jk_edit_content = jk_edit_onBeforeSave(DHTMLSafe, aeFieldnames[num]); }
    eval(obj).elements[element_idx].value = jk_edit_content;
  }
  eval(obj).submit();
}

function replaceString(oldS,newS,fullS)
{
  for (var i=0; i<fullS.length; i++) { if (fullS.substring(i,i+oldS.length) == oldS) { fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length); } }
  return fullS;
}

function jk_edit_about() { var wabour=edit_open("win_about.asp",window,400,223,"s"); }

function jk_edit_editsource(num)
{
  DHTMLSafe=aeObjects[num];
  DHTMLSafe.DOM.selection.empty();
  codewin =edit_open("win_source.asp",window,500,500,"s");
}

function jk_edit_editsourceinline(num, bVal)
{
  DHTMLSafe=aeObjects[num];
  thisContentItem=eval("document.all.jk_word");
  if(jk_edit_HTMLMode[num]==bVal) return;
  DHTMLSafe.DOM.selection.empty();
  if(jk_edit_HTMLMode[num])
  {
    document.normaltag.className="latched";
    document.normaltag.type="";
    document.htmltag.className="flat";
    document.htmltag.type="btn";
    if(jk_edit_defaultfont[num].length)
    { DHTMLSafe.DOM.body.style.font=jk_edit_defaultfont[num]; }
    else
    {
      DHTMLSafe.DOM.body.style.fontFamily="宋体";
      DHTMLSafe.DOM.body.style.fontSize="12px";
    }
    thisContentItem.value=DHTMLSafe.DOM.body.createTextRange().text;
    DHTMLSafe.DOM.body.innerHTML = thisContentItem.value;
    jk_edit_HTMLMode[num] = false;
  }
  else
  {
    var re=/((<br>)+)/ig;
    document.normaltag.className="flat";
    document.normaltag.type="btn";
    document.htmltag.className="latched";
    document.htmltag.type="";
    DHTMLSafe.DOM.body.style.fontFamily = "宋体";
    DHTMLSafe.DOM.body.style.fontSize = "12px";
    thisContentItem.value=DHTMLSafe.DOM.body.innerHTML;
    DHTMLSafe.DOM.body.innerHTML = "";
    DHTMLSafe.DOM.body.createTextRange().text = thisContentItem.value.replace(re, "$1\n");
    jk_edit_HTMLMode[num] = true;
  }
}

function jk_edit_specialchars() { jk_edit_specialwin = edit_open("win_specialchars.asp",window,370,250,"s"); }

function jk_edit_quickfont(num)
{
  if (jk_edit_HTMLMode[num]) { return; }
  DHTMLSafe=aeObjects[num];
  oSel=eval('document.all.oQuickFont'+num);
  DHTMLSafe.ExecCommand(5044, 0, oSel.options[oSel.selectedIndex].name);
  DHTMLSafe.focus();
  DHTMLSafe.DOM.body.focus();
  replaceFontsWithSpans(DHTMLSafe, DHTMLSafe.DOM.body, null);
  condenseSpans(DHTMLSafe, DHTMLSafe.DOM.body, null);
}

function jk_edit_quickfontsize(num)
{
  if (jk_edit_HTMLMode[num]) { return; }
  DHTMLSafe=aeObjects[num];
  oSel=eval('document.all.oQuickFontSize'+num);
  DHTMLSafe.ExecCommand(5045, 0, oSel.options[oSel.selectedIndex].value);
  DHTMLSafe.focus();
}

function jk_edit_quickformat(num)
{
  if (jk_edit_HTMLMode[num]) { return; }
  DHTMLSafe=aeObjects[num];
  oSel=eval('document.all.oQuickFormat'+num);
  DHTMLSafe.ExecCommand(5043, 0, oSel.options[oSel.selectedIndex].name);
  DHTMLSafe.focus();
}

function jk_edit_hyperlinkwin(num)
{
  jk_edit_hot=num;
  DHTMLSafe=aeObjects[num];
  DHTMLSafe.focus();
  if(DHTMLSafe.DOM.selection.type=="Control")
  {
    var el=DHTMLSafe.DOM.selection.createRange().commonParentElement();
    var tr = DHTMLSafe.DOM.body.createTextRange();
    tr.moveToElementText(el);
    tr.select();
  }
  if (typeof(jk_edit_linkwin) == "undefined" || jk_edit_linkwin.closed) { jk_edit_linkwin = edit_open("win_hyperlink.asp",window,400,230,"s"); }
}

function jk_edit_imageproperty(num, aWidth, aHeight, aBorder, aSrc, aAlt, aAlign)
{
  DHTMLSafe=aeObjects[num];
  var oSel=DHTMLSafe.DOM.selection.createRange().commonParentElement();
  var tr = DHTMLSafe.DOM.body.createTextRange();
  hs=oSel.getAttribute("STYLE",0).height;
  ws=oSel.getAttribute("STYLE",0).width;
  if (hs.length) { oSel.getAttribute("STYLE",0).removeAttribute("HEIGHT",0); }
  if (ws.length) { oSel.getAttribute("STYLE",0).removeAttribute("WIDTH",0); }
  oSel.width=aWidth;
  oSel.height=aHeight;
  oSel.border=aBorder;
  oSel.src=aSrc;
  oSel.alt=aAlt;
  oSel.align=aAlign;
  DHTMLSafe.focus();
  DHTMLSafe.DOM.body.focus();
  tr.moveToElementText(oSel);
  tr.collapse(false);
  tr.select();
}

function jk_edit_hyperlink(num, ivar, iHref, iTarget, iStyle, iClass, iName)
{
  DHTMLSafe=aeObjects[num];
  var uid="ae"+Math.random().toString();
  if(iHref=="" && !iName.length)
  { if(DHTMLSafe.QueryStatus(5050)==3) { DHTMLSafe.ExecCommand(5050); } }
  else
  {
    var trSel=DHTMLSafe.DOM.selection.createRange();
    if(trSel.compareEndPoints("StartToEnd",trSel)==0)
    {
      txtHTML="<a href=\""+iHref+"\" ";
      if(iTarget.length) { txtHTML+="target=\""+iTarget+"\" "; }
      if(iStyle.length) { txtHTML+="style=\""+iStyle+"\" "; }
      if(iClass.length) { txtHTML+="class=\""+iClass+"\" "; }
      if(iName.length) { txtHTML+="name=\""+iName+"\" "; }
      txtHTML+=">"+ivar+"</a>";
      trSel.pasteHTML(txtHTML);
    }
    else
    {
      DHTMLSafe.ExecCommand(5016,2,uid);
      var coll=DHTMLSafe.DOM.all.tags("A");
      for(i=0;i<coll.length;i++)
      {
        if(coll[i].href==uid)
        {
          coll[i].href=iHref;
          if(iTarget.length) coll[i].target=iTarget;
          else coll[i].removeAttribute("TARGET",0);
          if(iStyle.length) { coll[i].style.cssText=iStyle; }
          else { coll[i].style.cssText=""; }
          if(iClass.length) { coll[i].className=iClass; }
          else { coll[i].className=""; }
        }
      }
    }
  }
  DHTMLSafe.focus();
}

function ShowMenu(num)
{
  var menuStrings = new Array();
  var menuStates = new Array();
  var state;
  var i;
  var idx = 0;
  jk_edit_hot=num;
  DHTMLSafe=aeObjects[num];
  ContextMenu.length = 0;
  if(alloweditsource[num]) { i=0; }
  else { i=2; }
  for (i=0;i<GeneralContextMenu.length; i++) { ContextMenu[idx++] = GeneralContextMenu[i]; }
  if (DHTMLSafe.QueryStatus(5021) != 1) { for (i=0; i<TableContextMenu.length; i++) { ContextMenu[idx++] = TableContextMenu[i]; } }
  var tr = DHTMLSafe.DOM.selection.createRange();
  if (DHTMLSafe.DOM.selection.type == "Control") { for (i=0; i<ImageContextMenu.length; i++) { ContextMenu[idx++] = ImageContextMenu[i]; } }
  for (i=0;i<AboutContextMenu.length; i++) { ContextMenu[idx++] = AboutContextMenu[i]; }
  for (i=0; i<ContextMenu.length; i++)
  {
    menuStrings[i] = ContextMenu[i].string;
    if ((menuStrings[i] != MENU_SEPARATOR) && (ContextMenu[i].cmdId < 6000)) { state = DHTMLSafe.QueryStatus(ContextMenu[i].cmdId); }
    else { state = 3; }
    if (state == 1 || state == 0) { menuStates[i] = 2; }
    else if (state == 3 || state == 11) { menuStates[i] = 0; }
    else { menuStates[i] = 1; }
    if (ContextMenu[i].cmdId == 6004)
    {
      if (DHTMLSafe.ShowDetails) { menuStates[i] = 1; }
      else { menuStates[i] = 0; }
    }
    if(ContextMenu[i].cmdId == 6001)
    {
      if(jk_edit_sourceview) { menuStates[i] = 1; }
      else { menuStates[i] = 0; }
    }
  }
  DHTMLSafe.SetContextMenu(menuStrings, menuStates);
}

function ContextMenuItem(string, cmdId)
{
  this.string = string;
  this.cmdId = cmdId;
}

function QueryStatusItem(command, element)
{
  this.command = command;
  this.element = element;
}

var MENU_SEPARATOR = "";
var ContextMenu = new Array();
var GeneralContextMenu = new Array();
var AboutContextMenu = new Array();
var TableContextMenu = new Array();
var ImageContextMenu = new Array();
var genId = 0;
var abId = 0;
var tblId = 0;
var imgId = 0;

GeneralContextMenu[genId++] = new ContextMenuItem("编辑源代码", 6001);
GeneralContextMenu[genId++] = new ContextMenuItem(MENU_SEPARATOR, 0);

if (!is_ie4)
{
  TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
  TableContextMenu[tblId++] = new ContextMenuItem("表格属性", 6006);
}

TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[tblId++] = new ContextMenuItem("插入行", 5021);
TableContextMenu[tblId++] = new ContextMenuItem("删除行", 5007);
TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[tblId++] = new ContextMenuItem("插入列", 5020);
TableContextMenu[tblId++] = new ContextMenuItem("删除列", 5006);
TableContextMenu[tblId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
TableContextMenu[tblId++] = new ContextMenuItem("插入单元格", 5019);
TableContextMenu[tblId++] = new ContextMenuItem("删除单元格", 5005);
TableContextMenu[tblId++] = new ContextMenuItem("合并单元格", 5029);
TableContextMenu[tblId++] = new ContextMenuItem("拆分单元格", 5047);

ImageContextMenu[imgId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
ImageContextMenu[imgId++] = new ContextMenuItem("图片属性", 6009);

GeneralContextMenu[genId++] = new ContextMenuItem("剪切", 5003) ;
GeneralContextMenu[genId++] = new ContextMenuItem("拷贝", 5002) ;
GeneralContextMenu[genId++] = new ContextMenuItem("粘贴", 5032) ;
GeneralContextMenu[genId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
GeneralContextMenu[genId++] = new ContextMenuItem("查找", 5008);
GeneralContextMenu[genId++] = new ContextMenuItem("全部显示", 6004);

AboutContextMenu[abId++] = new ContextMenuItem(MENU_SEPARATOR, 0);
AboutContextMenu[abId++] = new ContextMenuItem("关于编辑器", 6002);

function jk_edit_m_out(src)
{
  if(src.state==0) return;
  if(src.state==2) { src.className="latched"; return; }
  if(src.type=="btn")
  {
    window.status="";
    src.className="flat";
  }
}

function jk_edit_m_over(src)
{
  if(src.state==0) return;
  if(src.state==2) return;
  if(src.type=="btn")
  {
    window.status=src.alt;
    src.className="outset";
  }
}

function jk_edit_m_down(src)
{
  if(src.state==0) return;
  if(src.type=="btn") { src.className="inset"; }
}

function jk_edit_m_up(src)
{
  if(src.state==0) return;
  if(src.state==2) { src.className="latched"; return; }
  if(src.type=="btn") { src.className="outset"; }
}

function set_tbstates(num)
{
  var pbtn;
  var cid;
  var state;
  DHTMLSafe=aeObjects[num];
  jk_edit_tbar=eval("jk_edit_tbar"+num);
  if(DHTMLSafe.QueryStatus(5002)!=DHTMLSafe.QueryStatus(5003)) return;
  for(var i=0;i<jk_edit_tbar.all.length;i++)
  {
    pbtn= jk_edit_tbar.all(i);
    cid=pbtn.cid;
    if(cid < 6000 && cid!=5016 && cid!=5050)
    {
      if (!is_ie4) { pbtn.style.visibility="visible"; }
      state=DHTMLSafe.QueryStatus(cid)
      if(state == 1 || state == 0)
      {
        if(pbtn.state!=0)
        {
          pbtn.className = "disabled";
          pbtn.state = 0;
        }
      }
      else if (state == 3 || state == 11)
      {
        if(pbtn.state!=1)
        {
          pbtn.className = "flat";
          pbtn.state = 1;
        }
      }
      else
      {
        if(pbtn.state!=2)
        {
          pbtn.className = "latched";
          pbtn.state = 2;
        }
      }
    }
    else if(cid==6004)
    {
      if(DHTMLSafe.ShowDetails)
      {
        if(pbtn.state!=2)
        {
          pbtn.className = "latched";
          pbtn.state = 2;
        }
      }
      else
      {
        if(pbtn.state!=1)
        {
          pbtn.className = "flat";
          pbtn.state = 1;
        }
      }
    }
  }
  if(oSel=eval('document.all.oQuickFont'+num))
  {
    if(DHTMLSafe.QueryStatus(5044)!=1&&DHTMLSafe.DOM.selection.type!="control")
    {
      if(oSel.disabled) oSel.disabled=false;
      fontname=DHTMLSafe.ExecCommand(5013);
      if(fontname!=""&&fontname!=null)
      {
        fCreateNew=true;
        for(i=0;i<oSel.options.length;i++)
        {
          if(oSel.options[i].name==fontname)
          {
            if(!oSel.options[i].selected) { oSel.options[i].selected=true; }
            fCreateNew=false;
          }
        }
        if(fCreateNew)
        {
          var oOption = document.createElement("OPTION");
          oSel.options.add(oOption,0);
          oOption.text = fontname;
          oOption.name = fontname;
          oOption.selected=true;
        }
      }
      else
      { oSel.selectedIndex=-1; }
    }
    else
    { if(!oSel.disabled) oSel.disabled=true; }
  }
  if(oSel=eval('document.all.oQuickFontSize'+num))
  {
    if(DHTMLSafe.QueryStatus(5045)!=1&&DHTMLSafe.DOM.selection.type!="control")
    {
      if(oSel.disabled) oSel.disabled=false;
      fs=DHTMLSafe.ExecCommand(5014);
      if(fs!=null&&fs!="")
      {
        for(i=0;i<oSel.options.length;i++)
        {
          if(oSel.options[i].name=="jk_edit_fs"+fs&&!oSel.options[i].selected)
          { oSel.options[i].selected=true; }
        }
      }
      else
      { oSel.selectedIndex=-1; }
    }
    else
    { if(!oSel.disabled) oSel.disabled=true; }
  }
  if(oSel=eval('document.all.oQuickFormat'+num))
  {
    if(DHTMLSafe.QueryStatus(5043)!=1&&DHTMLSafe.DOM.selection.type!="control")
    {
      if(oSel.disabled) oSel.disabled=false;
      fmt=DHTMLSafe.ExecCommand(5011);
      if(fmt!=""&&fmt!=null)
      { for(i=0;i<oSel.options.length;i++) { if(oSel.options[i].name==fmt&&!oSel.options[i].selected) { oSel.options[i].selected=true; } } }
      else
      { oSel.selectedIndex=-1; }
    }
    else
    { if(!oSel.disabled) oSel.disabled=true; }
  }
}

function aeapi_onLoad(aeObject) { aeObject.ShowBorders = true; }

function aeapi_onBeforeSave(aeObject)
{
  for (var i=0;i<aeObject.DOM.images.length;i++)
  {
    hs=aeObject.DOM.images[i].getAttribute("STYLE",0).height;
    ws=aeObject.DOM.images[i].getAttribute("STYLE",0).width;
    if(hs.length)
    {
      aeObject.DOM.images[i].removeAttribute("HEIGHT", 0);
      aeObject.DOM.images[i].setAttribute("HEIGHT", replaceString("px", "", hs),0);
      aeObject.DOM.images[i].getAttribute("STYLE",0).removeAttribute("HEIGHT",0);
    }
    if(ws.length)
    {
      aeObject.DOM.images[i].removeAttribute("WIDTH", 0);
      aeObject.DOM.images[i].setAttribute("WIDTH", replaceString("px", "", ws),0);
      aeObject.DOM.images[i].getAttribute("STYLE",0).removeAttribute("WIDTH",0);
    }
  }
  for (var k=0;k<aeObject.DOM.all.tags("TABLE").length;k++)
  {
    hs=aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).height;
    ws=aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).width;
    if(hs.length)
    {
      aeObject.DOM.all.tags("TABLE").item(k).removeAttribute("HEIGHT", 0);
      aeObject.DOM.all.tags("TABLE").item(k).setAttribute("HEIGHT", replaceString("px", "", hs),0);
      aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).removeAttribute("HEIGHT",0);
    }
    if(ws.length)
    {
      aeObject.DOM.all.tags("TABLE").item(k).removeAttribute("WIDTH", 0);
      aeObject.DOM.all.tags("TABLE").item(k).setAttribute("WIDTH", replaceString("px", "", ws),0);
      aeObject.DOM.all.tags("TABLE").item(k).getAttribute("STYLE",0).removeAttribute("WIDTH",0);
    }
  }
  var content = aeObject.DOM.body.innerHTML;
  if(content.length) { content = aeObject.FilterSourceCode(content); }
  replaceString("&#65279;", " ", content);
  return content;
}

function ubbcode()
{
  if (!validateMode()) { return; }
  cont=getPureHtml(Composition.document.body.innerHTML);
  var aryCode0 = new Array("<b>","[b]","</b>","[/b]","<p","[p","</p>","[/p]","<a href=","[url=","</a>","[/url]");
  var aryCode1 = new Array("<EM>","[i]","</EM>","[/i]","<u>","[u]","</u>","[/u]","<ul>","[list]","</ul>","[/list]","<ol>","[list=1]","</ol>","[/list]");
  var aryCode2 = new Array("<li>","[*]","</li>","","<font color=","[color=","<font face=","[face=","<font size=","[size=");
  var aryCode9 = new Array(">","]","<","[","</","[/");
  var aryCode = aryCode0.concat(aryCode1).concat(aryCode2).concat(aryCode9);
  for (var i=0;i<aryCode.length;i+=2) { cont=rCode(cont,aryCode[i],aryCode[i+1]); }
  eval("self.opener."+bodyID+".value=cont;");
  self.close();
}

function ubb2html(str)
{
  if (str=="") { return str; }
  var aryCode0 = new Array("<br>","\n","<b>","\\[b]","</b>","\\[/b]","<p","\\[p","</p>","\\[/p]","<a href=","\\[url=","</a>","\\[/url]");
  var aryCode1 = new Array("<i>","\\[i]","</i>","\\[/i]","<u>","\\[u]","</u>","\\[/u]");
  var aryCode = aryCode0.concat(aryCode1);
  for (var i=0;i<aryCode.length;i+=2) { str=rCode(str,aryCode[i+1],aryCode[i]); }
  return str;
}

function rCode(s,a,b)
{
  var r = new RegExp(a,"gi");
  return s.replace(r,b);
}

function insertHtml(html)
{
  if (DHTMLSafe.DOM.selection.type.toLowerCase() != "none") { DHTMLSafe.DOM.selection.clear(); }
  DHTMLSafe.DOM.selection.createRange().pasteHTML(html);
  SetFocus();
}

function SetFocus()
{
  if (BrowserInfo.IsIE55OrMore) { DHTMLSafe.DOM.focus(); }
  else {DHTMLSafe.focus(); }
}

function edit_open(nurl,nname,nwidth,nheight,otype)
{
  var Left_size=0;
  var Top_size=0;
  if (nwidth==0 || nheight==0)
  {
    nwidth=screen.width-8;
    nheight=screen.height-55;
  }
  else
  {
    Left_size=(screen.width) ? (screen.width-nwidth)/2 : 0;
    Top_size=(screen.height) ? (screen.height-nheight)/2 : 0;
  }
  nurl="html_edit/"+nurl;
  if (otype=="s")
  { return window.showModalDialog(nurl,nname,"dialogWidth:"+nwidth+"px;dialogHeight:"+nheight+"px;dialogLeft:"+Left_size+"px;dialogTop:"+Top_size+"px;center:Yes;help:No;resizable:No;status:No;scroll:no;"); }
  else
  { var open_win=window.open(nurl,nname,"width="+nwidth+",height="+nheight+",left="+Left_size+",top="+Top_size+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no"); }
}

function aaa()
{
  //document.all.jk_edit_frame.body.innerhtml="test";
  var ifrm = document.frames("jk_edit_frame");
  var a,b,tmp1;
  ifrm.document.body.innerHTML="test";
  alert(ifrm.document.body.outerText);
}

//<img class=flat onClick="jk_edit_clear();" src="html_edit/images/btn_blank.gif" type="btn" alt="清除全部内容">
-->
</script>
</head>
<body topmargin=0 leftmargin=0>
<form name="add_frm" action="" method="post">
<input type=hidden name=upid value="">
<table border=0 cellspacing=0 cellpadding=0 width="100%" bgcolor="buttonface" class="borderon" ondragstart="window.event.returnValue=false;" onselectstart="window.event.returnValue=false;">
<span id="jk_edit_tbar1" onmouseover="jk_edit_m_over(window.event.srcElement);" onmouseup="jk_edit_m_up(window.event.srcElement);" onmouseout="jk_edit_m_out(window.event.srcElement);" ondragstart="window.event.returnValue=false;" onmousedown=jk_edit_m_down(window.event.srcElement); onselectstart="window.event.returnValue=false;">
<tr class="hidden" id="c2"><td height="5">
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td><img alt="可视编辑模式" class=latched onClick="jk_edit_editsourceinline(1, false);" src="html_edit/images/btn_normal.gif" id="normaltag" name="normaltag"></td>
  <td><img alt="HTML代码编辑模式" id="htmltag" name="htmltag" class=flat onClick="jk_edit_editsourceinline(1, true);" src="html_edit/images/btn_html.gif" type="btn"></td>
  <td><img alt="页面预览" class=flat onClick="jk_edit_previewNewWin(0);" src="html_edit/images/btn_view.gif" type="btn"></td>
  <td><img class=spc src="html_edit/images/space.gif"></td>
  <td><IMG alt="取消" class=flat onclick="jk_edit_onCommand(null,1)" src="html_edit/images/btn_undo.gif" cid="5049" type="btn"></td>
  <td><IMG alt="重做" class=flat onclick="jk_edit_onCommand(null,1)" src="html_edit/images/btn_redo.gif" cid="5033" type="btn">
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td><IMG alt="剪切" class=flat onclick="jk_edit_onCommand(null,1)" src="html_edit/images/btn_cut.gif" cid="5003" type="btn"></td>
  <td><IMG alt="复制" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_copy.gif" cid="5002" type="btn"></td>
  <td><IMG alt="粘贴" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_paste.gif" cid="5032" type="btn"></td>
  <td><IMG alt="纯文本粘贴" class=flat onclick="jk_edit_onPastetext()" src="html_edit/images/btn_pastetext.gif" cid="50320" type="btn"></td>
  <td><IMG alt="来自Word的粘贴" class=flat onclick="jk_edit_onPasteWord()" src="html_edit/images/btn_pasteword.gif" cid="50321" type="btn"></td>
  <td><IMG alt="删除" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_delete.gif" cid="5004" type="btn"></td>
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td><IMG alt="粗体" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_bold.gif" cid="5000" type="btn"></td>
  <td><IMG alt="斜体" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_italics.gif" cid="5023" type="btn"></td>
  <td><IMG alt="下划线" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_underline.gif" cid="5048" type="btn"></td>
  <td><img alt="设置文本格式" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_fgcolor.gif" cid="5009" type="btn"></td>
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td><img alt="插入水平线" class=flat onClick="jk_edit_onCommand(null,1);" cid="6010" src="html_edit/images/btn_hr.gif" type="btn"></td>
  <td><IMG alt="插入表格"  class=flat name=jk_edit_tbtn1 onclick="jk_edit_onCommand(null, 1)" ondragstart="return false" onmouseout=jk_edit_m_out(jk_edit_tdrop1); onmouseover=jk_edit_m_over(jk_edit_tdrop1); src="html_edit/images/btn_table.gif" cid="5022" type="btn"></td>
  <td><IMG alt="快速生成表格" class=flat name=jk_edit_tdrop1 onclick=onTable(1) ondragstart="return false" onmouseout=jk_edit_m_out(jk_edit_tbtn1); onmouseover=jk_edit_m_over(jk_edit_tbtn1); src="html_edit/images/btn_tbdown.gif" style="WIDTH: 9px" cid="5022" type="btn"></td>
  <td><IMG alt="插入图片" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_image.gif" cid="5017" type="btn"></td>
  <td><img alt="插入附件" class=flat onClick="onFilewin();" src="html_edit/images/btn_file.gif" type="btn"></td>
  <td><IMG alt="插入超链接" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_hyperlink.gif" cid="5016" type="btn"></td>
  <td><IMG alt="移除超链接" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_unlink.gif" cid="5050" type="btn"></td>
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td><img alt="清除格式" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_unformat.gif" cid="5034" type="btn"></td>
  <td><img alt="全部显示" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_tag.gif" cid="6004" type="btn"></td>
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td width=5></td>
  <td><IMG alt="保存结果" class=flat onclick="jk_edit_save(1)" src="html_edit/images/btn_save.gif" type="btn"></td>
  <td width=30><a href='javascript:;' onclick="jk_edit_save(1)"><font color=#ff0000><b>保存</b></a></a></td>
  </tr>
  </table>
</td></tr>
<tr class="hidden" id="c2"><td colspan="2" background="html_edit/images/btn_line.gif" height="4" valign="center" ></td></tr>
<tr class="hidden" id="c2"><td height="2" valign="center">
  <table border=0 cellspacing=0 cellpadding=0>
  <tr>
  <td></td>
  <td></td>
  <td><select size="1" id="oQuickFormat1" style="FONT: 12px; VERTICAL-ALIGN: middle; WIDTH: 120px" onchange="jk_edit_quickformat(1);">
</select></td>
  <td><select size="1" id="oQuickFontSize1" style="FONT: 8pt Verdana; VERTICAL-ALIGN: middle; WIDTH: 40px" onchange="jk_edit_quickfontsize(1);">
  <option name="jk_edit_fs1" value=1>1</option>
  <option name="jk_edit_fs2" value=2>2</option>
  <option name="jk_edit_fs3" value=3 selected>3</option>
  <option name="jk_edit_fs4" value=4>4</option>
  <option name="jk_edit_fs5" value=5>5</option>
  <option name="jk_edit_fs6" value=6>6</option>
  <option name="jk_edit_fs7" value=7>7</option>
</select></td>
  <td><select size="1" id="oQuickFont1" style="FONT: 12px; VERTICAL-ALIGN: middle; WIDTH: 120px" onchange="jk_edit_quickfont(1);">
  <option name="宋体" value="宋体" selected>宋体</option>
  <option name="黑体" value="黑体">黑体</option>
  <option name="楷体_GB2312" value="楷体_GB2312">楷体</option>
  <option name="仿宋_GB2312" value="仿宋_GB2312">仿宋</option>
  <option name="隶书" value="隶书">隶书</option>
  <option name="幼圆" value="幼圆">幼圆</option>
  <option name="新宋体" value="新宋体">新宋体</option>
  <option name="细明体" value="细明体">细明体</option>
  <option name="Arial" value="Arial">Arial</option>
  <option name="Arial Black" value="Arial Black">Arial Black</option>
  <option name="Arial Narrow" value="Arial Narrow">Arial Narrow</option>
  <option name="Bradley Hand ITC" value="Bradley Hand ITC">Bradley Hand ITC</option>
  <option name="Brush Script MT" value="Brush Script MT">Brush Script MT</option>
  <option name="Century Gothic" value="Century Gothic">Century Gothic</option>
  <option name="Comic Sans MS" value="Comic Sans MS">Comic Sans MS</option>
  <option name="Courier" value="Courier">Courier</option>
  <option name="Courier New" value="Courier New">Courier New</option>
  <option name="MS Sans Serif" value="MS Sans Serif">MS Sans Serif</option>
  <option name="Script" value="Script">Script</option>
  <option name="System" value="System">System</option>
  <option name="Times New Roman" value="Times New Roman">Times New Roman</option>
  <option name="Viner Hand ITC" value="Viner Hand ITC">Viner Hand ITC</option>
  <option name="Verdana" value="Verdana">Verdana</option>
  <option name="Wide Latin" value="Wide Latin">Wide Latin</option>
  <option name="Wingdings" value="Wingdings">Wingdings</option>
</select></td>
  <td><img class=spc src="html_edit/images/space.gif"></td>
  <td><img alt="左对齐" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_left.gif" cid="5025" type="btn"></td>
  <td><img alt="居中" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_center.gif" cid="5024" type="btn"></td>
  <td><img alt="右对齐" class=flat onClick="jk_edit_onCommand(null,1)" src="html_edit/images/btn_right.gif" cid="5026" type="btn"></td>
  <td><img class=spc src="html_edit/images/space.gif"></td>
  <td><img class=flat onClick="jk_edit_onCommand(null, 1)" cid="5030" type="btn" src="html_edit/images/btn_numlist.gif"></td>
  <td><img alt="项目列表" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_bltlist.gif" cid="5051" type="btn"></td>
  <td><IMG alt="减少缩进" class=flat onclick="jk_edit_onCommand(null,1)" src="html_edit/images/btn_outdent.gif" cid="5031" type="btn"></td>
  <td><IMG alt="增加缩进" class=flat onclick="jk_edit_onCommand(null,1)" src="html_edit/images/btn_indent.gif" cid="5018" type="btn"></td>
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td><IMG alt="插入特殊符号" class=flat onclick="jk_edit_onCommand(null, 1)" src="html_edit/images/specialchar.gif" cid="6008" type="btn"></td>
  <td><IMG alt="插入当前日期" class=flat onclick="jk_edit_indate();" src="html_edit/images/btn_date.gif" type="btn"></td>
  <td><IMG alt="插入当前时间" class=flat onclick="jk_edit_intime();" src="html_edit/images/btn_time.gif" type="btn"></td>
  <td><IMG alt="插入回车" class=flat onclick="jk_edit_inbr();" src="html_edit/images/btn_br.gif" type="btn"></td>
  <td><img alt="插入分页符" class=flat onClick="jk_edit_insertPage();" src="html_edit/images/btn_p.gif" type="btn"></td>
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td><img alt="查找内容" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_find.gif" cid="5008" type="btn" vspace="0" hspace="0"></td>
  <td><img alt="选择全部" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_all.gif" cid="5035" type="btn" vspace="0" hspace="0"></td>
  <td><IMG class=spc src="html_edit/images/space.gif"></td>
  <td><img alt="关于" class=flat onClick="jk_edit_onCommand(null, 1)" src="html_edit/images/btn_about.gif" cid="6002" type="btn" vspace="0" hspace="0"></td>
  </tr>
  </table>
</td></tr>
</span>
</table>
<iframe src="html_edit/win_blank.htm" id="jk_edit_frame" style="POSITION: absolute; VISIBILITY: hidden; WIDTH: 10px; HEIGHT: 10px; Z-INDEX: 2;" marginheight="0" marginwidth="0" scrolling="no"></iframe>
<iframe src="about:blank" id="jk_tmp_frame" style="POSITION: absolute; VISIBILITY: hidden; WIDTH: 10px; HEIGHT: 10px; Z-INDEX: 3;" marginheight="0" marginwidth="0" scrolling="no"></iframe>
<table border=0 cellspacing=0 cellpadding=0 width="100%" bgcolor="buttonface" class="borderon">
<input name="vNum" type="hidden" value="0">
<tr><td colspan="2" id="c2">
<span style="display:none;"><textarea name="jk_word"></textarea></span>
<OBJECT classid=clsid:2D360201-FFF5-11d1-8D03-00A0C959BC0A style="height:expression(body.offsetHeight-56);Z-INDEX: 1; width:100%;" id=DHTMLSafe1>
<PARAM NAME="ActivateApplets" VALUE="0">
<PARAM NAME="ActivateActiveXControls" VALUE="0">
<PARAM NAME="ActivateDTCs" VALUE="-1">
<PARAM NAME="ShowDetails" VALUE="0">
<PARAM NAME="ShowBorders" VALUE="0">
<PARAM NAME="Appearance" VALUE="1">
<PARAM NAME="Scrollbars" VALUE="-1">
<PARAM NAME="ScrollbarAppearance" VALUE="0">
<PARAM NAME="SourceCodePreservation" VALUE="-1">
<PARAM NAME="AbsoluteDropMode" VALUE="0">
<PARAM NAME="SnapToGrid" VALUE="0">
<PARAM NAME="SnapToGridX" VALUE="50">
<PARAM NAME="SnapToGridY" VALUE="50">
<PARAM NAME="UseDivOnCarriageReturn" VALUE="0">
</OBJECT>
<script LANGUAGE="javascript">jk_edit_init(1);</script>
<script LANGUAGE="javascript" FOR="DHTMLSafe1" EVENT="ShowContextMenu"> return ShowMenu(1); </script>
<script LANGUAGE="javascript" FOR="DHTMLSafe1" EVENT="onkeypress"> return jk_edit_onkeypress(1); </script>
<script LANGUAGE="javascript" FOR="DHTMLSafe1" EVENT="onmousedown"> return jk_edit_onmousedown(1); </script>
<script LANGUAGE="javascript" FOR="DHTMLSafe1" EVENT="onclick"> return jk_edit_onclick(1); </script>
<script LANGUAGE="javascript" FOR="DHTMLSafe1" EVENT="DisplayChanged"> return jk_edit_ondisplaychange(1); </script>
<script LANGUAGE="javascript" FOR="DHTMLSafe1" EVENT="ContextMenuAction(itemIndex)"> return jk_edit_onmenuaction(itemIndex); </script>
<script LANGUAGE="javascript">jk_edit_initialize(1);</script>
<div id="divTemp" style="VISIBILITY: hidden; OVERFLOW: hidden; POSITION: absolute; WIDTH: 1px; HEIGHT: 1px"></div>
</td></tr>
</table>
</form>
</body>
</html>