var topic,start,show_modify,quickReplyCollapsed,buff_message;var cur_msg_id,cur_msg_div,buff_subject,cur_subject_div,in_edit_mode=0;function doQuote(b,a){var c="";if(window.getSelection){c=window.getSelection().toString()}else{if(document.getSelection){c=document.getSelection().toString()}else{if(document.selection){c=document.selection.createRange().text}}}while(c.charAt(0)==" "&&c.length>0){c=c.substr(1)}while(c.charAt(c.length-1)==" "&&c.length>0){c=c.substr(0,c.length-1)}if(c.length>10){var e=c.substr(0,5);var d=c.substr(c.length-5)}if(quickReplyCollapsed){if(e!=undefined&&d!=undefined){window.location.href=scripturl+"?action=post;quote="+b+";topic="+topic+"."+start+";word1="+escape(e)+";word2="+escape(d)+";sesc="+a}else{window.location.href=scripturl+"?action=post;quote="+b+";topic="+topic+"."+start+";sesc="+a}}else{if(window.XMLHttpRequest){if(typeof window.ajax_indicator=="function"){ajax_indicator(true)}if(e!=undefined&&d!=undefined){getXMLDocument(scripturl+"?action=quotefast;quote="+b+";word1="+escape(e)+";word2="+escape(d)+";sesc="+a+";xml",onDocReceived)}else{getXMLDocument(scripturl+"?action=quotefast;quote="+b+";sesc="+a+";xml",onDocReceived)}}else{if(e!=undefined&&d!=undefined){reqWin(scripturl+"?action=quotefast;quote="+b+";word1="+escape(e)+";word2="+escape(d)+";sesc="+a,240,90)}else{reqWin(scripturl+"?action=quotefast;quote="+b+";sesc="+a,240,90)}}if(navigator.appName=="Microsoft Internet Explorer"){window.location.hash="quickreply"}else{window.location.hash="#quickreply"}}}function onDocReceived(c){var b="";for(var a=0;a<c.getElementsByTagName("quote")[0].childNodes.length;a++){b+=c.getElementsByTagName("quote")[0].childNodes[a].nodeValue}replaceText(b,document.forms.postmodify.message);if(typeof window.ajax_indicator=="function"){ajax_indicator(false)}}function modify_msg(b,a){if(!window.XMLHttpRequest){return}if(typeof(window.opera)!="undefined"){var c=new XMLHttpRequest();if(typeof(c.setRequestitlebger)!="function"){return}}if(in_edit_mode==1){modify_cancel()}in_edit_mode=1;if(typeof window.ajax_indicator=="function"){ajax_indicator(true)}getXMLDocument(scripturl+"?action=quotefast;quote="+b+";sesc="+a+";modify;xml",onDocReceived_modify)}function onDocReceived_modify(d){var c="";var b="";cur_msg_id=d.getElementsByTagName("message")[0].getAttribute("id");for(var a=0;a<d.getElementsByTagName("message")[0].childNodes.length;a++){c+=d.getElementsByTagName("message")[0].childNodes[a].nodeValue}cur_msg_div=document.getElementById(cur_msg_id);buff_message=getInnerHTML(cur_msg_div);c=c.replace(/\$/g,"{&dollarfix;$}");c=template_body_edit.replace(/%body%/,c).replace(/%msg_id%/g,cur_msg_id.substr(4));c=c.replace(/\{&dollarfix;\$\}/g,"$");setInnerHTML(cur_msg_div,c);cur_subject_div=document.getElementById("subject_"+cur_msg_id.substr(4));buff_subject=getInnerHTML(cur_subject_div);b=d.getElementsByTagName("subject")[0].childNodes[0].nodeValue;b=b.replace(/\$/g,"{&dollarfix;$}");b=template_subject_edit.replace(/%subject%/,b);b=b.replace(/\{&dollarfix;\$\}/g,"$");setInnerHTML(cur_subject_div,b);if(typeof window.ajax_indicator=="function"){ajax_indicator(false)}}function modify_cancel(){setInnerHTML(cur_msg_div,buff_message);setInnerHTML(cur_subject_div,buff_subject);in_edit_mode=0;return false}function modify_save(b){if(!in_edit_mode){return true}var c,a=new Array();a[a.length]="subject="+escape(textToEntities(document.forms.quickModForm.subject.value.replace(/&#/g,"&#38;#"))).replace(/\+/g,"%2B");a[a.length]="message="+escape(textToEntities(document.forms.quickModForm.message.value.replace(/&#/g,"&#38;#"))).replace(/\+/g,"%2B");a[a.length]="topic="+parseInt(document.forms.quickModForm.elements.topic.value);a[a.length]="msg="+parseInt(document.forms.quickModForm.elements.msg.value);if(typeof window.ajax_indicator=="function"){ajax_indicator(true)}sendXMLDocument(scripturl+"?action=jsmodify;topic="+topic+";sesc="+b+";xml",a.join("&"),modify_done);return false}function modify_done(d){if(!d){modify_cancel();return}var k=d.getElementsByTagName("smf")[0].getElementsByTagName("message")[0];var e=k.getElementsByTagName("body")[0];var g=k.getElementsByTagName("error")[0];if(e){var j="";for(i=0;i<e.childNodes.length;i++){j+=e.childNodes[i].nodeValue}j=j.replace(/\$/g,"{&dollarfix;$}");j=template_body_normal.replace(/%body%/,j);j=j.replace(/\{&dollarfix;\$\}/g,"$");setInnerHTML(cur_msg_div,j);buff_message=j;var f=k.getElementsByTagName("subject")[0];var b=f.childNodes[0].nodeValue;b=b.replace(/\$/g,"{&dollarfix;$}");var h=template_subject_normal.replace(/%msg_id%/g,cur_msg_id.substr(4)).replace(/%subject%/,b);h=h.replace(/\{&dollarfix;\$\}/g,"$");setInnerHTML(cur_subject_div,h);buff_subject=h;if(f.getAttribute("is_first")==1){var c=template_top_subject.replace(/%subject%/,b);c=c.replace(/\{&dollarfix;\$\}/g,"$");setInnerHTML(document.getElementById("top_subject"),c)}if(show_modify){var a=document.getElementById("modified_"+cur_msg_id.substr(4));setInnerHTML(a,k.getElementsByTagName("modified")[0].childNodes[0].nodeValue)}}else{if(g){setInnerHTML(document.getElementById("error_box"),g.childNodes[0].nodeValue);document.forms.quickModForm.message.style.border=g.getAttribute("in_body")=="1"?"1px solid red":"";document.forms.quickModForm.subject.style.border=g.getAttribute("in_subject")=="1"?"1px solid red":""}}if(typeof window.ajax_indicator=="function"){ajax_indicator(false)}}function showModifyButtons(){var a=document.images.length;for(var b=0;b<a;b++){if(document.images[b].id.substr(0,14)=="modify_button_"){document.images[b].style.display=""}}}function expandThumb(a){var b=document.getElementById("thumb_"+a);var d=document.getElementById("link_"+a);var c=b.src;b.src=d.href;d.href=c;b.style.width="";b.style.height="";return false}function swapQuickReply(){document.getElementById("quickReplyExpand").src=images_url+"/"+(quickReplyCollapsed?"collapse.gif":"expand.gif");document.getElementById("quickReplyOptions").style.display=quickReplyCollapsed?"":"none";quickReplyCollapsed=!quickReplyCollapsed};
