var rte_tag="-rte-tmp-tag-";var rte_toolbar={s1:{separator:true},bold:{command:"bold",tags:["b","strong"]},italic:{command:"italic",tags:["i","em"]},strikeThrough:{command:"strikethrough",tags:["s","strike"]},underline:{command:"underline",tags:["u"]},s2:{separator:true},justifyLeft:{command:"justifyleft"},justifyCenter:{command:"justifycenter"},justifyRight:{command:"justifyright"},justifyFull:{command:"justifyfull"},s3:{separator:true},indent:{command:"indent"},outdent:{command:"outdent"},s4:{separator:true},subscript:{command:"subscript",tags:["sub"]},superscript:{command:"superscript",tags:["sup"]},s5:{separator:true},orderedList:{command:"insertorderedlist",tags:["ol"]},unorderedList:{command:"insertunorderedlist",tags:["ul"]},s6:{separator:true},block:{command:"formatblock",select:'<select>	<option value="">- style -</option>	<option value="<p>">Paragraph</option>	<option value="<h1>">Header 1</option>	<option value="<h2>">Header 2</options>	<option value="<h3>">Header 3</option>	<option value="<h4>">Header 4</options>	<option value="<h5>">Header 5</option>	<option value="<h6>">Header 6</options></select>	',arg_cmp:function(b,a){a=a.replace(/<([^>]*)>/,"$1");return(a.toLowerCase()==b.nodeName.toLowerCase())},tags:["p","h1","h2","h3","h4","h5","h6"]},font:{command:"fontname",select:'<select>	<option value="">- font -</option>	<option value="arial">Arial</option>	<option value="comic sans ms">Comic Sans</option>	<option value="courier new">Courier New</options>	<option value="georgia">Georgia</option>	<option value="helvetica">Helvetica</options>	<option value="impact">Impact</option>	<option value="times new roman">Times</options>	<option value="trebuchet ms">Trebuchet</options>	<option value="verdana">Verdana</options></select>	',tags:["font"]},size:{command:"fontsize",select:'<select>	<option value="">-</option>	<option value="1">1 (8pt)</option>	<option value="2">2 (10pt)</option>	<option value="3">3 (12pt)</options>	<option value="4">4 (14pt)</option>	<option value="5">5 (16pt)</options>	<option value="6">6 (18pt)</option>	<option value="7">7 (20pt)</options></select>	',tags:["font"]},color:{exec:function(){var p=this;var a=p.create_panel("Set color for text",385);var n=false;var j=false;a.append('<div class="colorpicker1"><div class="rgb" id="rgb"></div></div><div class="colorpicker1"><div class="gray" id="gray"></div></div><div class="colorpicker2">	<div class="palette" id="palette"></div>	<div class="preview" id="preview"></div>	<div class="color" id="color"></div></div><div class="clear"></div><p class="submit"><button id="ok">Ok</button><button id="cancel">Cancel</button></p>').show();var l=$("#preview",a);var f=$("#color",a);var d=$("#palette",a);var b=["#660000","#990000","#cc0000","#ff0000","#333333","#006600","#009900","#00cc00","#00ff00","#666666","#000066","#000099","#0000cc","#0000ff","#999999","#909000","#900090","#009090","#ffffff","#cccccc","#ffff00","#ff00ff","#00ffff","#000000","#eeeeee"];for(var h=0;h<25;h++){$("<div></div>").addClass("item").css("background",b[h]).appendTo(d)}var o=$("#rgb").height();var k=$("#rgb").width()/6;$("#rgb,#gray,#palette",a).mousedown(function(i){n=true;return false}).mouseup(function(i){n=false;return false}).mouseout(function(i){j=false;return false}).mouseover(function(i){j=true;return false});$("#rgb").mousemove(function(i){if(n&&j){m(this,true,false,false,i)}return false});$("#gray").mousemove(function(i){if(n&&j){m(this,false,true,false,i)}return false});$("#palette").mousemove(function(i){if(n&&j){m(this,false,false,true,i)}return false});$("#rgb").click(function(i){m(this,true,false,false,i);return false});$("#gray").click(function(i){m(this,false,true,false,i);return false});$("#palette").click(function(i){m(this,false,false,true,i);return false});$("#cancel",a).click(function(){a.remove();return false});$("#ok",a).click(function(){var i=f.html();if(i.length>0&&i.charAt(0)=="#"){if(p.iframe_doc.selection){p.range.select()}p.editor_cmd("foreColor",i)}a.remove();return false});function g(q){var i="0123456789abcdef";return i.charAt(Math.floor(q/16))+i.charAt(q%16)}function e(q){var s={x:q.offsetLeft,y:q.offsetTop};if(q.offsetParent){var i=e(q.offsetParent);s.x+=i.x;s.y+=i.y}return s}function c(s,r){var i,u;r=r||window.event;var q=r.target||r.srcElement;var t=e(s);i=r.pageX-t.x;u=r.pageY-t.y;return{x:i,y:u}}function m(u,q,E,s,z){var i,v,C,A;var w=c(u,z);var D=w.x;var B=w.y;if(q){i=(D>=0)*(D<k)*255+(D>=k)*(D<2*k)*(2*255-D*255/k)+(D>=4*k)*(D<5*k)*(-4*255+D*255/k)+(D>=5*k)*(D<6*k)*255;v=(D>=0)*(D<k)*(D*255/k)+(D>=k)*(D<3*k)*255+(D>=3*k)*(D<4*k)*(4*255-D*255/k);C=(D>=2*k)*(D<3*k)*(-2*255+D*255/k)+(D>=3*k)*(D<5*k)*255+(D>=5*k)*(D<6*k)*(6*255-D*255/k);var t=(o-B)/o;i=128+(i-128)*t;v=128+(v-128)*t;C=128+(C-128)*t}else{if(E){i=v=C=(o-B)*1.7}else{if(s){D=Math.floor(D/10);B=Math.floor(B/10);A=b[D+B*5]}}}if(!s){A="#"+g(i)+g(v)+g(C)}l.css("background",A);f.html(A)}}},image:{exec:function(){var self=this;var panel=self.create_panel("Insert image",385);panel.append('<p><label>URL</label><input type="text" id="url" size="30" value=""><button id="file">Upload</button><button id="view">View</button></p><div class="clear"></div><p class="submit"><button id="ok">Ok</button><button id="cancel">Cancel</button></p>').show();var url=$("#url",panel);var upload=$("#file",panel).upload({autoSubmit:false,action:"uploader.php",onSelect:function(){var file=this.filename();var ext=(/[.]/.exec(file))?/[^.]+$/.exec(file.toLowerCase()):"";if(!(ext&&/^(jpg|png|jpeg|gif)$/.test(ext))){alert("Invalid file extension");return}this.submit()},onComplete:function(response){if(response.length<=0){return}response=eval("("+response+")");if(response.error&&response.error.length>0){alert(response.error)}else{url.val((response.file&&response.file.length>0)?response.file:"")}}});$("#view",panel).click(function(){(url.val().length>0)?window.open(url.val()):alert("Enter URL of image to view");return false});$("#cancel",panel).click(function(){panel.remove();return false});$("#ok",panel).click(function(){var file=url.val();self.editor_cmd("insertImage",file);panel.remove();return false})},tags:["img"]},link:{exec:function(){var self=this;var panel=self.create_panel("Create link / Attach file",385);panel.append('<p><label>URL</label><input type="text" id="url" size="30" value=""><button id="file">Attach File</button><button id="view">View</button></p><div class="clear"></div><p><label>Title</label><input type="text" id="title" size="30" value=""><label>Target</label><select id="target"><option value="">default</option><option value="_blank">new</option></select></p><div class="clear"></div><p class="submit"><button id="ok">Ok</button><button id="cancel">Cancel</button></p>').show();$("#cancel",panel).click(function(){panel.remove();return false});var url=$("#url",panel);var upload=$("#file",panel).upload({autoSubmit:true,action:"uploader.php",onComplete:function(response){if(response.length<=0){return}response=eval("("+response+")");if(response.error&&response.error.length>0){alert(response.error)}else{url.val((response.file&&response.file.length>0)?response.file:"")}}});$("#view",panel).click(function(){(url.val().length>0)?window.open(url.val()):alert("Enter URL to view");return false});$("#ok",panel).click(function(){var url=$("#url",panel).val();var target=$("#target",panel).val();var title=$("#title",panel).val();if(self.get_selected_text().length<=0){alert("Select the text you wish to link!");return false}panel.remove();if(url.length<=0){return false}self.editor_cmd("unlink");self.editor_cmd("createLink",rte_tag);var tmp=$("<span></span>").append(self.get_selected_html());if(target.length>0){$('a[href*="'+rte_tag+'"]',tmp).attr("target",target)}if(title.length>0){$('a[href*="'+rte_tag+'"]',tmp).attr("title",title)}$('a[href*="'+rte_tag+'"]',tmp).attr("href",url);self.selection_replace_with(tmp.html());return false})},tags:["a"]},unlink:{command:"unlink"},s8:{separator:true},removeFormat:{exec:function(){this.editor_cmd("removeFormat");this.editor_cmd("unlink")}},word:{exec:function(){this.set_content(cleanup_word(this.get_content(),true,true,true))}},clear:{exec:function(){if(confirm("Clear Document?")){this.set_content("")}}}};var html_toolbar={s1:{separator:true},word:{exec:function(){this.set_content(cleanup_word(this.get_content(),true,true,true))}},clear:{exec:function(){if(confirm("Clear Document?")){this.set_content("")}}}};function cleanup_word(c,a,d,e){c=c.replace(/<o:p>\s*<\/o:p>/g,"");c=c.replace(/<o:p>[\s\S]*?<\/o:p>/g,"&nbsp;");c=c.replace(/\s*mso-[^:]+:[^;"]+;?/gi,"");c=c.replace(/\s*MARGIN: 0cm 0cm 0pt\s*;/gi,"");c=c.replace(/\s*MARGIN: 0cm 0cm 0pt\s*"/gi,'"');c=c.replace(/\s*TEXT-INDENT: 0cm\s*;/gi,"");c=c.replace(/\s*TEXT-INDENT: 0cm\s*"/gi,'"');c=c.replace(/\s*TEXT-ALIGN: [^\s;]+;?"/gi,'"');c=c.replace(/\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi,'"');c=c.replace(/\s*FONT-VARIANT: [^\s;]+;?"/gi,'"');c=c.replace(/\s*tab-stops:[^;"]*;?/gi,"");c=c.replace(/\s*tab-stops:[^"]*/gi,"");if(a){c=c.replace(/\s*face="[^"]*"/gi,"");c=c.replace(/\s*face=[^ >]*/gi,"");c=c.replace(/\s*FONT-FAMILY:[^;"]*;?/gi,"")}c=c.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");if(d){c=c.replace(/<(\w[^>]*) style="([^\"]*)"([^>]*)/gi,"<$1$3")}c=c.replace(/<STYLE[^>]*>[\s\S]*?<\/STYLE[^>]*>/gi,"");c=c.replace(/<(?:META|LINK)[^>]*>\s*/gi,"");c=c.replace(/\s*style="\s*"/gi,"");c=c.replace(/<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi,"&nbsp;");c=c.replace(/<SPAN\s*[^>]*><\/SPAN>/gi,"");c=c.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");c=c.replace(/<SPAN\s*>([\s\S]*?)<\/SPAN>/gi,"$1");c=c.replace(/<FONT\s*>([\s\S]*?)<\/FONT>/gi,"$1");c=c.replace(/<\\?\?xml[^>]*>/gi,"");c=c.replace(/<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi,"");c=c.replace(/<\/?\w+:[^>]*>/gi,"");c=c.replace(/<\!--[\s\S]*?-->/g,"");c=c.replace(/<(U|I|STRIKE)>&nbsp;<\/\1>/g,"&nbsp;");c=c.replace(/<H\d>\s*<\/H\d>/gi,"");c=c.replace(/<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig,"");c=c.replace(/<(\w[^>]*) language=([^ |>]*)([^>]*)/gi,"<$1$3");c=c.replace(/<(\w[^>]*) onmouseover="([^\"]*)"([^>]*)/gi,"<$1$3");c=c.replace(/<(\w[^>]*) onmouseout="([^\"]*)"([^>]*)/gi,"<$1$3");if(e){c=c.replace(/<H(\d)([^>]*)>/gi,"<h$1>");c=c.replace(/<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi,"<$1>$2</$1>");c=c.replace(/<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi,"<$1>$2</$1>")}else{c=c.replace(/<H1([^>]*)>/gi,'<div$1><b><font size="6">');c=c.replace(/<H2([^>]*)>/gi,'<div$1><b><font size="5">');c=c.replace(/<H3([^>]*)>/gi,'<div$1><b><font size="4">');c=c.replace(/<H4([^>]*)>/gi,'<div$1><b><font size="3">');c=c.replace(/<H5([^>]*)>/gi,'<div$1><b><font size="2">');c=c.replace(/<H6([^>]*)>/gi,'<div$1><b><font size="1">');c=c.replace(/<\/H\d>/gi,"</font></b></div>");var b=new RegExp("(<P)([^>]*>[\\s\\S]*?)(</P>)","gi");c=c.replace(b,"<div$2</div>");c=c.replace(/<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g,"");c=c.replace(/<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g,"");c=c.replace(/<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g,"")}return c};