var myeditor,ifm;var body_id,textboxelement;var content;var isIE=/msie|MSIE/.test(navigator.userAgent);var isChrome=/Chrome/.test(navigator.userAgent);var isSafari=/Safari/.test(navigator.userAgent)&&!isChrome;var browser=isIE||window.opera;var textRange;var enter=0;var editorVisible=false;var enableWysiwyg=false;function rep(re,str){content=content.replace(re,str);}function initEditor(textarea_id,wysiwyg){if(wysiwyg!=undefined){enableWysiwyg=wysiwyg;}else{enableWysiwyg=enableWysiwygs;}body_id=textarea_id;textboxelement=document.getElementById(body_id);textboxelement.setAttribute("class","editorBBCODE");textboxelement.className="editorBBCODE";if(enableWysiwyg){ifm=document.createElement("iframe");ifm.setAttribute("id","rte");ifm.setAttribute("frameborder","0");ifm.style.width=textboxelement.style.width;ifm.style.height=textboxelement.style.height;textboxelement.parentNode.appendChild(ifm);textboxelement.style.display="none";if(ifm){ShowEditor();}else{setTimeout("ShowEditor()",100);}}}function KSP_initEditor(textarea_id,wysiwyg){if(wysiwyg!=undefined){enableWysiwyg=wysiwyg;}else{enableWysiwyg=enableWysiwygs;}body_id=textarea_id;textboxelement=document.getElementById(body_id);textboxelement.setAttribute("class","editorBBCODE");textboxelement.className="editorBBCODE";if(enableWysiwyg){ifm=document.createElement("iframe");ifm.setAttribute("id","rte");ifm.setAttribute("frameborder","0");ifm.style.width=textboxelement.style.width;ifm.style.height=textboxelement.style.height;textboxelement.parentNode.appendChild(ifm);textboxelement.style.display="none";if(ifm){ShowEditor();}else{setTimeout("ShowEditor()",100);}}}function getStyle(el,styleProp){var x=document.getElementById(el);if(x.currentStyle){var y=x.currentStyle[styleProp];}else if(window.getComputedStyle){var y=document.defaultView.getComputedStyle(x,valforget).getPropertyValue(styleProp);}return y;}function ShowEditor(){if(!enableWysiwyg){return;}editorVisible=visibleeditor;content=document.getElementById(body_id).value;myeditor=ifm.contentWindow.document;bbcode2html();myeditor.designMode=designmodeeditor;myeditor.open();myeditor.write("<html><head><link href=\"editor.css\" rel=\"Stylesheet\" type=\"text/css\" /></head>");myeditor.write("<body style=\"margin:0px 0px 0px 0px\" class=\"editorWYSIWYG\" id=\"KSP_THREAD_QUOTE_HERE\">");myeditor.write(content);myeditor.write("</body></html>");myeditor.close();if(myeditor.attachEvent){if(parent.ProcessKeyPress){myeditor.attachEvent("onkeydown",parent.ProcessKeyPress);}myeditor.attachEvent("onkeypress",kp);}else if(myeditor.addEventListener){if(parent.ProcessKeyPress){myeditor.addEventListener("keydown",parent.ProcessKeyPress,publicarea);}myeditor.addEventListener("keypress",kp,publicarea);}}function SwitchEditor(){if(editorVisible){doCheck();ifm.style.display="none";textboxelement.style.display="";editorVisible=commanarea;}else{if(enableWysiwyg&&ifm){ifm.style.display="";textboxelement.style.display="none";ShowEditor();editorVisible=publicarea;}}}function strip_tags(str,allowed_tags,tentuoi){var key="",allowed=false;var matches=[];var allowed_array=[];var allowed_tag="";var i=0;var k="";var html="";var replacer=function(search,replace,str){return str.split(search).join(replace);};if(allowed_tags){allowed_array=allowed_tags.match(/([a-zA-Z0-9]+)/gi);}str+="";matches=str.match(/(<\/?[\S][^>]*>)/gi);for(key in matches){if(isNaN(key)){continue;}html=matches[key].toString();allowed=false;for(k in allowed_array){allowed_tag=allowed_array[k];i=-1;if(i!=0){i=html.toLowerCase().indexOf("&lt;"+allowed_tag+"&gt;");}if(i!=0){i=html.toLowerCase().indexOf("&lt;"+allowed_tag+" ");}if(i!=0){i=html.toLowerCase().indexOf("&lt;/"+allowed_tag);}if(i==0){allowed=true;break;}}if(!allowed){str=replacer(html,"",str);}}return"["+tentuoi+"]"+str+"[/"+tentuoi+"]";}function html2bbcode(){rep(/\[(quote|php|code)\]([\s\S]*?)\[\/(quote|php|code)\]/gi,strip_tags("$2","&gt;&lt;","$1"));rep(/<\!--([\s\S]*?)-->/gi,"");rep(/<(object|param|embed)([\s\S]*?)>/gi,"[$1ne=$2]");rep(/<\/object>/gi,"[/objectne]");rep(/<a([\s\S]*?)>([\s\S]*?)Select([\s\S]*?)all([\s\S]*?)<\/a>/gi,"");rep(/<\/h1>/gi,"[/h1]");rep(/<a href=\"([\s\S]*?)\" nhoc=\"urls\">([\s\S]*?)<\/a>/gi,"[url=\"$1\"]$2[/url]");rep(/<h1([\s\S]*?)>/gi,"[h1=$1]");rep(/<\/h1>/gi,"[/h1]");rep(/<pre([\s\S]*?)>/gi,"[pres=$1]");rep(/<\/pre>/gi,"[/pres]");rep(/<h2([\s\S]*?)>/gi,"[h2=$1]");rep(/<\/h2>/gi,"[/h2]");rep(/<h3([\s\S]*?)>/gi,"[h3=$1]");rep(/<\/h3>/gi,"[/h3]");rep(/<h4([\s\S]*?)>/gi,"[h4=$1]");rep(/<\/h4>/gi,"[/h4]");rep(/<fieldset([\s\S]*?)>/gi,"[fieldset=$1]");rep(/<\/fieldset>/gi,"[/fieldset]");rep(/<h5([\s\S]*?)>/gi,"[h5=$1]");rep(/<td([\s\S]*?)class="td1"([\s\S]*?)>Click([\s\S]*?)bar([\s\S]*?)view the full([\s\S]*?)<\/td>/gi,"[tdne=][/tdne]");rep(/<td([\s\S]*?)class="td2"([\s\S]*?)>Click([\s\S]*?)bar([\s\S]*?)view the full([\s\S]*?)<\/td>/gi,"[tdne=][/tdne]");rep(/<td([\s\S]*?)class="td1"([\s\S]*?)>Ảnh([\s\S]*?)đã([\s\S]*?)gốc([\s\S]*?)<\/td>/gi,"[tdne=][/tdne]");rep(/<td([\s\S]*?)class="td2"([\s\S]*?)>Ảnh([\s\S]*?)đã([\s\S]*?)gốc([\s\S]*?)<\/td>/gi,"[tdne=][/tdne]");rep(/<\/h5>/gi,"[/h5]");rep(/<h6([\s\S]*?)>/gi,"[h6=$1]");rep(/<a([\s\S]*?)href=\"([\s\S]*?)\"([\s\S]*?)>([\s\S]*?)<\/a>/gi,"[url=$2]$4[/url]");rep(/<\/h6>/gi,"[/h6]");rep(/<img\s[^<>]*?src=\"?([^<>]*?)\"?(\s[^<>]*)?\/?>/gi,"[img]$1[/img]");rep(/<(div|p)([\s\S]*?)>/gi,"[divet=\"$2\"]");rep(/<\/(div|p)>/gi,"[/divet]");rep(/<style([\s\S]*?)>([\s\S]*?)<\/style>/gi,"");rep(/<span([\s\S]*?)>/gi,"[khungspan=$1]");rep(/<font([\s\S]*?)>/gi,"[phon=$1]");rep(/<\/span>/gi,"[/khungspan]");rep(/<\/font>/gi,"[/phon]");rep(/<\/(strong|b)>/gi,"[/b]");rep(/<(strong|b)(\s[^<>]*)?>/gi,"[b]");rep(/<\/legend>/gi,"[/legend]");rep(/<legend(\s[^<>]*)?>/gi,"[legend]");rep(/<\/s>/gi,"[/strike]");rep(/<s(\s[^<>]*)?>/gi,"[strike]");rep(/<\/(em|i)>/gi,"[/i]");rep(/<(em|i)(\s[^<>]*)?>/gi,"[i]");rep(/<link(\s[^<>]*)?>/gi,"");rep(/<\/blockquote>/gi,"[/block]");rep(/<blockquote(\s[^<>]*)?>/gi,"[block=$1]");rep(/<\/u>/gi,"[/u]");rep(/\n/gi,"");rep(/\r/gi,"");rep(/<u(\s[^<>]*)?>/gi,"[u]");rep(/<br(\s[^<>]*)?>/gi,"[xuongdong][/xuongdong]");rep(/<p(\s[^<>]*)?>/gi,"");rep(/<\/p>/gi,"\n");rep(/<ol[\s\S]*?>/gi,"[olne]");rep(/<\/ol>/gi,"[/olne]");rep(/<ul[\s\S]*?>/gi,"[ulne]");rep(/<\/ul>/gi,"[/ulne]");rep(/<hr[\s\S]*?>/gi,"[hr]");rep(/<li[\s\S]*?>/gi,"[li]");rep(/<\/li>/gi,"[/li]");rep(/<table([\s\S]*?)>/gi,"[tablene=$1]");rep(/<\/table>/gi,"[/tablene]");rep(/<tr([\s\S]*?)>/gi,"[trne=$1]");rep(/<\/tr>/gi,"[/trne]");rep(/<td([\s\S]*?)>/gi,"[tdne=$1]");rep(/<\/td>/gi,"[/tdne]");rep(/<sub[\s\S]*?>/gi,"[sub]");rep(/<\/sub>/gi,"[/sub]");rep(/<sup[\s\S]*?>/gi,"[sup]");rep(/<\/sup>/gi,"[/sup]");rep(/<div([^<>]*)>/gi,"\n<span$1>");rep(/<\/div>/gi,"</span>\n");rep(/&nbsp;/gi," ");rep(/&quot;/gi,"\"");rep(/&amp;/gi,"&");var sc,sc2;do{sc=content;rep(/<font\s[^<>]*?color=\"?([^<>]*?)\"?(\s[^<>]*)?>([^<>]*?)<\/font>/gi,"[color=$1]$3[/color]");if(sc==content){rep(/<font[^<>]*>([^<>]*?)<\/font>/gi,"$1");}sc2=content;rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-weight: ?bold;?\"?\s*([^<]*?)<\/\1>/gi,"[b]<$1 style=$2</$1>[/b]");rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-weight: ?normal;?\"?\s*([^<]*?)<\/\1>/gi,"<$1 style=$2</$1>");rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-style: ?italic;?\"?\s*([^<]*?)<\/\1>/gi,"[i]<$1 style=$2</$1>[/i]");rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?font-style: ?normal;?\"?\s*([^<]*?)<\/\1>/gi,"<$1 style=$2</$1>");rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?text-decoration: ?underline;?\"?\s*([^<]*?)<\/\1>/gi,"[u]<$1 style=$2</$1>[/u]");rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?text-decoration: ?none;?\"?\s*([^<]*?)<\/\1>/gi,"<$1 style=$2</$1>");rep(/<(span|blockquote|pre)\s[^<>]*?style=\"?color: ?([^<>]*?);\"?\s*([^<]*?)<\/\1>/gi,"[color=$2]<$1 style=$3</$1>[/color]");rep(/<(blockquote|pre)\s[^<>]*?style=\"?\"? (class=|id=)([^<>]*)>([^<>]*?)<\/\1>/gi,"<$1 $2$3>$4</$1>");rep(/<span\s[^<>]*?style=\"?\"?>([^<>]*?)<\/span>/gi,"$1");if(sc2==content){rep(/<span[^<>]*>([^<>]*?)<\/span>/gi,"$1");sc2=content;rep(/<pre\s[^<>]*?class=\"?code\"?[^<>]*?>([^<>]*?)<\/pre>/gi,"[code]$1[/code]");if(sc2==content){rep(/<blockquote\s[^<>]*?class=\"?memberquote\"?[^<>]*?id=\"?([^<>\"]*)\"?>([^<>]*?)<\/blockquote>/gi,"[quote$1]$2[/quote]");if(sc2==content){rep(/<blockquote\s[^<>]*?id=\"?([^<>\"]*?)\"? class=\"?memberquote\"?[^<>]*?>([^<>]*?)<\/blockquote>/gi,"[quote$1]$2[/quote]");if(sc2==content){rep(/<blockquote\s[^<>]*?class=\"?memberquote\"?[^<>]*?>([^<>]*?)<\/blockquote>/gi,"[quote]$1[/quote]");}}}}}while(sc!=content);rep(/<[^<>]*>/gi,"");do{sc=content;rep(/\[(b|i|u)\]\[quote([^\]]*)\]([\s\S]*?)\[\/quote\]\[\/\1\]/gi,"[quote$2][$1]$3[/$1][/quote]");rep(/\[color=([^\]]*)\]\[quote([^\]]*)\]([\s\S]*?)\[\/quote\]\[\/color\]/gi,"[quote$2][color=$1]$3[/color][/quote]");rep(/\[(b|i|u)\]\[code\]([\s\S]*?)\[\/code\]\[\/\1\]/gi,"[code][$1]$2[/$1][/code]");rep(/\[color=([^\]]*)\]\[code\]([\s\S]*?)\[\/code\]\[\/color\]/gi,"[code][color=$1]$2[/color][/code]");}while(sc!=content);do{sc=content;rep(/\[b\]\[\/b\]/gi,"");rep(/\[i\]\[\/i\]/gi,"");rep(/\[u\]\[\/u\]/gi,"");rep(/\[quote[^\]]*\]\[\/quote\]/gi,"");rep(/\[code\]\[\/code\]/gi,"");rep(/\[url=([^\]]+)\]\[\/url\]/gi,"");rep(/\[img\]\[\/img\]/gi,"");rep(/\[color=([^\]]*)\]\[\/color\]/gi,"");}while(sc!=content);}function bbcode2html(){rep(/\[(quote|php|code)\]([\s\S]*?)\[\/(quote|php|code)\]/gi,strip_tags("$2","&gt;&lt;","$1"));rep(/\[size=([\s\S]*?)\]/gi,"<span style=\"font-size: $1;\">");rep(/\[\/size\]/gi,"</span>");rep(/--- Last Edited by [\s\S]*? ---/gi,"");rep(/\[olne\]/gi,"<ol>");rep(/\[\/olne\]/gi,"</ol>");rep(/\[strike\]/gi,"<s>");rep(/\[\/strike\]/gi,"</s>");rep(/\[ulne\]/gi,"<ul>");rep(/\[\/ulne\]/gi,"</ul>");rep(/\[legend\]/gi,"<legend>");rep(/\[\/legend\]/gi,"</legend>");rep(/\[h1=([\s\S]*?)\]/gi,"<h1$1>");rep(/\[(embed|object|param)ne=([\s\S]*?)\]/gi,"<$1$2>");rep(/\[\/objectne\]/gi,"</object>");rep(/\[h2=([\s\S]*?)\]/gi,"<h2$1>");rep(/\[\/h2\]/gi,"</h2>");rep(/\[\/h1\]/gi,"</h1>");rep(/\[pres=([\s\S]*?)\]/gi,"<pre$1>");rep(/\[\/pres\]/gi,"</pre>");rep(/\[h3=([\s\S]*?)\]/gi,"<h3$1>");rep(/\[\/h3\]/gi,"</h3>");rep(/\[fieldset=([\s\S]*?)\]/gi,"<fieldset$1>");rep(/\[\/fieldset\]/gi,"</fieldset>");rep(/\[h4=([\s\S]*?)\]/gi,"<h4$1>");rep(/\[\/h4\]/gi,"</h4>");rep(/\[h6=([\s\S]*?)\]/gi,"<h6$1>");rep(/\[\/h6\]/gi,"</h6>");rep(/\[h5=([\s\S]*?)\]/gi,"<h5$1>");rep(/\[hr\]/gi,"<hr>");rep(/\[\/h5\]/gi,"</h5>");rep(/\n/gi,"<br />");rep(/\[li\]/gi,"<li>");rep(/\[\/li\]/gi,"</li>");rep(/\[sub\]/gi,"<sub>");rep(/\[\/sub\]/gi,"</sub>");rep(/\[sup\]/gi,"<sup>");rep(/\[\/sup\]/gi,"</sup>");if(browser){rep(/\[b\]/gi,"<strong>");rep(/\[\/b\]/gi,"</strong>");rep(/\[i\]/gi,"<em>");rep(/\[\/i\]/gi,"</em>");rep(/\[u\]/gi,"<u>");rep(/\[\/u\]/gi,"</u>");}else{rep(/\[b\]/gi,"<span style=\"font-weight: bold;\">");rep(/\[i\]/gi,"<span style=\"font-style: italic;\">");rep(/\[u\]/gi,"<span style=\"text-decoration: underline;\">");rep(/\[\/(b|i|u)\]/gi,"</span>");}rep(/\[img\]([^\"]*?)\[\/img\]/gi,"<img src=\"$1\" />");rep(/\[align=([\s\S]*?)\]([\s\S]*?)\[\/align\]/gi,"<div align=\"$1\">$2</div>");rep(/\[divet=([\s\S]*?)\]/gi,"<p $1>");rep(/\[\/divet\]/gi,"</p>");rep(/\[pet=([\s\S]*?)\]/gi,"<p $1>");rep(/\[\/pet\]/gi,"</p>");rep(/\[khungspan=([\s\S]*?)\]/gi,"<span $1>");rep(/\[phon=([\s\S]*?)\]/gi,"<font $1>");rep(/\[\/phon\]/gi,"</font>");rep(/\[url=\"([\s\S]*?)\"\]([\s\S]*?)\[\/url\]/gi,"<a href=\"$1\" nhoc=\"urls\">$2</a>");rep(/\[\/trne\]/gi,"</tr>");rep(/\[\/tdne\]/gi,"</td>");rep(/\[\/tablene\]/gi,"</table>");rep(/\[\/khungspan\]/gi,"</span>");rep(/\[tablene=([\s\S]*?)\]/gi,"<table $1>");rep(/\[trne=([\s\S]*?)\]/gi,"<tr $1>");rep(/\[tdne=([\s\S]*?)\]/gi,"<td $1>");rep(/\[block=([\s\S]*?)\]([\s\S]*?)\[\/block\]/gi,"<blockquote $1>$2</blockquote>");rep(/\[xuongdong\]([\s\S]*?)\[\/xuongdong\]/gi,"<br />");var sc;do{sc=content;rep(/\[url=([^\]]+)\]([\s\S]*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");rep(/\[url\]([\s\S]*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");if(browser){rep(/\[color=([^\]]*?)\]([\s\S]*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");}else{rep(/\[color=([^\]]*?)\]([\s\S]*?)\[\/color\]/gi,"<span style=\"color: $1;\">$2</span>");}rep(/\[code\]([\s\S]*?)\[\/code\]/gi,"<pre>$1</pre>&nbsp;");}while(sc!=content);}function doCheck(){if(!editorVisible){ShowEditor();}content=myeditor.body.innerHTML;html2bbcode();document.getElementById(body_id).value=content;}function stopEvent(evt){evt||window.event;if(evt.stopPropagation){evt.stopPropagation();evt.preventDefault();}else if(typeof evt.cancelBubble!="undefined"){evt.cancelBubble=publicarea;evt.returnValue=commanarea;}return false;}function doQuote(){if(editorVisible){ifm.contentWindow.focus();if(isIE){textRange=ifm.contentWindow.document.selection.createRange();var newTxt="[quote]"+textRange.text+"[/quote]";textRange.text=newTxt;}else{var edittext=this.ifm.contentWindow.getSelection().getRangeAt(0);var startContainer=edittext.startContainer;var spanNode=startContainer.ownerDocument.createElement("span");var docfrag=edittext.extractContents();spanNode.appendChild(docfrag);var original=spanNode.innerHTML;edittext.deleteContents();insertHtml("[quote]"+original+"[/quote]");}}else{AddTag("[quote]","[/quote]");}}function doPHP(){if(editorVisible){ifm.contentWindow.focus();if(isIE){textRange=ifm.contentWindow.document.selection.createRange();var newTxt="[PHP]"+textRange.text+"[/PHP]";textRange.text=newTxt;}else{var edittext=this.ifm.contentWindow.getSelection().getRangeAt(0);var startContainer=edittext.startContainer;var spanNode=startContainer.ownerDocument.createElement("span");var docfrag=edittext.extractContents();spanNode.appendChild(docfrag);var original=spanNode.innerHTML;edittext.deleteContents();insertHtml("[PHP]"+original+"[/PHP]");}}else{AddTag("[PHP]","[/PHP]");}}function kp(e){if(isIE){var k=e.keyCode;}else{var k=e.which;}if(k==13){if(isIE){var r=myeditor.selection.createRange();if(r.parentElement().tagName.toLowerCase()!="li"){r.pasteHTML("<br/>");if(r.move("character")){r.move("character",-1);}r.select();stopEvent(e);return false;}}}else{enter=0;}}function InsertSmile(txt){InsertText(txt);document.getElementById("divSmilies").style.display="none";}function InsertYoutube(){InsertText("[url=http://www.youtube.com/watch?v=XXXXXXXXXXX]http://www.youtube.com/watch?v=XXXXXXXXXXX[/url]");}function InsertText(txt){if(editorVisible){insertHtml(txt);}else{textboxelement.value+=txt;}}function doClick(command){if(editorVisible){ifm.contentWindow.focus();myeditor.execCommand(command,commanarea,valforget);}else{switch(command){case"bold":AddTag("[b]","[/b]");break;case"italic":AddTag("[i]","[/i]");break;case"underline":AddTag("[u]","[/u]");break;case"InsertUnorderedList":AddTag("[ul][li]","[/li][/ul]");break;case"InsertSoList":AddTag("[ol][li]","[/li][/ol]");break;default:;}}}function doColor(color){ifm.contentWindow.focus();if(isIE){textRange=ifm.contentWindow.document.selection.createRange();textRange.select();}myeditor.execCommand("forecolor",commanarea,color);}function doLink(){if(editorVisible){ifm.contentWindow.focus();var mylink=prompt("Enter a URL:","http://");if(mylink!=valforget&&mylink!=""){if(isIE){var range=ifm.contentWindow.document.selection.createRange();if(range.text==""){range.pasteHTML("<a href='"+mylink+"'>"+mylink+"</a>");}else{myeditor.execCommand("CreateLink",commanarea,mylink);}}else if(window.getSelection){var userSelection=ifm.contentWindow.getSelection().getRangeAt(0);if(userSelection.toString().length==0){myeditor.execCommand("inserthtml",commanarea,"<a href='"+mylink+"'>"+mylink+"</a>");}else{myeditor.execCommand("CreateLink",commanarea,mylink);}}else{myeditor.execCommand("CreateLink",commanarea,mylink);}}}else{AddTag("[url=","]link[/url]");}}function doImage(){myimg=prompt("Enter Image URL:","http://");if(myimg!=valforget&&myimg!=""){if(editorVisible){ifm.contentWindow.focus();myeditor.execCommand("InsertImage",commanarea,myimg);}else{AddTag("[img]"+myimg,"[/img]");}}}function doCenter(){if(editorVisible==commanarea){AddTag("[align=center]","[/align]");}else{ifm.contentWindow.focus();myeditor.execCommand("JustifyCenter",commanarea,valforget);}}function doLeft(){if(editorVisible==commanarea){AddTag("[align=left]","[/align]");}else{ifm.contentWindow.focus();myeditor.execCommand("JustifyLeft",commanarea,valforget);}}function doRight(){if(editorVisible==commanarea){AddTag("[align=right]","[/align]");}else{ifm.contentWindow.focus();myeditor.execCommand("JustifyRight",commanarea,valforget);}}function doJustify(){if(editorVisible==commanarea){AddTag("[align=justify]","[/align]");}else{ifm.contentWindow.focus();myeditor.execCommand("JustifyFull",commanarea,valforget);}}function doUndo(){if(editorVisible){ifm.contentWindow.focus();myeditor.execCommand("Undo",commanarea,valforget);}}function doRedo(){if(editorVisible){ifm.contentWindow.focus();myeditor.execCommand("Undo",commanarea,valforget);}}function doRemoveFormat(){if(editorVisible){ifm.contentWindow.focus();myeditor.execCommand("RemoveFormat",commanarea,valforget);}}function insertHtml(html){ifm.contentWindow.focus();if(isIE){ifm.contentWindow.document.selection.createRange().pasteHTML(html);}else{myeditor.execCommand("inserthtml",commanarea,html);}}function MozillaInsertText(element,text,pos){element.value=element.value.slice(0,pos)+text+element.value.slice(pos);}function AddTag(opentag,closetag){var element=textboxelement;if(this.isIE){if(document.selection){element.focus();var txt=element.value;var str=document.selection.createRange();if(str.text==""){str.text=opentag+closetag;}else if(txt.indexOf(str.text)>=0){str.text=opentag+str.text+closetag;}else{element.value=txt+opentag+closetag;}str.select();}}else if(element.selectionStart>=0){var sel_start=element.selectionStart;var sel_end=element.selectionEnd;MozillaInsertText(element,opentag,sel_start);MozillaInsertText(element,closetag,sel_end+opentag.length);element.selectionStart=sel_start+opentag.length;element.selectionEnd=sel_end+opentag.length;element.focus();}else{element.value=element.value+opentag+closetag;}}function getScrollY(){var scrOfX=0,scrOfY=0;if(typeof window.pageYOffset=="number"){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}return scrOfY;}document.write("<style type='text/css'>.colorpicker201{visibility:hidden;display:none;position:absolute;background:#FFF;z-index:999;filter:progid:DXImageTransform.Microsoft.Shadow(color=#D0D0D0,direction=135);}.o5582brd{padding:0;width:12px;height:14px;border-bottom:solid 1px #DFDFDF;border-right:solid 1px #DFDFDF;}a.o5582n66,.o5582n66,.o5582n66a{font-family:arial,tahoma,sans-serif;text-decoration:underline;font-size:9px;color:#666;border:none;}.o5582n66,.o5582n66a{text-align:center;text-decoration:none;}a:hover.o5582n66{text-decoration:none;color:#FFA500;cursor:pointer;}.a01p3{padding:1px 4px 1px 2px;background:whitesmoke;border:solid 1px #DFDFDF;}</style>");function getTop2(){csBrHt=0;if(typeof window.innerWidth=="number"){csBrHt=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){csBrHt=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){csBrHt=document.body.clientHeight;}ctop=csBrHt/2-115+getScrollY();return ctop;}var nocol1="&#78;&#79;&#32;&#67;&#79;&#76;&#79;&#82;",clos1="X";function getLeft2(){var csBrWt=0;if(typeof window.innerWidth=="number"){csBrWt=window.innerWidth;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){csBrWt=document.documentElement.clientWidth;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){csBrWt=document.body.clientWidth;}cleft=csBrWt/2-125;return cleft;}function setCCbldID2(val){if(editorVisible){doColor(val);}else{AddTag("[color="+val+"]","[/color]");}}function setCCbldSty2(objID,prop,val){switch(prop){case"bc":if(objID!="none"){document.getElementById(objID).style.backgroundColor=val;}break;case"vs":document.getElementById(objID).style.visibility=val;break;case"ds":document.getElementById(objID).style.display=val;break;case"tp":document.getElementById(objID).style.top=val;break;case"lf":document.getElementById(objID).style.left=val;break;default:;}}function putOBJxColor2(Samp,pigMent,textBoxId){if(pigMent!="x"){setCCbldID2(pigMent,textBoxId);setCCbldSty2(Samp,"bc",pigMent);}setCCbldSty2("colorpicker201","vs","hidden");setCCbldSty2("colorpicker201","ds","none");}function showColorGrid2(Sam,textBoxId){var objX=new Array("00","33","66","99","CC","FF");var c=0;var xl="\""+Sam+"\",\"x\", \""+textBoxId+"\"";var mid="";mid+="<table bgcolor=\"#FFFFFF\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:solid 0px #F0F0F0;padding:2px;\"><tr>";mid+="<td colspan='9' align='left' style='margin:0;padding:2px;height:12px;' ><input class='o5582n66' type='text' size='12' id='o5582n66' value='#FFFFFF'><input class='o5582n66a' type='text' size='2' style='width:14px;' id='o5582n66a' onclick='javascript:alert(\"click on selected swatch below...\");' value='' style='border:solid 1px #666;'></td><td colspan='9' align='right'><a class='o5582n66' href='javascript:onclick=putOBJxColor2("+xl+")'><span class='a01p3'>"+clos1+"</span></a></td></tr><tr>";var br=1;for(o=0;o<6;o++){mid+="</tr><tr>";for(y=0;y<6;y++){if(y==3){mid+="</tr><tr>";}for(x=0;x<6;x++){var grid="";grid=objX[o]+objX[y]+objX[x];var b="'"+Sam+"','"+grid+"', '"+textBoxId+"'";mid+="<td class=\"o5582brd\" style=\"background-color:#"+grid+"\"><a class=\"o5582n66\"  href=\"javascript:onclick=putOBJxColor2("+b+");\" onmouseover=javascript:document.getElementById(\"o5582n66\").value=\"#"+grid+"\";javascript:document.getElementById(\"o5582n66a\").style.backgroundColor=\"#"+grid+"\";  title=\"#"+grid+"\"><div style=\"width:12px;height:14px;\"></div></a></td>";c++;}}}mid+="</tr></table>";document.getElementById("colorpicker201").innerHTML=mid;setCCbldSty2("colorpicker201","vs","visible");setCCbldSty2("colorpicker201","ds","inline");}function doFontName(fontname){if(editorVisible){ifm.contentWindow.focus();myeditor.execCommand("FontName",0,fontname);}else{AddTag("[khungspan="+fontname+"]","[/khungspan]");}}function doFontSize(fontsize){if(this.editorVisible){this.ifm.contentWindow.focus();if(this.isIE){this.textRange=this.ifm.contentWindow.document.selection.createRange();this.textRange.select();}myeditor.execCommand("fontsize",false,fontsize);}else{AddTag("[phon= size=\""+fontsize+"\"]","[/phon]");}}function doSUP(){if(editorVisible==commanarea){AddTag("[SUP]","[/SUP]");}else{ifm.contentWindow.focus();myeditor.execCommand("Superscript",commanarea,valforget);}}function doSUB(){if(editorVisible==commanarea){AddTag("[SUB]","[/SUB]");}else{ifm.contentWindow.focus();myeditor.execCommand("Subscript",commanarea,valforget);}}function doLine(){if(editorVisible==commanarea){InsertText("[hr]");}else{ifm.contentWindow.focus();myeditor.execCommand("InsertHorizontalRule",commanarea,valforget);}}function doStrike(){if(editorVisible==commanarea){AddTag("[khungspan= style=\"text-decoration: line-through;\"]","[/khungspan]");}else{ifm.contentWindow.focus();myeditor.execCommand("StrikeThrough",commanarea,valforget);}}function doIndent(){if(editorVisible==commanarea){AddTag("[divet=\" style=\"margin-left: 40px;\"\"]","[/divet]");}else{ifm.contentWindow.focus();myeditor.execCommand("Indent",commanarea,valforget);}}function doOutdent(){ifm.contentWindow.focus();myeditor.execCommand("Outdent",commanarea,valforget);}function doUnlink(){ifm.contentWindow.focus();myeditor.execCommand("Unlink",commanarea,valforget);}function doDelete(){ifm.contentWindow.focus();myeditor.execCommand("Delete",commanarea,valforget);}function doChar(Cah){InsertText(Cah);}function putOBJxColors(Samp,pigMent,textBoxId){if(pigMent!="x"){setCCbldID2(pigMent,textBoxId);setCCbldStys(Samp,"bc",pigMent);}setCCbldStys("colorpicker201","vs","hidden");setCCbldStys("colorpicker201","ds","none");}function setCCbldStys(objID,prop,val){ifm.contentWindow.focus();myeditor.execCommand("HiliteColor",commanarea,val);myeditor.execCommand("ForeColor",commanarea,"black");switch(prop){case"bc":if(objID!="none"){document.getElementById(objID).style.backgroundColor=val;}break;case"vs":document.getElementById(objID).style.visibility=val;break;case"ds":document.getElementById(objID).style.display=val;break;case"tp":document.getElementById(objID).style.top=val;break;case"lf":document.getElementById(objID).style.left=val;break;default:;}}function showColorGrids(Sam,textBoxId){var objX=new Array("00","33","66","99","CC","FF");var c=0;var xl="\""+Sam+"\",\"x\", \""+textBoxId+"\"";var mid="";mid+="<table bgcolor=\"#FFFFFF\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:solid 0px #F0F0F0;padding:2px;\"><tr>";mid+="<td colspan='9' align='left' style='margin:0;padding:2px;height:12px;' ><input class='o5582n66' type='text' size='12' id='o5582n66' value='#FFFFFF'><input class='o5582n66a' type='text' size='2' style='width:14px;' id='o5582n66a' onclick='javascript:alert(\"click on selected swatch below...\");' value='' style='border:solid 1px #666;'></td><td colspan='9' align='right'><a class='o5582n66' href='javascript:onclick=putOBJxColors("+xl+")'><span class='a01p3'>"+clos1+"</span></a></td></tr><tr>";var br=1;for(o=0;o<6;o++){mid+="</tr><tr>";for(y=0;y<6;y++){if(y==3){mid+="</tr><tr>";}for(x=0;x<6;x++){var grid="";grid=objX[o]+objX[y]+objX[x];var b="'"+Sam+"','"+grid+"', '"+textBoxId+"'";mid+="<td class=\"o5582brd\" style=\"background-color:#"+grid+"\"><a class=\"o5582n66\"  href=\"javascript:onclick=putOBJxColors("+b+");\" onmouseover=javascript:document.getElementById(\"o5582n66\").value=\"#"+grid+"\";javascript:document.getElementById(\"o5582n66a\").style.backgroundColor=\"#"+grid+"\";  title=\"#"+grid+"\"><div style=\"width:12px;height:14px;\"></div></a></td>";c++;}}}mid+="</tr></table>";document.getElementById("colorpicker201").innerHTML=mid;setCCbldStys("colorpicker201","vs","visible");setCCbldStys("colorpicker201","ds","inline");}function doFlash(){var fromurl=prompt("Insert your flash url:","http://");var chieudaiflash=prompt("The width of embed:","475");var chieurongflash=prompt("The height of embed:","400");InsertText("[flash="+chieudaiflash+","+chieurongflash+"]"+fromurl+"[/flash]");}function doFLV(){var fromurl=prompt("Insert your flv url:","http://");var chieudaiflash=prompt("The width of embed:","475");var chieurongflash=prompt("The height of embed:","400");InsertText("[flv="+chieudaiflash+","+chieurongflash+"]"+fromurl+"[/flv]");}function doMP3(){var fromurl=prompt("Insert your mp3 url:","http://");InsertText("[mp3]"+fromurl+"[/mp3]");}function doYoutube(){var fromurl=prompt("Insert your Youtube Video url:","http://");InsertText("[url="+fromurl+"]Youtube Video[/url]");}function doHideMOD(){var fromurl=prompt("Insert the post count to view link:","5");var count="0";if(fromurl==valforget){count="5";}else{count=fromurl;}if(editorVisible){ifm.contentWindow.focus();if(isIE){textRange=ifm.contentWindow.document.selection.createRange();var newTxt="[hide="+count+"]"+textRange.text+"[/hide]";textRange.text=newTxt;}else{var edittext=ifm.contentWindow.getSelection().getRangeAt(0);var original=edittext.toString();edittext.deleteContents();edittext.insertNode(document.createTextNode("[hide="+count+"]"+original+"[/hide]"));}}else{AddTag("[hide="+count+"]","[/hide]");}}function doZingMP3(){var fromurl=prompt("Insert your Zing Mp3 url:","http://");if(fromurl=="http://"){return false;}else if(fromurl==valforget){return false;}else{InsertText("[zingmp3]"+fromurl+"[/zingmp3]");}}function doNhaccuatao(){var fromurl=prompt("Insert your NhacCuaTui.Com url:","http://");if(fromurl=="http://"){return false;}else if(fromurl==valforget){return false;}else{InsertText("[nhaccuatui]"+fromurl+"[/nhaccuatui]");}}function doClipVN(){var fromurl=prompt("Insert your Clip.VN url:","http://");if(fromurl=="http://"){return false;}else if(fromurl==valforget){return false;}else{InsertText("[clipvn]"+fromurl+"[/clipvn]");}}function doDownLoadMyCode(){var fromurl=prompt("Insert The DownLoad Link, Split by ',':","http://");if(fromurl=="http://"){return false;}else if(fromurl==valforget){return false;}else{fromurl=fromurl.split(",");if(editorVisible==commanarea){InsertText("[divet=\" style=\"-moz-border-radius: 5px 5px 5px 5px; border: 2px solid rgb(245, 208, 19); background-color: rgb(254, 254, 155); width: 500px;\"\"][b][phon= color=\"#a12004\" size=\"5\"]Download Link[/phon][/b]:[xuongdong][/xuongdong]");for(var i=0;i<fromurl.length;i++){InsertText("[b][url="+fromurl[i]+"]"+fromurl[i]+"[/url][/b][xuongdong][/xuongdong]");}InsertText("[/divet]");}else{insertHtml("<div style=\"-moz-border-radius:5px 5px 5px 5px;border: 2px solid rgb(245, 208, 19); background-color: rgb(254, 254, 155); width: 500px;\"><strong><font size=\"5\" color=\"#a12004\">Download Link</font></strong>:<br/></div>");for(var i=0;i<fromurl.length;i++){insertHtml("<br/><b><a href=\""+fromurl[i]+"\">"+fromurl[i]+"</a></b><br/>");}}}}
