
/* NEW JS */
var quoteEditor = false;
var qrEditor = false;
function quoteForm(idItem,user){
	if (quoteEditor){
		closeQuoteForm(quoteEditor.idItem);
	}
	var div = $c('div');
	div.id = 'quoteDiv'+idItem;
	div.className = "mtop";
	div.innerHTML = '<div class="lh20 pleft5 cwhite tbgblack fbold">Comentar</div>';
	var txt = $c('textarea');
	txt.className = "bdarkgray txtreply";
	txt.id = 'quote'+idItem;
	div.appendChild(txt);
	var div2 = $c('div');
	div2.className = "tright mtop";
	div.appendChild(div2);
	$('item'+idItem).appendChild(div);
	quoteEditor = loadEditor('quote'+idItem);
	quoteEditor.idItem = idItem;
	hide('citar'+idItem,'responder'+idItem);
	show('enviar'+idItem,'cancelar'+idItem);
	$('btns'+idItem).classNameOld = $('btns'+idItem).className;
	$('btns'+idItem).className = 'p3 bggray5 reply';
}
function loadEditor(idTextarea){
	editor = new textEditor({
			textArea_id		: idTextarea,
			buttons			: 'minimum'
		}
	);
	editor.start();
	return editor;
}
function sendQuote(idReply,user,quickResponse){
	message = quickResponse?qrEditor.getHTML():quoteEditor.getHTML();
	if (!trim(message)){
		alert('Por favor escriba un mensaje');
		return;
	}
	disable('enviar'+idReply,'qrSend');
	previousCmnt = $('body'+idReply).innerHTML;
	if (!quickResponse){
		messageTmp = message;
		message = '[citar='+user+']'+previousCmnt+'[/citar]';
		message += '<br/>'+messageTmp;
	}
	params = {'tema':TOPIC_ID,'mensaje':message,'foro':FORUM_ID};
	$('actionMessage').innerHTML = 'Agregando respuesta...';
	ajaxRequest(FORUM,'add_reply',params,displayReplyResult);
}
function displayReplyResult(obj){
	if (obj.status){
		window.location.href = obj.link;
		return;
	}
	alert(obj.message);
	enable('enviar'+idReply,'qrSend');
}
function closeQuoteForm(idReply){
	show('citar'+idReply,'responder'+idReply);
	hide('enviar'+idReply,'cancelar'+idReply);
	try {
		quoteEditor._destruct();
		delete quoteEditor;
		quoteEditor = false;
	}catch(e){}
	removeEl($('quoteDiv'+idReply));
	$('btns'+idReply).className = $('btns'+idReply).classNameOld;
}
function quickResponse(idReply,user){
	if (typeof $('qrSend').idReply != 'undefined')
		closeQuickResponse($('qrSend').idReply);
	$('qrSend').idReply = idReply;
	$('qrSend').user = user;
	$('qrSend').onclick = function(){sendQuote(this.idReply,this.user,true)};
	$('qr'+idReply).appendChild($('quickResponse'));
	show('quickResponse');
	$('btns'+idReply).classNameOld = $('btns'+idReply).className;
	$('btns'+idReply).className = 'bgwhite reply';
	hide('citar'+idReply,'responder'+idReply);
	qrEditor = loadEditor('qrTxt');
}
function closeQuickResponse(idReply){
	try{
		qrEditor._destruct();
		delete qrEditor;
		qrEditor = false;
	}catch(e){}
	idReply = $('qrSend').idReply;
	$('qrSend').idReply = false;
	show('citar'+idReply,'responder'+idReply);
	hide('quickResponse');
}
windowOnloadAdd(function(){
	var reply = getCookie('reply');
	if (reply){
		window.location.hash = 'reply'+reply+'row';
	}
	clearCookie('reply');
});
function deleteReply(idReply){
	if(confirm('Estas seguro que quieres eliminar la respuesta?')){
		params = {'tema_id':TOPIC_ID,'reply_id':idReply,'foro':FORUM_ID};
		ajaxRequest(FORUM,'delete_reply',params,deleteReplyRes);
	}
	else{
		$('actionMessage').innerHTML = '';
		return false;
	}
}
function deleteReplyRes(obj){
	if (obj.status){
		if ($('reply'+obj.id+'row')){
			removeEl($('reply'+obj.id+'row'));
			removeEl($('reply'+obj.id+'row1'));
			removeEl($('reply'+obj.id+'row2'));
			removeEl($('reply'+obj.id+'row3'));
		}
		if ($('reply'+obj.id+'row4'))
			removeEl($('reply'+obj.id+'row4'));
		if ($('c'+obj.id))
			removeEl($('c'+obj.id));
				
		return;
	}
	alert(obj.message);	
}
function getInfo(foumId,action){
	if(checkForm(action)){
		var nombre_foro = getValue('nombre_foro_'+action);
		var descripcion_foro = getValue('descripcion_foro_'+action);
		var permisos = getValue('permisos_'+action);
		var categorias;
		var access= new Array();
		var size=0;
		var platforms = $('platforms_hidden').value;
		
		if($('users_size')){
			size=getValue('users_size');
			access_string= '';
			user_string='';
			for(i=1;i<=size;i++){
				userId = getValue('user_'+i+'_id');
				level = getValue('acceso_'+i+'_id');
				access_string += 'acceso_usuario_'+i+'_select' + '@' + level + ',';
				user_string += 'user_id_'+i+'_hidden'+ '@' + userId+',';
			}
		}else{
			access_string = '';
			user_string = '';
		}
				
		if (getValue('categorias_'+action)!='-1'){
			categorias = getValue('categorias_'+action);
			category_name = '';
		}else{
			categorias = -1;
			category_name = getValue('new_category_'+action);
		}
		
		if(action=='save_forum_changes'){
			params = {'nombre_foro':nombre_foro,'descripcion_foro':descripcion_foro,'permisos':permisos,'categoria_id':categorias,'category':category_name, 'platforms':platforms,'foro':FORUM_ID,'arreglo_accesos':access_string,'arreglo_usuarios':user_string};
		}else{
			params = {'nombre_foro':nombre_foro,'descripcion_foro':descripcion_foro,'permisos':permisos,'categoria_id':categorias,'category':category_name, 'platforms':platforms};
		}
		
		if ($('idParent')){
			 params.idParent = $('idParent').value;
		}
		
		action_aux = action;
		$('message_'+action).innerHTML = 'Actualizando datos. Por favor espere...';
		
		ajaxRequest(FORUM,action,params,displayActionMessage);
	}
}
function checkForm(action){
	if (getValue('nombre_foro_'+action)==''){
		alert('Escriba un nombre valido');
		return false;
	}
	/*if (getValue('descripcion_foro_'+action)==''){
		alert('Escriba una descripcion valido');
		return false;
	}*/
	if (getValue('permisos_'+action)=='-1'){
		alert('Debe asignar permisos');
		return false;
	}
	if (getValue('categorias_'+action)=='-1'){
		if($('new_category_'+action)){
			if (getValue('new_category_'+action)== ''&&$('idParent').value==''){
				alert('Debe seleccionar una categoria');
				return false;
			}
		}
	}
	return true;
}
function displayActionMessage(obj){
	if(obj.status==true){
		window.location.href = obj.link;
	}else{
		$('message').innerHTML = obj.message;
	}
}
function reportTopic(idTopic,hash){
	if (confirm('¿Realmente desea reportar este tema?')){
		$('rt'+idTopic).onclick = function(){};
		$('rt'+idTopic).innerHTML = 'Enviando...';
		ajaxRequest(FORUM,'reportTopic',{'id':idTopic,'hash':hash},doneReportTopic);
	}
}
function doneReportTopic(obj){
	if (obj.status){
		$('rt'+obj.id).onclick = function(){};
		$('rt'+obj.id).innerHTML = 'Reportado';
		return;
	}
	$('rt'+obj.id).onclick = function(){
		reportTopic(obj.id,obj.hash);
	};
	$('rt'+obj.id).innerHTML = 'Reportar';
	alert(obj.message);
}
function reportReply(idReply,hash){
	if (confirm('¿Realmente desea reportar este comentario?')){
		$('rr'+idReply).onclick = function(){};
		$('rr'+idReply).innerHTML = 'Enviando...';
		ajaxRequest(FORUM,'reportReply',{'id':idReply,'hash':hash},doneReportReply);
	}
}
function doneReportReply(obj){
	if (obj.status){
		$('rr'+obj.id).onclick = function(){};
		$('rr'+obj.id).innerHTML = 'Reportado';
		return;
	}
	$('rr'+obj.id).onclick = function(){
		reportTopic(obj.id,obj.hash);
	};
	$('rr'+obj.id).innerHTML = 'Reportar';
	alert(obj.message);
}
function ignoreReply(idReply){
	if (confirm('¿Realmente desea quitar este comentario de la lista?')){
		ajaxRequest(FORUM,'ignoreReply',{'id':idReply},doneIgnoreItem);
	}
}
function ignoreTopic(idTopic){
	if (confirm('¿Realmente desea quitar este tema de la lista?')){
		ajaxRequest(FORUM,'ignoreTopic',{'id':idTopic},doneIgnoreItem);
	}
}
function doneIgnoreItem(obj){
	if (obj.status){
		removeNode('c'+obj.id);
		return;
	}
	alert(obj.message);
}
function newCategory(conFlag){
	if (conFlag&&($('idCat').value!=''||$('catName').value!='')){
		if (!confirm('¿Desea descartar los cambios?')){
			return false;
		}
	}
	$('catName').value = '';
	$('idCat').value = '';
	$('formTitle').innerHTML = 'Agregar nueva categoría';
	$('saveCatBtn').onclick = addCategory;
}
function deleteCategory(){
	var opt = getSelectedItem('categories');
	if (!opt){
		alert('Por favor, seleccione la categoría a eliminar');
		return;
	}
	if (!confirm('¿Realmente desea eliminar la categoría "'+opt.text+'"?')){
		return false;
	}
	$('messageCategory').innerHTML = 'Eliminando categoría "'+opt.text+'"...';
	disable('delCatBtn');
	ajaxRequest(FORUM,'deleteCategory',{id:opt.value},doneDeleteCategory);
}
function doneDeleteCategory(obj){
	if (obj.status){
		removeNode('c'+obj.id);
		if (obj.id==$('idCat').value)
			newCategory();
	}else{
		alert(obj.status);
	}
	$('messageCategory').innerHTML = '';
	enable('delCatBtn');
}
function addCategory(){
	disable('saveCatBtn');
	disable('newCatBtn');
	disable('cancelCatBtn');
	ajaxRequest(FORUM,'addCategory',{name:$('catName').value},doneAddCategory);
}
function doneAddCategory(obj){
	if (obj.status){
		op = $c('option');
		op.value = obj.id;
		op.selected = true;
		op.innerHTML = obj.name;
		$('categories').insertBefore(op,$('categories').firstChild);
		newCategory();
	}else{
		alert(obj.message);
	}
	enable('saveCatBtn');
	enable('newCatBtn');
	enable('cancelCatBtn');
}
function updateCategory(){
	disable('saveCatBtn');
	disable('newCatBtn');
	disable('cancelCatBtn');
	ajaxRequest(FORUM,'updateCategory',{id:$('idCat').value,name:$('catName').value},doneUpdateCategory);
}
function doneUpdateCategory(obj){
	if (obj.status){
		op = $('c'+obj.id);
		op.selected = true;
		op.innerHTML = obj.name;
		newCategory();
	}else{
		alert(obj.message);
	}
	enable('saveCatBtn');
	enable('newCatBtn');
	enable('cancelCatBtn');
}
function editCategory(){
	var opt = getSelectedItem('categories');
	$('catName').value = opt.text;
	$('idCat').value = opt.value;
	$('formTitle').innerHTML = 'Editar: '+opt.text+' (ID: '+opt.value+')';
	$('saveCatBtn').onclick = updateCategory;
}
function addUser(id,name){
	var table = $('moderadores');
	var row = table.insertRow(table.rows.length);
	var cell = row.insertCell(0);
	cell.className = 'p5 bdarkgray';
	cell.innerHTML = name;
	var cell = row.insertCell(1);
	cell.className = 'p5 bdarkgray';
	
	var table_permission = $c('table');
	table_permission.className="list_permissions";
	table_permission.id="forum_permissions_"+id;
	var table_permission_tbody = $c('tbody');
	
	var table_permission_first = $c('tr');
	var table_permission_hedit_for = $c('td');
	table_permission_hedit_for.width="25%";
	table_permission_hedit_for.className = 'header_access_level';
	table_permission_hedit_for.innerHTML = 'Editar Foro';
	var table_permission_hadd_top = $c('td');
	table_permission_hadd_top.width="25%";
	table_permission_hadd_top.className = 'header_access_level';
	table_permission_hadd_top.innerHTML = 'Crear Tema';
	var table_permission_hupd_top = $c('td');
	table_permission_hupd_top.width="25%";
	table_permission_hupd_top.className = 'header_access_level';
	table_permission_hupd_top.innerHTML = 'Editar Tema';
	var table_permission_hdel_top = $c('td');
	table_permission_hdel_top.width="25%";
	table_permission_hdel_top.className = 'header_access_level';
	table_permission_hdel_top.innerHTML = 'Eliminar Tema';

	var table_permission_second = $c('tr');
	table_permission_second.name="accesos["+id+"]";
	var table_permission_edit_for = $c('td');
	table_permission_edit_for.className = 'header_level';
	var input1 = $c('input');
	input1.id="forum_update_checkbox_"+id;
	input1.name="forum_update_"+id;
	input1.type="checkbox";
	$a(table_permission_edit_for,input1);
	var table_permission_add_top = $c('td');
	table_permission_add_top.className = 'header_level';
	var input2 = $c('input');
	input2.id="topic_add_checkbox_"+id;
	input2.name="topic_add_"+id;
	input2.type="checkbox";
	$a(table_permission_add_top,input2);	
	var table_permission_upd_top = $c('td');
	table_permission_upd_top.className = 'header_level';
	var input3 = $c('input');
	input3.id="topic_update_checkbox_"+id;
	input3.name="topic_update_"+id;
	input3.type="checkbox";
	$a(table_permission_upd_top,input3);	
	var table_permission_del_top = $c('td');
	table_permission_del_top.className = 'header_level';
	var input4 = $c('input');
	input4.id="topic_delete_checkbox_"+id;
	input4.name="topic_delete_"+id;
	input4.type="checkbox";
	$a(table_permission_del_top,input4);		
	
	$a(table_permission_first,table_permission_hedit_for);
	$a(table_permission_first,table_permission_hadd_top);
	$a(table_permission_first,table_permission_hupd_top);
	$a(table_permission_first,table_permission_hdel_top);
	$a(table_permission_second,table_permission_edit_for);
	$a(table_permission_second,table_permission_add_top);
	$a(table_permission_second,table_permission_upd_top);
	$a(table_permission_second,table_permission_del_top);	
	$a(table_permission_tbody,table_permission_first);
	$a(table_permission_tbody,table_permission_second);
	$a(table_permission,table_permission_tbody);
	
	$a(cell,table_permission);
	
	/*var sel = $c('select');
	sel.className = 'bdarkgray p3';
	sel.name = 'accesos['+id+']';
	for (n in userAccess){
		opt = $c('option');
		opt.text = n;
		opt.value = userAccess[n];
		try{
			sel.add(opt, null);
		}catch(ex){
			sel.add(opt);
		}
	}
	$a(cell,sel);
	sel.value = 0;*/

	addModeratorToArray(id);
	$('messageUser').innerHTML = '';
}

