var ie_ptags_to_newlines=true;var IPS_editor=new Array();var buttons_update=new Array("bold","italic","underline","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist");var ips_primary_colors=new Array('#000000','#A0522D','#556B2F','#006400','#483D8B','#000080','#4B0082','#2F4F4F','#8B0000','#FF8C00','#808000','#008000','#008080','#0000FF','#708090','#696969','#FF0000','#F4A460','#9ACD32','#2E8B57','#48D1CC','#4169E1','#800080','#808080','#FF00FF','#FFA500','#FFFF00','#00FF00','#00FFFF','#00BFFF','#9932CC','#C0C0C0','#FFC0CB','#F5DEB3','#FFFACD','#98FB98','#AFEEEE','#ADD8E6','#DDA0DD','#FFFFFF');var ips_primary_fonts=new Array("Arial","Arial Black","Arial Narrow","Book Antiqua","Century Gothic","Comic Sans MS","Courier New","Franklin Gothic Medium","Garamond","Georgia","Impact","Lucida Console","Lucida Sans Unicode","Microsoft Sans Serif","Palatino Linotype","Tahoma","Times New Roman","Trebuchet MS","Verdana");var ips_primary_sizes=new Array(1,2,3,4,5,6,7);var ips_format_items={'cmd_subscript':'Sub-script','cmd_superscript':'Super-script','cmd_strikethrough':'Strikethrough'};var ips_format_item_images={'cmd_subscript':'rte-subscript.gif','cmd_superscript':'rte-superscript.gif','cmd_strikethrough':'rte-strike.gif'};ips_language_array={};function ips_text_editor(editor_id,mode,use_bbcode,file_path,initial_text){this.editor_id=editor_id;this.is_rte=mode;this.initialized=false;this.buttons=new Array();this.fonts=new Array();this.state=new Array();this.text_obj=document.getElementById(this.editor_id+'_textarea');this.control_obj=document.getElementById(this.editor_id+'_controls');this.font_obj=document.getElementById(this.editor_id+'_out_fontname');this.size_obj=document.getElementById(this.editor_id+'_out_fontsize');this.special_obj=document.getElementById(this.editor_id+'_out_special');this.format_obj=document.getElementById(this.editor_id+'_out_format');this.mainbar=document.getElementById(this.editor_id+'_main-bar');this.use_menus=(typeof(ipsmenu)=='undefined'?false:true);this.is_ie=is_ie;this.is_moz=is_moz;this.is_opera=is_opera;this.is_safari=is_safari;this.file_path=file_path?file_path:global_rte_includes_url;this.font_state=null;this.size_state=null;this.use_bbcode=use_bbcode;this.open_brace=this.use_bbcode?'[':'<';this.close_brace=this.use_bbcode?']':'>';this.allow_advanced=this.use_bbcode?0:1;this.ips_frame_html='';this.popups=new Array();this.char_set=global_rte_char_set?global_rte_char_set:'UTF-8';this.forum_fix_ie_newlines=0;this.emoticon_window_id='';this.is_loading=0;this.hidden_objects=new Array();this.history_pointer=-1;this.history_recordings=new Array();this._showing_html=0;this._ie_cache=null;this.current_bar_object=null;this.ips_special_items={};ips_format_items['cmd_subscript']=ips_language_array['js_rte_sub']?ips_language_array['js_rte_sub']:'Sub-script';ips_format_items['cmd_superscript']=ips_language_array['js_rte_sup']?ips_language_array['js_rte_sup']:'Super-script';ips_format_items['cmd_strikethrough']=ips_language_array['js_rte_strike']?ips_language_array['js_rte_strike']:'Strikethrough';ips_language_array['emos_show_all']=ips_language_array['emos_show_all']?ips_language_array['emos_show_all']:'Show All';this.init=function(){if(this.initialized){return;}this.control_obj.style.display='';try{document.getElementById(this.editor_id+'_wysiwyg_used').value=parseInt(this.is_rte);}catch(err){}this.ips_frame_html=this.get_frame_html();this.editor_set_content(initial_text);this.editor_set_functions();this.editor_set_controls();this.initialized=true;};this.get_frame_html=function(){var ips_frame_html="";ips_frame_html+="\n";ips_frame_html+="\n";ips_frame_html+="";ips_frame_html+="\n";ips_frame_html+="\n";ips_frame_html+="\n";ips_frame_html+="{:content:}\n";ips_frame_html+="\n";ips_frame_html+="";return ips_frame_html;};this.editor_check_focus=function(){if(!this.editor_window.has_focus){if(this.is_opera){this.editor_window.focus();}this.editor_window.focus();}};this.editor_set_controls=function(){var controls=new Array();var _c=0;if(!this.control_obj){return;}var items=this.control_obj.getElementsByTagName("DIV");for(var i=0;i'+ips_primary_sizes[i]+'';option.className='rte-menu-size';option.title=ips_primary_sizes[i];option.cmd=obj.cmd;option.editor_id=this.editor_id;option.onmouseover=option.onmouseout=option.onmouseup=option.onmousedown=ips_editor_events.prototype.menu_option_onmouseevent;option.onclick=ips_editor_events.prototype.font_format_option_onclick;menu.style.width=this.size_obj.style.width;menu.appendChild(option);}break;case 'fontname':for(var i in ips_primary_fonts){if(typeof(ips_primary_fonts[i])=='function'){continue;}var option=document.createElement('div');option.innerHTML=''+ips_primary_fonts[i]+'';option.className='rte-menu-face';option.title=ips_primary_fonts[i];option.cmd=obj.cmd;option.editor_id=this.editor_id;option.onmouseover=option.onmouseout=option.onmouseup=option.onmousedown=ips_editor_events.prototype.menu_option_onmouseevent;option.onclick=ips_editor_events.prototype.font_format_option_onclick;menu.style.width=this.font_obj.style.width;menu.appendChild(option);}break;case 'special':for(var i in this.ips_special_items){if(typeof(this.ips_special_items[i])=='function'){continue;}var option=document.createElement('div');var img=(typeof this.ips_special_items[i][1]!='undefined')?' ':'';option.innerHTML=img+this.ips_special_items[i][0];option.className='rte-menu-face';option.cmd='module_load',option.loader_key=i.replace('cmd_loader_','');option.editor_id=this.editor_id;option.onmouseover=option.onclick=option.onmouseout=option.onmouseup=option.onmousedown=ips_editor_events.prototype.special_onmouse_event;menu.style.width=this.special_obj.style.width;menu.appendChild(option);}break;case 'format':for(var i in ips_format_items){if(typeof(ips_format_items[i])=='function'){continue;}var option=document.createElement('div');var img=(typeof ips_format_item_images[i]!='undefined')?' ':'';option.innerHTML=img+ips_format_items[i];option.className='rte-menu-face';option.cmd=i.replace('cmd_','');option.editor_id=this.editor_id;option.onmouseover=option.onclick=option.onmouseout=option.onmouseup=option.onmousedown=ips_editor_events.prototype.special_onmouse_event;menu.style.width='130px';menu.appendChild(option);}break;case 'emoticons':var table=document.createElement('table');table.cellPadding=0;table.cellSpacing=0;table.border=0;if(this.is_ie){table.style.paddingRight='15px';}var i=0;var perrow=3;var tr=table.insertRow(-1);var td=tr.insertCell(-1);td.colSpan=perrow;td.align='center';td.cellPadding=0;td.innerHTML='
'+ips_language_array['emos_show_all']+'
';for(var emo in ips_smilie_items){if(i%perrow==0){var tr=table.insertRow(-1);}i++;var div=document.createElement('div');var _tmp=ips_smilie_items[emo].split(",");var img=' ';div.innerHTML=img;var option=tr.insertCell(-1);option.className='rte-menu-emo';option.appendChild(div);option.cmd=obj.cmd;option.editor_id=this.editor_id;option.id=this.editor_id+'_emoticon_'+_tmp[0];option.emo_id=_tmp[0];option.emo_image=_tmp[1];option.emo_code=emo;option.onmouseover=option.onmouseout=option.onmouseup=option.onmousedown=ips_editor_events.prototype.menu_option_onmouseevent;option.onclick=ips_editor_events.prototype.emoticon_onclick;}if(i>0){menu.style.width='auto';if(this.is_ie){menu.style.paddingRight='15px';}menu.style.height='200px';menu.style.overflow='auto';menu.style.overflowX='hidden';menu.appendChild(table);break;}else{menu.style.width='auto';menu.style.height='40px';menu.style.overflow='auto';menu.appendChild(table);break;}case 'forecolor':case 'backcolor':var table=document.createElement('table');table.cellPadding=0;table.cellSpacing=0;table.border=0;var i=0;for(var hex in ips_primary_colors){if(typeof(ips_primary_colors[hex])=='function'){continue;}if(i%8==0){var tr=table.insertRow(-1);}i++;var div=document.createElement('div');div.style.backgroundColor=ips_primary_colors[hex];div.innerHTML=' ';var option=tr.insertCell(-1);option.className='rte-menu-color';option.appendChild(div);option.cmd=obj.cmd;option.editor_id=this.editor_id;option.colorname=ips_primary_colors[hex];option.id=this.editor_id+'_color_'+ips_primary_colors[hex];option.onmouseover=option.onmouseout=option.onmouseup=option.onmousedown=ips_editor_events.prototype.menu_option_onmouseevent;option.onclick=ips_editor_events.prototype.color_cell_onclick;}menu.style.overflow='visible';menu.appendChild(table);break;}this.popups[obj.cmd]=this.control_obj.appendChild(menu);ipsclass.set_unselectable(menu);};this.init_editor_button=function(obj){obj.cmd=obj.id.replace(new RegExp('^'+this.editor_id+'_cmd_(.+?)$'),'$1');obj.editor_id=this.editor_id;this.buttons[obj.cmd]=obj;obj.state=false;obj.mode='normal';obj.real_type='button';obj.onclick=ips_editor_events.prototype.button_onmouse_event;obj.onmousedown=ips_editor_events.prototype.button_onmouse_event;obj.onmouseover=ips_editor_events.prototype.button_onmouse_event;obj.onmouseout=ips_editor_events.prototype.button_onmouse_event;};this.set_menu_context=function(obj,state){if(this._showing_html){return false;}switch(obj.state){case true:{this.editor_set_ctl_style(obj,'menubutton','down');break;}default:{switch(state){case 'mouseout':{this.editor_set_ctl_style(obj,'menubutton','normal');break;}case 'mousedown':{this.editor_set_ctl_style(obj,'menubutton','down');break;}case 'mouseup':case 'mouseover':{this.editor_set_ctl_style(obj,'menubutton','hover');break;}}}}};this.set_button_context=function(obj,state,type){if(this._showing_html){return false;}if(typeof type=='undefined'){type='button';}if(state=='mousedown'&&(obj.cmd=='undo'||obj.cmd=='redo')){return false;}switch(obj.state){case true:{switch(state){case 'mouseout':{this.editor_set_ctl_style(obj,'button','selected');break;}case 'mouseover':case 'mousedown':case 'mouseup':{this.editor_set_ctl_style(obj,type,'down');break;}}break;}default:{switch(state){case 'mouseout':{this.editor_set_ctl_style(obj,type,'normal');break;}case 'mousedown':{this.editor_set_ctl_style(obj,type,'down');break;}case 'mouseover':case 'mouseup':{this.editor_set_ctl_style(obj,type,'hover');break;}}break;}}};this.editor_set_ctl_style=function(obj,type,mode){if(obj.mode!=mode){var extra='';if(type=='menu'){extra='-menu';}else if(type=='menubutton'){extra='-menubutton';}extra+=obj.colorname?'-color':'';extra+=obj.emo_id?'-emo':'';obj.mode=mode;try{switch(mode){case "normal":{obj.className='rte-normal'+extra;}break;case "hover":{obj.className='rte-hover'+extra;}break;case "selected":case "down":{obj.className='rte-selected'+extra;}break;}}catch(e){}}};this.format_text=function(e,command,arg){e=ipsclass.cancel_bubble(e,true);if(command.match( /resize_/)){this.resize_editorbox(command.replace( /resize_(up|down)/,"$1"));}if(command.match( /switcheditor/i)){switch_editor_mode(this.editor_id);}if(!this.is_rte){if(command!='redo'){this.history_record_state(this.editor_get_contents());}}this.editor_check_focus();if(this[command]){var return_val=this[command](e);}else{try{var return_val=this.apply_formatting(command,false,(typeof arg=='undefined'?true:arg));}catch(e){var return_val=false;}}if(!this.is_rte){if(command!='undo'){this.history_record_state(this.editor_get_contents());}}this.set_context(command);this.editor_check_focus();return return_val;};this.spellcheck=function(){if(this.is_moz||this.is_opera){return false;}try{if(this.rte_mode){var tmpis=new ActiveXObject("ieSpell.ieSpellExtension").CheckDocumentNode(this.editor_document);}else{var tmpis=new ActiveXObject("ieSpell.ieSpellExtension").CheckAllLinkedDocuments(this.editor_document);}}catch(exception){if(exception.number==-2146827859){if(confirm(ips_language_array['js_rte_erroriespell']?ips_language_array['js_rte_erroriespell']:"ieSpell not detected. Click Ok to go to download page.")){window.open("http://www.iespell.com/download.php","DownLoad");}}else{alert(ips_language_array['js_rte_errorliespell']?ips_language_array['js_rte_errorliespell']:"Error Loading ieSpell: Exception "+exception.number);}}};this.module_remove_item=function(key){var tmp=this.ips_special_items;this.ips_special_items=new Array();for(var i in tmp){if(i!='cmd_loader_'+key){this.ips_special_items[i]=tmp[i];}}};this.module_add_item=function(key,text,image,evalcode){this.ips_special_items['cmd_loader_'+key]=new Array(text,image,evalcode);};this.module_load=function(obj,e,loader_key){if(!loader_key){return false;}e=ipsclass.cancel_bubble(e,true);this.editor_check_focus();this.preserve_ie_range();menu_action_close();var _m=loader_key.match( /\{(.+?)\}$/);var _args='';try{if(_m[1]){_args=_m[1];}}catch(internetexplorer){}if(typeof this.ips_special_items['cmd_loader_'+loader_key][2]!="undefined"){eval(this.ips_special_items['cmd_loader_'+loader_key][2]);return false}else{this.module_show_control_bar(loader_key,_args);}};this.module_show_control_bar=function(type,_args){if(!this.control_obj){return;}type=type.replace( /(\{.+?\})$/,'');_args=(typeof(_args)!='undefined')?_args:'';if(this.current_bar_object){this.module_remove_control_bar();}var newdiv=document.createElement('div');newdiv.id=this.editor_id+'_htmlblock_'+type+'_menu';newdiv.style.display='';newdiv.className='rte-buttonbar';newdiv.style.zIndex=parseInt(this.control_obj.style.zIndex)+1;newdiv.style.position='absolute';newdiv.style.width='320px';newdiv.style.height='400px';newdiv.style.top=ipsclass.get_obj_toppos(this.mainbar)+'px';var _left=ipsclass.get_obj_leftpos(this.mainbar)-(parseInt(newdiv.style.width)+10);if(_left<1){_left=ipsclass.get_obj_leftpos(this.mainbar);}newdiv.style.left=ipsclass.get_obj_leftpos(this.mainbar)-(parseInt(newdiv.style.width)+10)+'px';newdiv.style.left=_left+'px';var tmpheight=parseInt(newdiv.style.height)-16;newdiv.innerHTML=this.module_wrap_html_panel("");this.mainbar.appendChild(newdiv);if(is_ie){document.getElementById(this.editor_id+'_iframeblock_'+type+'_menu').style.backgroundColor='transparent';document.getElementById(this.editor_id+'_iframeblock_'+type+'_menu').allowTransparency=true;}ipsclass.set_unselectable(newdiv);Drag.init(document.getElementById(this.editor_id+'_pallete-handle'),newdiv);this.current_bar_object=newdiv;};this.module_remove_control_bar=function(){if(!this.current_bar_object){return;}this.mainbar.removeChild(this.current_bar_object);this.current_bar_object=null;};this.module_wrap_html_panel=function(html){var newhtml="";newhtml+="
";newhtml+="
";newhtml+="
";newhtml+="
";newhtml+="
";newhtml+="
"+html+"
";newhtml+="
";newhtml+="
";return newhtml;};this.resize_editorbox=function(direction){var inc_value=100;var current_height=parseInt(this.editor_box.style.height);var new_height=0;current_height=current_height?current_height:300;if(current_height>=50){if(direction=='up'){new_height=current_height-inc_value;}else{new_height=current_height+inc_value;}if(new_height>249){this.editor_box.style.height=new_height+'px';ipsclass.my_setcookie('ips_rte_height',new_height,1);}}};this.htmlspecialchars=function(html){html=html.replace(/&/g,"&");html=html.replace(/"/g,""");html=html.replace(//g,">");return html;};this.unhtmlspecialchars=function(html){html=html.replace( /"/g,'"');html=html.replace( /</g,'<');html=html.replace( />/g,'>');html=html.replace( /&/g,'&');return html;};this.strip_html=function(html){html=html.replace( /<\/?([^>]+?)>/ig,"");return html;};this.strip_empty_html=function(html){html=html.replace('<([^>]+?)>]+?)>',"");return html;};this.clean_html=function(t){if(t==""||typeof t=='undefined'){return t;}t=t.replace( /
/ig,"
");t=t.replace( /

(\s+?)?<\/p>/ig,"");t=t.replace( /


<\/p>/ig,"
");t=t.replace( /

 <\/p>


 <\/p>/ig,"


");t=t.replace( /<(p|div)([^&]*)>/ig,"\n<$1$2>\n");t=t.replace( /<\/(p|div)([^&]*)>/ig,"\n\n");t=t.replace( /
(?!<\/td)/ig,"
\n");t=t.replace( /<\/(td|tr|tbody|table)>/ig,"\n");t=t.replace( /<(tr|tbody|table(.+?)?)>/ig,"<$1>\n");t=t.replace( /<(td(.+?)?)>/ig,"\t<$1>");t=t.replace( /

 <\/p>/ig,"
");t=t.replace( /
/ig,"
\n");t=t.replace( /
/ig,"
\n");t=t.replace( /
\n<\/td>/ig,"
");t=t.replace( /