var editorcurrentheight = 400, editorminheight = 400, savedataInterval = 30, editbox = null, editwin = null, editdoc = null, editcss = null, savedatat = null, savedatac = 0, autosave = 1, framemObj = null, cursor = -1, stack = [], initialized = false, postSubmited = false, editorcontroltop = false, editorcontrolwidth = false, editorcontrolheight = false, editorisfull = 0, fulloldheight = 0, savesimplodemode = null;EXTRAFUNC['keydown'] = [];EXTRAFUNC['keyup'] = [];EXTRAFUNC['mouseup'] = [];EXTRAFUNC['showEditorMenu'] = [];var EXTRASELECTION = '', EXTRASEL = null;function newEditor(mode, initialtext) {wysiwyg = parseInt(mode);if(!(BROWSER.ie || BROWSER.firefox || (BROWSER.opera >= 9 || BROWSER.rv))) {allowswitcheditor = wysiwyg = 0;}if(!allowswitcheditor) {$(editorid + '_switcher').style.display = 'none';}if(wysiwyg) {if($(editorid + '_iframe')) {editbox = $(editorid + '_iframe');} else {var iframe = document.createElement('iframe');iframe.frameBorder = '0';iframe.tabIndex = 2;iframe.hideFocus = true;iframe.style.display = 'none';editbox = textobj.parentNode.appendChild(iframe);editbox.id = editorid + '_iframe';}editwin = editbox.contentWindow;editdoc = editwin.document;writeEditorContents(isUndefined(initialtext) ? textobj.value : initialtext);} else {editbox = editwin = editdoc = textobj;if(!isUndefined(initialtext)) {writeEditorContents(initialtext);}addSnapshot(textobj.value);}setEditorEvents();initEditor();}function setEditorTip(s) {$(editorid + '_tip').innerHTML = ' ' + s;}function initEditor() {if(BROWSER.other) {$(editorid + '_controls').style.display = 'none';return;}var buttons = $(editorid + '_controls').getElementsByTagName('a');initesbar();for(var i = 0; i < buttons.length; i++) {if(buttons[i].id.indexOf(editorid + '_') != -1) {buttons[i].href = 'javascript:;';if(buttons[i].id.substr(buttons[i].id.indexOf('_') + 1) == 'fullswitcher') {buttons[i].innerHTML = !editorisfull ? '全屏' : '返回';buttons[i].onmouseover = function(e) {setEditorTip(editorisfull ? '恢复编辑器大小' : '全屏方式编辑');};buttons[i].onclick = function(e) {editorfull();doane();}} else if(buttons[i].id.substr(buttons[i].id.indexOf('_') + 1) == 'simple') {buttons[i].innerHTML = !simplodemode ? '常用' : '高级';buttons[i].onclick = function(e) {editorsimple();doane();}} else {_attachEvent(buttons[i], 'mouseover', function(e) {setEditorTip(BROWSER.ie ? window.event.srcElement.title : e.target.title);});if(buttons[i].id.substr(buttons[i].id.indexOf('_') + 1) == 'url') {buttons[i].onclick = function(e) {discuzcode('unlink');discuzcode('url');doane();};} else {if(!buttons[i].getAttribute('init')) {buttons[i].onclick = function(e) {discuzcode(this.id.substr(this.id.indexOf('_') + 1));doane();};}}}buttons[i].onmouseout = function(e) {setEditorTip('');};}}setUnselectable($(editorid + '_controls'));if(editorcontroltop === false && (BROWSER.ie && BROWSER.ie > 6 || !BROWSER.ie)) {seteditorcontrolpos();var obj = wysiwyg ? editwin.document.body.parentNode : $(editorid + '_textarea');editorcontrolwidth = $(editorid + '_controls').clientWidth - 8;ctrlmObj = document.createElement('div');ctrlmObj.style.display = 'none';ctrlmObj.style.height = $(editorid + '_controls').clientHeight + 'px';ctrlmObj.id = editorid + '_controls_mask';$(editorid + '_controls').parentNode.insertBefore(ctrlmObj, $(editorid + '_controls'));_attachEvent(window, 'scroll', function () { editorcontrolpos(); }, document);}if($(editorid + '_fullswitcher') && BROWSER.ie && BROWSER.ie < 7) {$(editorid + '_fullswitcher').onclick = function () {showDialog('您的浏览器不支持此功能,请升级浏览器版本', 'notice', '友情提示');};$(editorid + '_fullswitcher').className = 'xg1';}if($(editorid + '_svdsecond') && savedatat === null) {savedatac = savedataInterval;autosave = !getcookie('editorautosave_' + editorid) || getcookie('editorautosave_' + editorid) == 1 ? 1 : 0;savedataTime();savedatat = setInterval("savedataTime()", 10000);}checkFocus();}function initesbar() {if(!$(editorid + '_adv_s3')) {return;}var buttons = $(editorid + '_adv_s3').getElementsByTagName('A');var s = '';for(i = 0;i < buttons.length;i++) {if(i/2 == parseInt(i/2)) {s += '
';}s += buttons[i].outerHTML;}$(editorid + '_adv_s3').innerHTML = s;for(var i = 0; i < buttons.length; i++) {if(buttons[i].id.indexOf(editorid + '_') != -1) {buttons[i].href = 'javascript:;';if(buttons[i].id.substr(buttons[i].id.indexOf('_') + 1) == 'fullswitcher') {} else if(buttons[i].id.substr(buttons[i].id.indexOf('_') + 1) == 'simple') {} else {_attachEvent(buttons[i], 'mouseover', function(e) {setEditorTip(BROWSER.ie ? window.event.srcElement.title : e.target.title);});if(buttons[i].id.substr(buttons[i].id.indexOf('_') + 1) == 'url') {buttons[i].onclick = function(e) {discuzcode('unlink');discuzcode('url');doane();};} else {if(!buttons[i].getAttribute('init')) {buttons[i].onclick = function(e) {discuzcode(this.id.substr(this.id.indexOf('_') + 1));doane();};}}}buttons[i].onmouseout = function(e) {setEditorTip('');};}}}function savedataTime() {if(!autosave) {$(editorid + '_svdsecond').innerHTML = '开启自动保存 ';return;}if(!savedatac) {savedatac = savedataInterval;saveData();d = new Date();var h = d.getHours();var m = d.getMinutes();h = h < 10 ? '0' + h : h;m = m < 10 ? '0' + m : m;setEditorTip('数据已于 ' + h + ':' + m + ' 保存');}$(editorid + '_svdsecond').innerHTML = '' + savedatac + ' 秒后保存 ';savedatac -= 10;}function setAutosave() {autosave = !autosave;setEditorTip(autosave ? '数据自动保存已开启' : '数据自动保存已关闭');setcookie('editorautosave_' + editorid, autosave ? 1 : -1, 2592000);savedataTime();}function unloadAutoSave() {if(autosave) {saveData();}}function seteditorcontrolpos() {var objpos = fetchOffset($(editorid + '_controls'));editorcontroltop = objpos['top'];}function editorcontrolpos() {if(editorisfull) {return;}var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);if(scrollTop > editorcontroltop && editorcurrentheight > editorminheight) {$(editorid + '_controls').style.position = 'fixed';$(editorid + '_controls').style.top = '0px';$(editorid + '_controls').style.width = editorcontrolwidth + 'px';$(editorid + '_controls_mask').style.display = '';} else {$(editorid + '_controls').style.position = $(editorid + '_controls').style.top = $(editorid + '_controls').style.width = '';$(editorid + '_controls_mask').style.display = 'none';}}function editorsize(op, v) {var obj = wysiwyg ? editwin.document.body.parentNode : $(editorid + '_textarea');var editorheight = obj.clientHeight;if(!v) {if(op == '+') {editorheight += 200;} else{editorheight -= 200;}} else {editorheight = v;}editorcurrentheight = editorheight > editorminheight ? editorheight : editorminheight;if($(editorid + '_iframe')) {$(editorid + '_iframe').style.height = $(editorid + '_iframe').contentWindow.document.body.style.height = editorcurrentheight + 'px';}if(framemObj) {framemObj.style.height = editorcurrentheight + 'px';}$(editorid + '_textarea').style.height = editorcurrentheight + 'px';}var editorsizepos = [];function editorresize(e, op) {op = !op ? 1 : op;e = e ? e : window.event;if(op == 1) {if(wysiwyg) {var objpos = fetchOffset($(editorid + '_iframe'));framemObj = document.createElement('div');framemObj.style.width = $(editorid + '_iframe').clientWidth + 'px';framemObj.style.height = $(editorid + '_iframe').clientHeight + 'px';framemObj.style.position = 'absolute';framemObj.style.left = objpos['left'] + 'px';framemObj.style.top = objpos['top'] + 'px';$('append_parent').appendChild(framemObj);} else {framemObj = null;}editorsizepos = [e.clientY, editorcurrentheight, framemObj];document.onmousemove = function(e) {try{editorresize(e, 2);}catch(err){}};document.onmouseup = function(e) {try{editorresize(e, 3);}catch(err){}};doane(e);}else if(op == 2 && editorsizepos !== []) {var dragnow = e.clientY;editorsize('', editorsizepos[1] + dragnow - editorsizepos[0]);doane(e);}else if(op == 3) {if(wysiwyg) {$('append_parent').removeChild(editorsizepos[2]);}editorsizepos = [];document.onmousemove = null;document.onmouseup = null;}}function editorfull(op) {var op = !op ? 0 : op, control = $(editorid + '_controls'), area = $(editorid + '_textarea').parentNode, bbar = $(editorid + '_bbar'), iswysiwyg = wysiwyg;if(op) {var editorheight = document.documentElement.clientHeight - control.offsetHeight - bbar.offsetHeight - parseInt(getCurrentStyle(area, 'paddingTop', 'padding-top')) - parseInt(getCurrentStyle(area, 'paddingBottom', 'padding-bottom'));area.style.position = 'fixed';area.style.top = control.offsetHeight + 'px';area.style.height = editorheight + 'px';editorsize('', editorheight);bbar.style.position = 'fixed';bbar.style.top = (document.documentElement.clientHeight - bbar.offsetHeight) + 'px';return;}if(!editorisfull) {savesimplodemode = 0;if(simplodemode) {savesimplodemode = 1;editorsimple();}$(editorid + '_simple').style.visibility = 'hidden';fulloldheight = editorcurrentheight;document.body.style.overflow = 'hidden';document.body.scroll = 'no';control.style.position = 'fixed';control.style.top = '0px';control.style.left = '0px';control.style.width = '100%';control.style.minWidth = '800px';area.style.backgroundColor = $(editorid + '_textarea') ? getCurrentStyle($(editorid + '_textarea'), 'backgroundColor', 'background-color') : '#fff';$(editorid + '_switcher').style.paddingRight = '10px';var editorheight = document.documentElement.clientHeight - control.offsetHeight - bbar.offsetHeight - parseInt(getCurrentStyle(area, 'paddingTop', 'padding-top')) - parseInt(getCurrentStyle(area, 'paddingBottom', 'padding-bottom'));area.style.position = 'fixed';area.style.top = control.offsetHeight + 'px';area.style.left = '0px';area.style.width = '100%';area.style.height = editorheight + 'px';editorsize('', editorheight);bbar.style.position = 'fixed';bbar.style.top = (document.documentElement.clientHeight - bbar.offsetHeight) + 'px';bbar.style.left = '0px';bbar.style.width = '100%';control.style.zIndex = '500';area.style.zIndex = bbar.style.zIndex = '200';if($(editorid + '_resize')) {$(editorid + '_resize').style.display = 'none';}window.onresize = function() { editorfull(1); };editorisfull = 1;} else {if(savesimplodemode) {editorsimple();}$(editorid + '_simple').style.visibility = 'visible';window.onresize = null;document.body.style.overflow = 'auto';document.body.scroll = 'yes';control.style.position = control.style.top = control.style.left = control.style.width = control.style.minWidth = control.style.zIndex =area.style.position = area.style.top = area.style.left = area.style.width = area.style.height = area.style.zIndex =bbar.style.position = bbar.style.top = bbar.style.left = bbar.style.width = bbar.style.zIndex = '';editorheight = fulloldheight;$(editorid + '_switcher').style.paddingRight = '0px';editorsize('', editorheight);if($(editorid + '_resize')) {$(editorid + '_resize').style.display = '';}editorisfull = 0;editorcontrolpos();}$(editorid + '_fullswitcher').innerHTML = editorisfull ? '返回' : '全屏';initesbar();}function editorsimple() {if($(editorid + '_body').className == 'edt') {v = 'none';$(editorid + '_simple').innerHTML = '高级';$(editorid + '_body').className = 'edt simpleedt';$(editorid + '_adv_s1').className = 'b2r';$(editorid + '_adv_s2').className = 'b2r nbl';if(allowswitcheditor) {$(editorid + '_switcher').style.display = 'none';}$(editorid + '_adv_s3').className = 'b2r esbs';simplodemode = 1;} else {v = '';$(editorid + '_simple').innerHTML = '常用';$(editorid + '_body').className = 'edt';$(editorid + '_adv_s1').className = 'b1r';$(editorid + '_adv_s2').className = 'b2r nbr nbl';if(allowswitcheditor) {$(editorid + '_switcher').style.display = '';}$(editorid + '_adv_s3').className = 'b2r esb';simplodemode = 0;}setcookie('editormode_' + editorid, simplodemode ? 1 : -1, 2592000);for(i = 1;i <= 9;i++) {if($(editorid + '_adv_' + i)) {$(editorid + '_adv_' + i).style.display = v;}}var btns = $(editorid + '_adv_s3').getElementsByTagName('A');for(i = 0;i < btns.length;i++) {if(btns[i].getAttribute('adv')) {btns[i].style.display = v;}}}function pasteWord(str) {var mstest = /<\w[^>]* class="?[MsoNormal|xl]"?/gi;if(mstest.test(str)){str = str.replace(//gi, "");str = str.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");str = str.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, function ($1, $2, $3, $4) {var style = '';re = new RegExp('(^|[;\\s])color:\\s*([^;]+);?', 'ig');match = re.exec($3);if(match != null) {style += 'color:' + match[2] + ';';}re = new RegExp('(^|[;\\s])text-indent:\\s*([^;]+);?', 'ig');match = re.exec($3);if(match != null) {style += 'text-indent:' + parseInt(parseInt(match[2]) / 10) + 'em;';}re = new RegExp('(^|[;\\s])font-size:\\s*([^;]+);?', 'ig');match = re.exec($3);if(match != null) {style += 'font-size:' + match[2] + ';';}if(style) {style = ' style="' + style + '"';}return '<' + $2 + style + $4;});str = str.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");str = str.replace(/<\\?\?xml[^>]*>/gi, "");str = str.replace(/<\/?\w+:[^>]*>/gi, "");str = str.replace(/ /, " ");var re = new RegExp("(
]*>.*?)(<\/P>)", 'ig');str = str.replace(re, "
[page]
';} else {str = '\n\n[page]';}insertText(str, strlen(str), 0);} else if(cmd == 'autotypeset') {autoTypeset();return;} else if(!wysiwyg && cmd == 'removeformat') {var simplestrip = new Array('b', 'i', 'u');var complexstrip = new Array('font', 'color', 'backcolor', 'size');var str = getSel();if(str === false) {return;}for(var tag in simplestrip) {str = stripSimple(simplestrip[tag], str);}for(var tag in complexstrip) {str = stripComplex(complexstrip[tag], str);}insertText(str);} else if(cmd == 'undo') {addSnapshot(getEditorContents());moveCursor(-1);if((str = getSnapshot()) !== false) {if(wysiwyg) {editdoc.body.innerHTML = str;} else {editdoc.value = str;}}} else if(cmd == 'redo') {moveCursor(1);if((str = getSnapshot()) !== false) {if(wysiwyg) {editdoc.body.innerHTML = str;} else {editdoc.value = str;}}} else if(!wysiwyg && in_array(cmd, ['insertorderedlist', 'insertunorderedlist'])) {var listtype = cmd == 'insertorderedlist' ? '1' : '';var opentag = '[list' + (listtype ? ('=' + listtype) : '') + ']\n';var closetag = '[/list]';if(txt = getSel()) {var regex = new RegExp('([\r\n]+|^[\r\n]*)(?!\\[\\*\\]|\\[\\/?list)(?=[^\r\n])', 'gi');txt = opentag + trim(txt).replace(regex, '$1[*]') + '\n' + closetag;insertText(txt, strlen(txt), 0);} else {insertText(opentag + closetag, opentag.length, closetag.length);while(listvalue = prompt('输入一个列表项目.\r\n留空或者点击取消完成此列表.', '')) {if(BROWSER.opera > 8) {listvalue = '\n' + '[*]' + listvalue;insertText(listvalue, strlen(listvalue) + 1, 0);} else {listvalue = '[*]' + listvalue + '\n';insertText(listvalue, strlen(listvalue), 0);}}}} else if(!wysiwyg && cmd == 'unlink') {var sel = getSel();sel = stripSimple('url', sel);sel = stripComplex('url', sel);insertText(sel);} else if(cmd == 'floatleft' || cmd == 'floatright') {var arg = cmd == 'floatleft' ? 'left' : 'right';if(wysiwyg) {if(txt = getSel()) {argm = arg == 'left' ? 'right' : 'left';insertText('| ' + txt + ' |
正在下载远程附件,请稍等……

请输入帖子密码:
';break;case 'code':if(wysiwyg) {opentag = '';closetag = '
';closetag = '
表格行数: 表格列数:
表格宽度: 背景颜色:
快速书写表格提示
请输入音乐文件地址:
支持 wma mp3 ra rm 等音乐格式
示例: http://server/audio.wma
请输入视频地址:
宽: 高:
支持优酷、土豆、56、酷6等视频站的视频网址
支持 wmv avi rmvb mov swf flv 等视频格式
示例: http://server/movie.wmv
请输入 Flash 文件地址:
宽: 高:
支持 swf flv 等 Flash 网址
示例: http://server/flash.swf
请输入开头动画 Flash 或 图片 地址:
';str += '点击链接地址:
';str += '宽: 高:
';str += '停留秒数:
';str += '载入、消失的效果:
无 淡入淡出 展开闭合
';str += '支持 swf flv jpg gif png 网址
宽高范围: 宽400~1024 高300~640
示例: http://server/flash.swf
请通过快捷键(Ctrl+V)把 Word 文件中的内容粘贴到上方
';menuwidth = 600;menupos = '00';menutype = 'win';break;case 'index':stitle = '创建帖子目录';str = '[index]
\n\[#页码]标题
\n\*[#tid,pid]标题
\n\[/index]
\n\
\n\页码
\n\tid,pid
\n\*
'+ '' + stitle + '关闭' + str + ' '+ ''+ ' | ||
';closetag = '
';closetag = '
| \n';}str += ' |
') : selection.replace(/\n\n+/g, '[/p]\n[p=30, 2, left]');opentag = wysiwyg ? '
' : '[p=30, 2, left]';var s = opentag + selection + (wysiwyg ? '
' : '[/p]');insertText(s, strlen(opentag), 4, false, sel);hideMenu();}function getSel() {if(wysiwyg) {try {selection = editwin.getSelection();checkFocus();range = selection ? selection.getRangeAt(0) : editdoc.createRange();return readNodes(range.cloneContents(), false);} catch(e) {try {var range = editdoc.selection.createRange();if(range.htmlText && range.text) {return range.htmlText;} else {var htmltext = '';for(var i = 0; i < range.length; i++) {htmltext += range.item(i).outerHTML;}return htmltext;}} catch(e) {return '';}}} else {if(!isUndefined(editdoc.selectionStart)) {return editdoc.value.substr(editdoc.selectionStart, editdoc.selectionEnd - editdoc.selectionStart);} else if(document.selection && document.selection.createRange) {return document.selection.createRange().text;} else if(window.getSelection) {return window.getSelection() + '';} else {return false;}}}function insertText(text, movestart, moveend, select, sel) {checkFocus();if(wysiwyg) {try {if(!editdoc.execCommand('insertHTML', false, text)) {throw 'insertHTML Err';}} catch(e) {try {if(!isUndefined(editdoc.selection) && editdoc.selection.type != 'Text' && editdoc.selection.type != 'None') {movestart = false;editdoc.selection.clear();}range = isUndefined(sel) ? editdoc.selection.createRange() : sel;range.pasteHTML(text);if(text.indexOf('\n') == -1) {if(!isUndefined(movestart)) {range.moveStart('character', -strlen(text) + movestart);range.moveEnd('character', -moveend);} else if(movestart != false) {range.moveStart('character', -strlen(text));}if(!isUndefined(select) && select) {range.select();}}} catch(e) {if(!sel) {var sel = editdoc.getSelection();var range = sel.getRangeAt(0);} else {var range = sel;}if(range && range.insertNode) {range.deleteContents();}var frag = range.createContextualFragment(text);range.insertNode(frag);}}} else {if(!isUndefined(editdoc.selectionStart)) {if(editdoc._selectionStart) {editdoc.selectionStart = editdoc._selectionStart;editdoc.selectionEnd = editdoc._selectionEnd;editdoc._selectionStart = 0;editdoc._selectionEnd = 0;}var opn = editdoc.selectionStart + 0;editdoc.value = editdoc.value.substr(0, editdoc.selectionStart) + text + editdoc.value.substr(editdoc.selectionEnd);if(!isUndefined(movestart)) {editdoc.selectionStart = opn + movestart;editdoc.selectionEnd = opn + strlen(text) - moveend;} else if(movestart !== false) {editdoc.selectionStart = opn;editdoc.selectionEnd = opn + strlen(text);}} else if(document.selection && document.selection.createRange) {if(isUndefined(sel)) {sel = document.selection.createRange();}if(editbox.sel) {sel = editbox.sel;editbox.sel = null;}sel.text = text.replace(/\r?\n/g, '\r\n');if(!isUndefined(movestart)) {sel.moveStart('character', -strlen(text) +movestart);sel.moveEnd('character', -moveend);} else if(movestart !== false) {sel.moveStart('character', -strlen(text));}sel.select();} else {editdoc.value += text;}}checkFocus();}function stripSimple(tag, str, iterations) {var opentag = '[' + tag + ']';var closetag = '[/' + tag + ']';if(isUndefined(iterations)) {iterations = -1;}while((startindex = stripos(str, opentag)) !== false && iterations != 0) {iterations --;if((stopindex = stripos(str, closetag)) !== false) {var text = str.substr(startindex + opentag.length, stopindex - startindex - opentag.length);str = str.substr(0, startindex) + text + str.substr(stopindex + closetag.length);} else {break;}}return str;}function readNodes(root, toptag) {var html = "";var moz_check = /_moz/i;switch(root.nodeType) {case Node.ELEMENT_NODE:case Node.DOCUMENT_FRAGMENT_NODE:var closed;if(toptag) {closed = !root.hasChildNodes();html = '<' + root.tagName.toLowerCase();var attr = root.attributes;for(var i = 0; i < attr.length; ++i) {var a = attr.item(i);if(!a.specified || a.name.match(moz_check) || a.value.match(moz_check)) {continue;}html += " " + a.name.toLowerCase() + '="' + a.value + '"';}html += closed ? " />" : ">";}for(var i = root.firstChild; i; i = i.nextSibling) {html += readNodes(i, true);}if(toptag && !closed) {html += "" + root.tagName.toLowerCase() + ">";}break;case Node.TEXT_NODE:html = htmlspecialchars(root.data);break;}return html;}function stripComplex(tag, str, iterations) {var opentag = '[' + tag + '=';var closetag = '[/' + tag + ']';if(isUndefined(iterations)) {iterations = -1;}while((startindex = stripos(str, opentag)) !== false && iterations != 0) {iterations --;if((stopindex = stripos(str, closetag)) !== false) {var openend = stripos(str, ']', startindex);if(openend !== false && openend > startindex && openend < stopindex) {var text = str.substr(openend + 1, stopindex - openend - 1);str = str.substr(0, startindex) + text + str.substr(stopindex + closetag.length);} else {break;}} else {break;}}return str;}function stripos(haystack, needle, offset) {if(isUndefined(offset)) {offset = 0;}var index = haystack.toLowerCase().indexOf(needle.toLowerCase(), offset);return (index == -1 ? false : index);}function switchEditor(mode) {if(mode == wysiwyg || !allowswitcheditor) {return;}if(!mode) {var controlbar = $(editorid + '_controls');var controls = [];var buttons = controlbar.getElementsByTagName('a');var buttonslength = buttons.length;for(var i = 0; i < buttonslength; i++) {if(buttons[i].id) {controls[controls.length] = buttons[i].id;}}var controlslength = controls.length;for(var i = 0; i < controlslength; i++) {var control = $(controls[i]);if(control.id.indexOf(editorid + '_') != -1) {control.state = false;control.mode = 'normal';} else if(control.id.indexOf(editorid + '_popup_') != -1) {control.state = false;}}setContext('clear');}cursor = -1;stack = [];var parsedtext = getEditorContents();parsedtext = mode ? bbcode2html(parsedtext) : html2bbcode(parsedtext);wysiwyg = mode;$(editorid + '_mode').value = mode;newEditor(mode, parsedtext);setEditorStyle();editwin.focus();setCaretAtEnd();}function setCaretAtEnd() {if(wysiwyg) {editdoc.body.innerHTML += '';} else {editdoc.value += '';}}function moveCursor(increment) {var test = cursor + increment;if(test >= 0 && stack[test] != null && !isUndefined(stack[test])) {cursor += increment;}}function addSnapshot(str) {if(stack[cursor] == str) {return;} else {cursor++;stack[cursor] = str;if(!isUndefined(stack[cursor + 1])) {stack[cursor + 1] = null;}}}function getSnapshot() {if(!isUndefined(stack[cursor]) && stack[cursor] != null) {return stack[cursor];} else {return false;}}function squarestrip(str) {str = str.replace('[', '%5B');str = str.replace(']', '%5D');return str;}function loadimgsize(imgurl, editor, p) {var editor = !editor ? editorid : editor;var s = new Object();var p = !p ? '_image' : p;s.img = new Image();s.img.src = imgurl;s.loadCheck = function () {if(s.img.complete) {$(editor + p + '_param_2').value = s.img.width ? s.img.width : '';$(editor + p + '_param_3').value = s.img.height ? s.img.height : '';} else {setTimeout(function () {s.loadCheck();}, 100);}};s.loadCheck();}function showHrBox(ctrlid, boxtype) {if(typeof postimg_type == 'undefined') {var scriptNode = document.createElement("script");scriptNode.type = "text/javascript";scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset);scriptNode.src = 'data/cache/common_postimg.js?' + VERHASH;$('append_parent').appendChild(scriptNode);if(BROWSER.ie) {scriptNode.onreadystatechange = function() {_initHrBox(ctrlid, boxtype);};} else {scriptNode.onload = function() {_initHrBox(ctrlid, boxtype);};}} else {_initHrBox(ctrlid, boxtype);}}function _initHrBox(ctrlid, boxtype) {if(!$(ctrlid + '_menu')) {var menu = document.createElement('div');menu.id = ctrlid + '_menu';menu.unselectable = true;menu.style.display = 'none';if(boxtype == 'postbg') {menu.className = 'p_pop postbgbox';var imglist = postimg_type['postbg'];var str = '';for(var i = 0; i < imglist.length; i++) {str += '' ;}} else {menu.className = 'p_pop hrbox';var hrimglist = postimg_type['hrline'];var str = '';for(var i = 0; i < hrimglist.length; i++) {inserturl = (hrimglist[i] != '0.gif') ? "'"+STATICURL+'image/hrline/'+hrimglist[i]+"'" : 'false';str += '' ;}}menu.innerHTML = str;$('append_parent').appendChild(menu);}}function insertHrImage(url) {checkFocus();if(wysiwyg) {if(url !== false) {insertText('