function addModeratorToArray(user_id){
	if($('idsModerators').value=='')
		$('idsModerators').value=user_id;
	else
		$('idsModerators').value+=','+user_id;
}
function saveTopic(action){
	var idForum = $('idForum').value;
	var idTopic = $('idTopic').value;
	var tema = $('topicTitle').value;
	var msg = $('topicBody').value;
	var cerrado = $('cerrado').value;
	
	if (action=='addTopic'){
		params = {'tema':tema,'mensaje':msg,'foro':idForum};
	}else{
		params = {'tema':tema,'mensaje':msg,'foro':idForum,'tema_id':idTopic,'cierra_topic':cerrado};
	}
	ajaxRequest(FORUM,action,params,displayActionMessage_forum_new_topic);
}

/*********/
























/************************************************************************************/




/*** forum_new_topic.js BEGIN***/
function checkForm_forum_new_topic(action)
{
	if (trim(getValue('tema_'+action))=='')
	{
		alert('Escriba un nombre valido');
		return false;
	}
	return true;
}
	
function validateForm(action)
{
	if ((getValue('tema_'+action)=='')||(getValue('mensaje_'+action)==''))
	{
	
	}
	else{
		$(action+'_btn').disabled = '';
	}
}

function getInfo_forum_new_topic(topicId,action)
{	
	if(checkForm_forum_new_topic(action))
	{
		var tema = getValue('tema_'+action);
		if (editor)
			var msg = editor.getHTML();
		else
			var msg = $('topic_body').value;
		
		if(trim(msg)==''){
			alert('Escriba un mensaje');
			return false;
		}
		var notify = 0;
		if(action=='save_topic'||action=='save_topic_changes')
		{
			var id_foro = getValue('foro_'+action);
			
			if($('close_topic'))
			{
				var cerrado = $('close_topic').checked?1:0;
			}
			else
			{
				var cerrado = 0;
			}
			params = {'tema':tema,'mensaje':msg,'foro':id_foro,'tema_id':TOPIC_ID,'cierra_topic':cerrado,'notificar':notify};
		}
		else
		{
			var id_foro = getValue('hdn_idForo_'+action);
			params = {'tema':tema,'mensaje':msg,'foro':id_foro,'notificar':notify};
		}
		action_aux = action;
		if ($('message_'+action))
			$('message_'+action).innerHTML = 'Actualizando datos. Por favor espere...';
		ajaxRequest(FORUM,action,params,displayActionMessage_forum_new_topic);
	}
}

