var i_am='rte';var DEBUG=0;var isRichText=false;var css_off=false;var rng;var currentRTE;var allRTEs="";var rte="";var rtewindow;var rtedocument;var rteready;var isIE;var isGecko;var isSafari;var isKonqueror;var imagesPath;var includesPath;var g_buttons;var g_rte;var g_tablewidth;var g_width_unit;var g_imagesPath;var g_width;var g_height;var g_readOnly;var g_includesPath var g_html;var g_DEBUG;var currentfont;var currentsize;var button_status=new Array();var viewingHTML=0;var viewingFS=0;var buttons_update=new Array("bold","italic","underline","strikethrough","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist");var opentags={'bold':0,'italic':0,'strikethrough':0,'underline':0,'forecolor':0,'fontname':0,'fontsize':0};function init_rte(imgPath,incPath){var ua=navigator.userAgent.toLowerCase();isIE=((ua.indexOf("msie")!=-1)&&(ua.indexOf("opera")==-1)&&(ua.indexOf("webtv")==-1));isGecko=(ua.indexOf("gecko")!=-1);isSafari=(ua.indexOf("safari")!=-1);isKonqueror=(ua.indexOf("konqueror")!=-1);if(document.getElementById&&document.designMode&&!isSafari&&!isKonqueror){isRichText=true;}if(isIE){document.onmouseover=ie_raise_button;document.onmouseout=ie_normal_button;document.onmousedown=ie_lower_button;document.onmouseup=ie_raise_button;}imagesPath=imgPath;includesPath=incPath;}function write_rte_editor(fieldname,html,width,height,buttons,readOnly){rte=fieldname;if(isRichText){if(allRTEs.length>0){allRTEs+=";";}allRTEs+=rte;write_rte(html,width,height,buttons,readOnly);}else{write_default(html,width,height,buttons,readOnly);}}function write_default(html,width,height,buttons,readOnly){if(!readOnly){document.writeln('');}else{document.writeln('');}}function write_rte(html,width,height,buttons,readOnly){if(readOnly)buttons=false;var o_width=width;var o_height=height;width=parseInt(width);height=parseInt(height);if(isIE){if(!o_width.match( /%/)){if(buttons&&(width<400)){width=400;}g_width_unit='px';var tablewidth=width+4;}else{g_width_unit='%';var tablewidth=width;width=width;}}else{if(!o_width.match( /%/)){if(buttons&&(width<400)){width=400;}g_width_unit='px';var tablewidth=width+2;}else{g_width_unit='%';var tablewidth=width;width=width;}}g_buttons=buttons;g_rte=rte;g_tablewidth=tablewidth;g_imagesPath=imagesPath;g_width=width;g_height=height;g_readOnly=readOnly;g_includesPath=includesPath;g_html=html;g_DEBUG=DEBUG;boo_to_int=isRichText==true?1:0;document.writeln("");write_rte_html();document.getElementById('hdn_rte_content').value=html;enable_design_mode(make_newlines_safe(html),readOnly);poss_images=document.getElementsByTagName('img');if(poss_images.length){for(var i in poss_images){if(poss_images[i].className=='rteimage'){poss_images[i].unselectable=true;}}}if(isIE&&ie_ptags_to_newlines){rtewindow=frames[rte];var _test=new Array('Indent','Outdent','JustifyLeft','JustifyCenter','JustifyRight','InsertOrderedList','InsertUnorderedList');rtewindow.document.onkeydown=function(){if(rtewindow.event.keyCode==13){for(var i in _test){if(rtewindow.document.queryCommandState(_test[i])){return true;}}var sel=rtewindow.document.selection;var ts=rtewindow.document.selection.createRange();var t=ts.htmlText.replace(/]*)>(.*)<\/p>/i,'$2');if((sel.type=="Text"||sel.type=="None")){ts.pasteHTML("
"+t+"\n");}else{rtewindow.document.body.innerHTML+="
\n";}rtewindow.event.returnValue=false;ts.select();rtewindow.focus();return false;}}}}function enable_design_mode(html,readOnly){var use_charset='';try{use_charset=g_CHARSET;}catch(e){}use_charset=use_charset?use_charset:'iso-8859-1';var frameHtml="\n";frameHtml+="\n";frameHtml+=''+"\n";frameHtml+="\n";frameHtml+="\n";frameHtml+="\n";frameHtml+=html+"\n";frameHtml+="\n";frameHtml+="";if(isIE){try{rtewindow=frames[rte];rtewindow.document.open();rtewindow.document.write(frameHtml);rtewindow.document.close();}catch(e){alert(e);}if(!readOnly){rtewindow.document.designMode="On";}rtewindow.document.onmouseup=rte_button_update;rtewindow.document.onkeyup=rte_button_update;}else{try{rtewindow=document.getElementById(rte).contentWindow;rtedocument=document.getElementById(rte).contentDocument;if(!readOnly){rtedocument.designMode="on";}try{rtewindow.document.open();rtewindow.document.write(frameHtml);rtewindow.document.close();rtewindow.document.body.style.fontSize='10pt';rtewindow.document.addEventListener("mouseup",rte_button_update,true);rtewindow.document.addEventListener("keyup",rte_button_update,true);if(isGecko&&!readOnly){rtewindow.document.addEventListener("keypress",kb_handler,true);}}catch(e){alert(jsfile_errorc_lang+e);}}catch(e){if(isGecko){setTimeout("enable_design_mode('"+rte+"', '"+make_newlines_safe(html)+"', "+readOnly+");",10);}else{return false;}}}for(var i in buttons_update){button_status[buttons_update[i]]=false;}rteready=1;}function update_rte(){if(!isRichText)return;var oHdnMessage=document.getElementById('hdn_rte_content');var readOnly=false;if(isIE){if(rtewindow.document.designMode!="On"){readOnly=true;}}else{if(rtedocument.designMode!="on"){readOnly=true;}}if(isRichText&&!readOnly){if(viewingHTML){toggleHTMLSrc();}if(oHdnMessage.value==null){oHdnMessage.value="";}oHdnMessage.value=rtewindow.document.body.innerHTML;if(strip_html(oHdnMessage.value.replace(" "," "))==""&&oHdnMessage.value.toLowerCase().search("<$1$2>
");t=t.replace( /<\/(p|div)([^&]*)>/ig,"
</$1$2>
");t=t.replace( /<br \/>(?!<\/td)/ig,"<br />
");t=t.replace( /<\/(td|tr|tbody|table)>/ig,"</$1>
");t=t.replace( /<(tr|tbody|table(.+?)?)>/ig,"<$1>
");t=t.replace( /<(td(.+?)?)>/ig," <$1>");t=t.replace( /<p> <\/p>/ig,"<br />");return t;}function rte_button_update(command){if(viewingHTML){return false;}if(!rteready){return false;}try{var cmd_state;for(var i in buttons_update){cmd_state=rtewindow.document.queryCommandState(buttons_update[i]);if(typeof(button_status[buttons_update[i]])!="undefined"&&button_status[buttons_update[i]]!=cmd_state){prev_state=button_status[buttons_update[i]];button_status[buttons_update[i]]=cmd_state;rte_button_context(my_getbyid('do_'+buttons_update[i]),prev_state==true?"mouseout":"mouseover");}}}catch(e){}font_context=rtewindow.document.queryCommandValue("fontname");if(font_context==""){if(isIE){font_context=document.body.style.fontFamily;}}else if(font_context==null){font_context="";}if(font_context!=false&&font_context!=currentfont){fontword=font_context;commapos=fontword.indexOf(",");if(commapos!=-1){fontword=fontword.substr(0,commapos);}fontword=fontword.toLowerCase();document.getElementById("fontname").selectedIndex=ips_reverse_primary_fonts[fontword];currentfont=font_context;}size_context=rtewindow.document.queryCommandValue("fontsize");if(size_context==""){if(!isIE){size_context=ips_fontsizes[rtewindow.document.body.style.fontSize];}}else if(size_context==null){size_context="";}if(size_context!=currentsize){document.getElementById("fontsize").selectedIndex=ips_reverse_font_sizes[size_context];currentsize=size_context;}rtewindow.focus();}function rte_window_resize(elid,pix){var box=my_getbyid(elid);var cur_height=parseInt(box.style.height);cur_height=cur_height?cur_height:g_height;var new_height=cur_height+pix;if(new_height>0){box.style.height=new_height+"px";}return false;}function rte_button_context(element,state){if(element==null){return;}command=element.id.toString();command=command.replace( /do_/,"");if(typeof(button_status[command])=="undefined"){button_status[command]=null;}try{switch(state){case "click":case "mouseout":{element.className='rteimage';}break;case "mouseup":case "mouseover":{element.className='rteImageRaised';}break;case "mousedown":{element.className='rteImageRaised';}break;}}catch(e){}}function format_text(command,option){if(isGecko){rtewindow.document.execCommand("inserthtml",false,"-");rtewindow.document.execCommand("undo",false,null);}if(isIE){var selection=rtewindow.document.selection;if(selection!=null){rng=selection.createRange();}}else if(is_safari){var selection=rtewindow.getSelection();}else{var selection=rtewindow.getSelection();rng=selection.getRangeAt(selection.rangeCount-1).cloneRange();}try{if((command=="forecolor")||(command=="hilitecolor")){parent.command=command;buttonElement=document.getElementById(command);var iLeftPos=getOffsetLeft(buttonElement);var iTopPos=getOffsetTop(buttonElement)+(buttonElement.offsetHeight+30);document.getElementById('cp').style.left=(iLeftPos)+"px";document.getElementById('cp').style.top=(iTopPos)+"px";if(document.getElementById('cp').style.visibility=="hidden"){document.getElementById('cp').style.visibility="visible";document.getElementById('cp').style.display="inline";}else{document.getElementById('cp').style.visibility="hidden";document.getElementById('cp').style.display="none";}}else if(command=='cut'||command=='copy'||command=='paste'){try{rtewindow.document.execCommand(command,false,null);}catch(e){if(isGecko){alert(jsfile_alert1+jsfile_alert2+jsfile_alert3+"\n"+jsfile_alert4);}}}else if(command=="createlink"){if(isIE){var check_text=rng.htmlText;}else{var check_text=_gecko_get_html();}if(!check_text){alert(jsfile_highlight_lang);return false;}else{var szURL=prompt(text_enter_url,"http://");}try{var pass_link=0;if(szURL.substring(0,7)=='http://'){pass_link=1;}if(szURL.substring(0,8)=='https://'){pass_link=1;}if(szURL.substring(0,6)=='ftp://'){pass_link=1;}if(pass_link==0){szURL=null;}rtewindow.document.execCommand("Unlink",false,null);rtewindow.document.execCommand("CreateLink",false,szURL);}catch(e){}}else if((command=='justifyleft'||command=='justifycenter'||command=='justifyright')&&isIE&&ie_ptags_to_newlines){var _a=command.replace("justify","");wrap_tags("["+_a+"]","[/"+_a+"]");}else if((command=='outdent'||command=='indent'||command=='insertorderedlist'||command=='insertunorderedlist')&&isIE&&ie_ptags_to_newlines){rtewindow.focus();var sel=rtewindow.document.selection;var ts=rtewindow.document.selection.createRange();var t=ts.htmlText.replace(/]*)>(.*)<\/p>/i,'$2');if((sel.type=="Text"||sel.type=="None")){ts.pasteHTML(t+"

\n");}else{rtewindow.document.body.innerHTML+="

";}rtewindow.focus();rtewindow.document.execCommand(command,false,null);rte_button_update(command);rtewindow.focus();}else{rtewindow.focus();_gecko_kill_css();rtewindow.document.execCommand(command,false,null);rte_button_update(command);rtewindow.focus();}}catch(e){alert(e);}}function show_smilies(){buttonElement=document.getElementById('popsmilies');var iLeftPos=getOffsetLeft(buttonElement);var iTopPos=getOffsetTop(buttonElement)+(buttonElement.offsetHeight+30);document.getElementById('smiliestable').style.left=(iLeftPos)+"px";document.getElementById('smiliestable').style.top=(iTopPos)+"px";if(document.getElementById('smiliestable').style.visibility=="hidden"){document.getElementById('smiliestable').style.visibility="visible";document.getElementById('smiliestable').style.display="inline";}else{document.getElementById('smiliestable').style.visibility="hidden";document.getElementById('smiliestable').style.display="none";}}function setColor(color){var parentCommand=parent.command;if(isIE){var sel=rtewindow.document.selection;if(parentCommand=="hilitecolor")parentCommand="backcolor";if(sel!=null){var newRng=sel.createRange();newRng=rng;newRng.select();}}rtewindow.focus();_gecko_kill_css();rtewindow.document.execCommand(parentCommand,false,color);rtewindow.focus();document.getElementById('cp').style.visibility="hidden";document.getElementById('cp').style.display="none";}function add_email(){if(isIE){var selection=rtewindow.document.selection;if(selection!=null){rng=selection.createRange();}var rng_len=rng.text.length;}else{var selection=rtewindow.getSelection();rng=selection.getRangeAt(selection.rangeCount-1).cloneRange();}emailaddress=prompt(text_enter_email,'');if((emailaddress!=null)&&(emailaddress!="")){if(isIE){if(rng_len!="undefined"&&rng_len>0){rtewindow.focus();_gecko_kill_css();rtewindow.document.execCommand('createlink',false,'mailto:'+emailaddress);rtewindow.focus();}else{emailHTML=''+emailaddress+'';wrap_tags(""+emailHTML,"");rtewindow.focus();}}else if((rng!=null)&&(rng!="")){rtewindow.focus();_gecko_kill_css();rtewindow.document.execCommand('createlink',false,'mailto:'+emailaddress);rtewindow.focus();}else{emailHTML=''+emailaddress+'';wrap_tags(""+emailHTML,"");rtewindow.focus();}}}function add_image(){if(isIE){var selection=rtewindow.document.selection;if(selection!=null){rng=selection.createRange();}}else{var selection=rtewindow.getSelection();rng=selection.getRangeAt(selection.rangeCount-1).cloneRange();}imagePath=prompt(text_enter_image,'http://');var pass_image=0;if(imagePath.substring(0,7)=='http://'){pass_image=1;}if(imagePath.substring(0,8)=='https://'){pass_image=1;}if(imagePath.substring(0,6)=='ftp://'){pass_image=1;}if(pass_image==0){imagePath=null;}if((imagePath!=null)&&(imagePath!="")){rtewindow.focus();_gecko_kill_css();rtewindow.document.execCommand('InsertImage',false,imagePath);rtewindow.focus();}}function checkspell(){try{var tmpis=new ActiveXObject("ieSpell.ieSpellExtension");tmpis.CheckAllLinkedDocuments(document);}catch(exception){if(exception.number==-2146827859){if(confirm(jsfile_erroriespell))window.open("http://www.iespell.com/download.php","DownLoad");}else{alert(jsfile_errorliespell+exception.number);}}}function emoticon(scode,smid,surl){rtewindow.focus();try{if(!surl){surl=document.getElementById(smid).src;}if(!isIE){rtewindow.focus();_gecko_kill_css();rtewindow.document.execCommand('InsertImage',false,surl);rtewindow.focus();var images=rtewindow.document.getElementsByTagName('img');for(var i=0;i<=images.length;i++){if(images[i].src==surl){if(!images[i].getAttribute('emoid')){images[i].setAttribute('emoid',scode);images[i].setAttribute('border','0');images[i].style.verticalAlign='middle';}}}}else{smilieHTML='';wrap_tags(""+smilieHTML,"");}}catch(e){}rtewindow.focus();if(emowindow!=''&&emowindow!='undefined'){emowindow.focus();}}function wrap_tags(opentag,closetag){var has_closed=false;if(!isRichText){return;}if(isIE){rtewindow.focus();var sel=rtewindow.document.selection;var ts=rtewindow.document.selection.createRange();var t=ts.htmlText.replace(/]*)>(.*)<\/p>/i,'$2');if((sel.type=="Text"||sel.type=="None")){has_closed=true;ts.pasteHTML(opentag+t+closetag);}else{has_closed=true;rtewindow.document.body.innerHTML+=opentag+closetag;}}else{var frag=rtewindow.document.createDocumentFragment();var span=rtewindow.document.createElement("span");sel_html=_gecko_get_html();var my_contents;var my_length;if(sel_html){has_closed=true;span.innerHTML=opentag+sel_html+closetag;my_contents=opentag+sel_html+closetag;}else{span.innerHTML=opentag+closetag;my_contents=opentag+closetag;}while(span.firstChild){frag.appendChild(span.firstChild);}my_length=my_contents.length?my_contents.length:0;_gecko_insert_node_at_selection(frag,my_length);}rtewindow.focus();return has_closed;}function do_select(selectname){if(isIE){var selection=rtewindow.document.selection;if(selection!=null){rng=selection.createRange();}}else{var selection=rtewindow.getSelection();rng=selection.getRangeAt(selection.rangeCount-1).cloneRange();}var idx=document.getElementById(selectname).selectedIndex;var selected=document.getElementById(selectname).options[idx].value;rtewindow.focus();_gecko_kill_css();rtewindow.document.execCommand(selectname,false,selected);rte_button_update(selectname);rtewindow.focus();}function launch_rte_fs(){if(viewingFS){}if(viewingHTML){toggleHTMLSrc();}viewingFS=1;window.open(ipb_var_base_url+'&act=rtefs','RTEFS','width=640,height=480,resizable=yes,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no');}function launch_div(){window.open(includesPath+'insert_div.html','DIV','width=550,height=340,resizable=yes,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no');}function write_div(param,pwindow){try{if(pwindow){pwindow.close();}}catch(e){}if(!param){return false;}var remap_elements={"f_fontfamily":"font-family","f_fontsize":"font-size","f_color":"color","f_backgroundimage":"background-image","f_backgroundrepeat":"background-repeat","f_backgroundcolor":"background-color","f_border":"border","f_padding":"padding","f_margin":"margin"};var tagtype=param["f_type"];var style="";if(!param["f_classes"]||param["f_classes"]=="__none"){style+="style='";for(var field in param){var value=param[field];if(!value||value=='undefined'||field=='undefined'||!remap_elements[field]){continue;}if(remap_elements[field]&&value){style+=remap_elements[field]+":"+value+";";}}style+=param["f_other"]+"'";}else{style+="class='"+param["f_classes"]+"'";}if(style){wrap_tags("<"+tagtype+" "+style+">","");}else{wrap_tags("<"+tagtype+">","")}return true;}function launch_table(){window.open(includesPath+'insert_table.html','TABLE','width=450,height=220,resizable=yes,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no');}function write_tables(param,pwindow){try{if(pwindow){pwindow.close();}}catch(e){}var sel=_my_getselection();var range=_my_createrange(sel);if(!param){return false;}var doc=rtewindow.document;var table=doc.createElement("table");for(var field in param){var value=param[field];if(!value){continue;}switch(field){case "f_width":table.style.width=value+param["f_unit"];break;case "f_align":table.align=value;break;case "f_border":table.border=parseInt(value);break;case "f_spacing":table.cellspacing=parseInt(value);break;case "f_padding":table.cellpadding=parseInt(value);break;}}var tbody=doc.createElement("tbody");table.appendChild(tbody);for(var i=0;i":">";}for(var i=root.firstChild;i;i=i.nextSibling){html+=_gecko_read_nodes(i,true);}if(toptag&&!closed){html+="";}}break;case Node.TEXT_NODE:{html=htmlspecialchars(root.data);}break;}return html;}function _gecko_insert_node_at_selection(text,text_length){var sel=_my_getselection();var range=_my_createrange(sel);var node=range.startContainer;var pos=range.startOffset;text_length=text_length?text_length:0;sel.removeAllRanges();range.deleteContents();if(node.nodeName=='HTML'){node=_goto_parent_then_body(node);}switch(node.nodeType){case 1:{if(text.nodeType==11){selNode=text.firstChild;}else{selNode=text;}node.insertBefore(text,node.childNodes[pos]);_gecko_add_range(selNode,text_length);}break;case 3:{if(text.nodeType==3){var text_length=pos+text.length;node.insertData(pos,text.data);range=rtewindow.document.createRange();range.setEnd(node,text_length);range.setStart(node,text_length);sel.addRange(range);}else{node=node.splitText(pos);var selNode;if(text.nodeType==11){selNode=text.firstChild;}else{selNode=text;}node.parentNode.insertBefore(text,node);_gecko_add_range(selNode,text_length);}}break;}}function _goto_parent_then_body(n){var o=n;while(n.parentNode!=null&&n.parentNode.nodeName=='HTML'){n=n.parentNode;}if(n){for(var c=0;c]+)>)/ig,"");newString=newString.replace(/\r\n/g," ");newString=newString.replace(/\n/g," ");newString=newString.replace(/\r/g," ");newString=trim(newString);return newString;}function make_newlines_safe(t){return t;}function trim(inputString){if(typeof inputString!="string")return inputString;var retValue=inputString;var ch=retValue.substring(0,1);while(ch==" "){retValue=retValue.substring(1,retValue.length);ch=retValue.substring(0,1);}ch=retValue.substring(retValue.length-1,retValue.length);while(ch==" "){retValue=retValue.substring(0,retValue.length-1);ch=retValue.substring(retValue.length-1,retValue.length);}while(retValue.indexOf(" ")!=-1){retValue=retValue.substring(0,retValue.indexOf(" "))+retValue.substring(retValue.indexOf(" ")+1,retValue.length);}return retValue;}function ValidateForm(isMsg){update_rte();MessageLength=3;errors="";try{if(postformobj.removeattachid.value>0){okdelete=confirm(js_remove_attach);if(okdelete==true){return true;}else{postformobj.removeattachid.value=0;return false;}}}catch(error){}if(isMsg==1){if(postformobj.msg_title.value.length<2){errors=js_msg_no_title;}}if(MessageLength<2){errors=js_no_message;}if(MessageMax!=0){if(MessageLength>MessageMax){errors=js_max_length+" "+MessageMax+" "+js_characters+". "+js_current+": "+MessageLength;}}if(errors!=""&&Override==""){alert(errors);return false;}else{try{postformobj.submit.disabled=true;}catch(e){try{postformobj.dosubmit.disabled=true;}catch(e){}}return true;}}function htmlspecialchars(html){html=html.replace(/"/,""");html=html.replace(//,">");return html;}