var _global 	= new Array();
var comflds		= new Array("req","lang","tbpids");
var listcomflds	= new Array("req","lang","tbpid");
/******************************	CONTROLLERS ******************************/
function viewComments(id) {
	
}
function addComment(id) {
	xGetElementById("action").value = "ADD_COMMENT";
	document.postFRM.action = xGetElementById("rm_" + id).href;
	document.postFRM.submit();
}
/******************************	AJAX ******************************/
function loadCommentInfo() {
	xGetElementById("req").value = 'GET_COMMENT_INFO';
	var loader = new net.ContentLoader(AJAX_PATH + "twinblog.cfm",onLoadCommentInfoResult,onLoadCommentInfoError,"POST",net.CreatePostString(null,comflds));
}
function onLoadCommentInfoResult() {
	response = net.CleanResponse(this.req.responseText);
	if ( response.indexOf('ERROR') == 0 )
		alert('error');
	else if ( response == 'NO_SESSION' )
		toggleInfo(_global['ST_NO_SESSION'],true,false);
	else {
		try {
			eval(response);
			parseCommentInfo(commentinfo);
		}
		catch (e) { };
	}
}
function onLoadCommentInfoError() {
	response = net.CleanResponse(this.req.responseText);
	xGetElementById("error").innerHTML = response;
}
function loadComments() {
	xGetElementById("req").value = 'LIST_COMMENTS';
	var loader = new net.ContentLoader(AJAX_PATH + "twinblog.cfm",onLoadCommentsResult,onLoadCommentsError,"POST",net.CreatePostString(null,listcomflds));
}
function onLoadCommentsResult() {
	response = net.CleanResponse(this.req.responseText);
	if ( response.indexOf('ERROR') == 0 )
		alert('error');
	else if ( response == 'NO_SESSION' )
		toggleInfo(_global['ST_NO_SESSION'],true,false);
	else
		xGetElementById("comments_block").innerHTML = response;
}
function onLoadCommentsError() {
	response = net.CleanResponse(this.req.responseText);
	xGetElementById("error").innerHTML = response;
}
/******************************	AJAX DATA PARSERS ******************************/
function parseCommentInfo(arr) {
	if ( arr.length > 0 ) {
		for ( i = 0; i < arr.length; i++ ) {
			xGetElementById("comments_" + arr[i].postid).innerHTML = arr[i].html;
		}
	}
}
/************************** MANAGE TWINBLOG **************************/
function manageTwinblog(pid,tbid,fa) {
	xGetElementById("pid_blog").value = pid;
	xGetElementById("tbid_blog").value = tbid;
	xGetElementById("fuseaction").value = fa;
	document.blogFRM.target = "_blank";
	document.blogFRM.submit();
	document.blogFRM.target = "_self";
}
function addTwinblogPost(pid,tbid,fa) {
	xGetElementById("pid_blog").value = pid;
	xGetElementById("tbid_blog").value = tbid;
	xGetElementById("fuseaction").value = fa;
	document.blogFRM.target = "_blank";
	document.blogFRM.submit();
	document.blogFRM.target = "_self";
}