function displayMessage(html)
{
	$('editorDiv').innerHTML = html;
}

function displayActionMessage_forum_new_topic(obj){
	if(obj.status){
		window.location.href = obj.redirect;
		return;
	}
	alert(obj.message);
}
var action_aux;
var editor;
function onLoad_forum_new_topic()
{
	editor = new textEditor
	(
		{
			textArea_id		: 'topic_body',
			buttons			: 'normal'
		}
	);
	editor.start();
} 
/*** forum_new_topic.js END ***/
/*** forum_new_reply.js BEGIN ***/
var editor;
function onLoad_forum_new_replay()
{
	editor = new textEditor
	(
		{
			textArea_id		: 'new_reply',
			buttons			: 'normal'
		}
	);
	editor.start();
}
function sendMessage(){

	reply = editor.getHTML();
	if(trim(reply)==''){
		alert('Escriba un mensaje');
		return false;
	}
	if(REPLAY_ACTION == 'add_reply')
	{
		$('message').innerHTML = 'Agregando respuesta...';
		params = {'tema':TOPIC_ID,'mensaje':reply,'foro':FORUM_ID};
		ajaxRequest(FORUM,REPLAY_ACTION,params,displayReplyResult_forum_new_reply);
	}
	else
	{
		$('message').innerHTML = 'Guardando respuesta...';
		params = {'tema':TOPIC_ID,'mensaje':reply,'foro':FORUM_ID,'reply_id':replyId,'pagina_replys':page};
		ajaxRequest(FORUM,REPLAY_ACTION,params,displayReplyResult_forum_new_reply);
	}
}

