(function(){function reply(a,b,c){var d=MGJS.$(a).innerHTML;var e='<a href="#'+b+'">@'+d.replace(/\t|\n|\r\n/g,"")+' </a> \n';appendReply(e,c)}function quote(a,b,c,d){var e=MGJS.$(a).innerHTML;var f=MGJS.$(c).innerHTML;var g='<blockquote cite="#'+c+'">';g+='\n<strong><a href="#'+b+'">'+e.replace(/\t|\n|\r\n/g,"")+'</a> :</strong>';g+=f.replace(/\t/g,"");g+='</blockquote>\n';insertQuote(g,d)}function appendReply(a,b){if(MGJS.$(b)&&MGJS.$(b).type=='textarea'){field=MGJS.$(b)}else{alert("The comment box does not exist!");return false}if(field.value.indexOf(a)>-1){alert("You've already appended this reply!");return false}if(field.value.replace(/\s|\t|\n/g,"")==''){field.value=a}else{field.value=field.value.replace(/[\n]*$/g,"")+'\n\n'+a}field.focus()}function insertQuote(a,b){if(MGJS.$(b)&&MGJS.$(b).type=='textarea'){field=MGJS.$(b)}else{alert("The comment box does not exist!");return false}if(document.selection){field.focus();sel=document.selection.createRange();sel.text=a;field.focus()}else if(field.selectionStart||field.selectionStart=='0'){var c=field.selectionStart;var d=field.selectionEnd;var e=c;field.value=field.value.substring(0,c)+a+field.value.substring(d,field.value.length);e+=a.length;field.focus();field.selectionStart=e;field.selectionEnd=e}else{field.value+=a;field.focus()}}window['MGJS_CMT']={};window['MGJS_CMT']['reply']=reply;window['MGJS_CMT']['quote']=quote})();