function displayReplyResult_forum_new_reply(html){
	if(html['status']){
		editor.clear();
		window.location.href = html['link'];
	}
	$('message').innerHTML = html['message'];
}
//--add
var editor;
function onLoad_forum_new_reply_ADD()
{
	editor = new textEditor
	(
		{
			textArea_id		: 'new_reply',
			buttons			: 'normal'
		}
	);
	editor.start();
}
/*** forum_new_reply.js END ***/
/*** forum_new_forum BEGIN ***/
var action_aux;
var winRelated;
var winPlatforms;

function showForumFilters(divFilter){
	form = $('filters_form');
	destination = $(divFilter);
	destination.appendChild(form);
	openNode(divFilter);
}

function doneNewFilter(filter,action){
	closeNode('FilterDiv'+action_aux);
	openNode('new_filter'+action_aux);
}

function searchUser(){
	nickname = getValue('user_txt');
	$('messageUser').innerHTML = "Buscando usuario...";
	params = {'nickname':nickname,'foro':FORUM_ID};
	
	ajaxRequest(FORUM,'search_user',params,displayUserMessage);
}

function displayUserMessage(html){
	$('messageUser').innerHTML =html;
}

function saveUserPreferences(userId){
	acceso = getValue('acceso');
	if(acceso == -1){
		alert('Debe asignar un acceso al moderador');
		return false;
	}
	params = {'user_id':userId,'acceso_usuario':acceso,'foro':FORUM_ID};
	$('messageUser').innerHTML = "Guardando permisos de usuario...";
	ajaxRequest(FORUM,'save_user_access',params,displayUserMessage);
}

/*** forum_new_forum END ***/
/*** forum_forum_list BEGIN ***/
var actionMsg;
var deleteAction = false;
function deleteForum(forumId){
	if(confirm('Esta seguro que desea eliminar el foro?')){
		$('actionMessage').innerHTML = "Eliminando foro...";
		ajaxRequest(FORUM,'delete_forum',forumId,displayDeleteForum);
	}
}

function displayDeleteForum(html){
	$('actionMessage').innerHTML = html['message'];
	if(html['status']==true){
		window.location.href = html['link'];
	}
}
/*** forum_forum_list  END ***/
/*** forum_categories BEGIN ***/
function moveUpDown(idSelect,direction)
{
	var source = $(idSelect);
	
	if(source.selectedIndex!=-1){
		if(direction==1){
			index = source.selectedIndex-1;
			if(index==-1){
				return false;
			}
		}
		else{
			index = source.selectedIndex+1;
			if(index>=source.length){
				return false;
			}
		}
		
		var optMove = new Object();
		optMove.text = source.options[source.selectedIndex].text;
		optMove.value = source.options[source.selectedIndex].value;
		optMove.selected = source.options[source.selectedIndex].selected;
		
		var optDest = new Object();
		optDest.text = source.options[index].text;
		optDest.value = source.options[index].value;
		optDest.selected = source.options[index].selected;
		
		for (var property in optDest){
			source.options[source.selectedIndex][property] = optDest[property];
		}
		for (var property in optMove){
			source.options[index][property] = optMove[property]; 
		}
	}
}

function selecOrder(selectId)
{
	var source = $(selectId);
	var newOrder = new Array();
	for(i=0;i<source.length;i++){
		newOrder[i+1] = source.options[i].value;
	}
	params = newOrder;
	
	$('messageCategory').innerHTML = "Guardando...";
	
	ajaxRequest(FORUM,'save_categories_changes',params,displayCategoryMessage);
}

function displayCategoryMessage(html)
{
	$('messageCategory').innerHTML = html['message'];
	if(html['status']==true){
		window.location.href = html['link'];
	}
}
/*** forum_categories END ***/
/*** forum_template BEGIN ***/
	var actionMsg;
	var isQouteTmp = false;
	tempReply = 0;
	userTmp = 0;
	var editor;		
	var msgVentana; 
	
function onLoad_forum_template()
{
	msgVentana = Window
	(
		'windowprofile',
		{	is_textarea: 	false,
			width:			460,
			height:			100,
			min_width:		160,
			closable:		true,
			draggable:		true,
			disable_screen:	false,
			resizable:		false,
			toogle:			true,
			container:		'message_form_container',
			title: 			'Enviar mensaje',
			append:			$('forma_mensajes')
		}	
	);
	msgVentana.hideWindow();
}
/*** forum_template END ***/
/*** forum_topic_list BEGIN ***/
	var actionMsg;
	var deleteAction = false;
	
function deleteTopic_topic_list(topicId,forumId){
	if(confirm('Esta seguro que desea eliminar el tema?')){
		$('actionMessage').innerHTML = "Eliminando tema...";
		params[WEB_FORUM_ID] = FORUM_ID;
		params[WEB_TOPIC_ID] = TOPIC_ID;
		//params = {'{WEB_FORUM_ID}':forumId,'{WEB_TOPIC_ID}':topicId};
		ajaxRequest(FORUM,'delete_topic',params,displayDeleteTopic_forum_topic_list);
	}
}
function displayDeleteTopic_forum_topic_list(html)
{
	if(html['status']){
		$('actionMessage').innerHTML = html['message'];
		window.location.href = html['link'];
	}
	else{
		$('actionMessage').innerHTML = html['message'];
	}
}
/*** forum_topic_list END ***/
/*** forum_replys BEGIN***/
function showMessageForm(userId){
		userTmp = userId;
		msgVentana.showWindow();
}

function sendMsg(commentId,tdId,user){
	message = editor.getHTML();
	if (!trim(message)){
		alert('Por favor escriba un mensaje');
		return;
	}
	if(isQuoteTmp==true){
		previousCmnt = $(tdId).innerHTML;
		messageTmp = message;
		message = '[citar='+user+']'+previousCmnt+'[/citar]';
		message += '<br />'+messageTmp;
		}
	params = {'tema':TOPIC_ID,'mensaje':message,'foro':FORUM_ID};
	$('actionMessage').innerHTML = 'Agregando respuesta...';
	ajaxRequest(FORUM,'add_reply',params,displayReplyResult);
}

function lockTopic(){
	if(confirm('Estas seguro que deseas cerrar este tema?')){
		$('actionMessage').innerHTML = 'Cerrando tema...';
		params = {'tema_id':TOPIC_ID,'foro':FORUM_ID};
		ajaxRequest(FORUM,'lock_topic',params,displayReplyDelete);
	}
	else{
		$('actionMessage').innerHTML = '';
		return false;
	}
}

function deleteSignature(memberId,type){
	if(confirm('Estas seguro que quieres eliminar la firma?')){
		$('actionMessage').innerHTML = 'Eliminando firma...';
		params = {'member_id':memberId,'type':type,'tema_id':TOPIC_ID,'foro':FORUM_ID};
		ajaxRequest(MEMBERS,'remove_signature',params,displayReplyDelete);
	}
}

function displayReplyDelete(html){
	if(html['status']){
		window.location.href = html['link'];
	}
	else{
		$('actionMessage').innerHTML = html['message'];
	}
}

function refreshComments(html){
	$('commentsList').innerHTML = html;
	$('actionMessage').innerHTML = actionMsg;
}


function closeNewCommentForm(){
	openNode('new_comment_btn');
	closeNode('new_comment_form');
}


/*** forum_relys END ***/
/*** forum_topics BEGIN ***/
function deleteTopic(topicId){
	if(confirm('Esta seguro que desea eliminar el tema?'))
	{
		params = {'tema_id':topicId};
		ajaxRequest(FORUM,'delete_topic',params,displayDeleteTopic);
	}
}
		
function displayDeleteTopic(obj){
	if(obj.status){
		if ($('topic'+obj.topic))
			removeNode('topic'+obj.topic);
		else if ($('c'+obj.topic))
			removeNode('c'+obj.topic);
		return;
	}
	alert(obj.message);
}
/*** forum_topics END ***/

