var UserID='';
var userNombre='';
var tout=false;
var foroID=0;
var foroPaginas=0;
var foroPagAct=0;
var foroUltID=0;
var respAct=0;
var txtPage=new Array();
var numPage=new Array();
var comPage=new Array();
var ultPage=new Array();
txtPage[0]='';
numPage[0]=-1;
comPage[0]=true;
ultPage[0]=0;
var act=false;
var act2=false;
var inhibe=false;
var counter=0;
var vistaAct=0;

var catForo=new Array();
var titForo=new Array();
var txtForo=new Array();
var prgForo=new Array();
var cerForo=new Array();

var catCat=new Array();
var nomCat=new Array();

var canProg=new Array();
var nomProg=new Array();
var txtProg=new Array();
var logProg=new Array();

var nomCanal=new Array();
var logCanal=new Array();


function cerrarTodo()
{
	get('ForosMenu').style.display='none';
	get('Contacto').style.display='none';
	get('Foros').style.display='none';
	get('Programa').style.display='none';
	get('Reglas').style.display='none';
}

function agregarGestos(txt)
{
	var a;
	for (a=0;a<Gesto.length;a++)
	{
		txt=txt.replace(Gesto[a], '<img src="/gestos/'+aGesto[a]+'" width="23" height="19" align="absmiddle" border="0">');
	}
	for (a=0;a<Eti.length;a++)
	{
		txt=txt.replace(Eti[a], HTML[a]);
	}
	return txt;
}

function filtrarMalasP(txt)
{
	var txtant;
	do
	{
		txtant=txt;
		for (a=0;a<malasP.length;a++)
		{
			txt=txt.replace(malasP[a], '$1****$2');
		}
	}
	while (txtant!=txt);
	return txt;
}

function adaptar(txt)
{
	var txtant;
	var regul;
	var a;
	var ok;
	do
	{
		txtant=txt;
		regul=/  /g;
		txt=txt.replace(regul, ' ');
		regul=/[\n\r]/g;
		txt=txt.replace(regul, '[/]');
		regul=/\[\/\]\[\/\]/g
		txt=txt.replace(regul, '[/]');
	}
	while (txtant!=txt);
	
	//Cambiar los acentos:
	for (a=0;a<Acentos.length;a++)
	{
		txt=txt.replace(Acentos[a], AcentosCambio[a]);
	}
	
	do
	{
		txtant=txt;
		//Espaciar los signos:
		regul=/([\w\.,;])([¡¿\(\[\{])/gi;
		txt=txt.replace(regul, '$1 $2');
		
		regul=/([!\?\)\]\}\.:;,ºª])([\w\¡¿{\[\(])/gi;
		txt=txt.replace(regul, '$1 $2');
		
		regul=/([¡¿\(\[\{]) ([\w\¡¿{\[\(])/gi;
		txt=txt.replace(regul, '$1$2');
		
		regul=/([\w\]\)\}\?!\.:;,ºª]) ([!\?\)\]\}\.:;,ºª])/gi;
		txt=txt.replace(regul, '$1$2');
		
		regul=/\[: d\]/gi;
		txt=txt.replace(regul, '[:d]');
		
		regul=/\[: o\]/gi;
		txt=txt.replace(regul, '[:o]');
		
		regul=/\[: p\]/gi;
		txt=txt.replace(regul, '[:p]');
		
		regul=/\[: s\]/gi;
		txt=txt.replace(regul, '[:s]');
		
		regul=/\[: \(\]/gi;
		txt=txt.replace(regul, '[:(]');

	}
	while (txtant!=txt);
	
	//Limitación de cantidad de caracteres:
	var reg1=/[0-9]{1}/; //máximo 10
	var reg2=/[A-Z\W]{1}/i; //máximo 3
	var reg3=/[,;:]{1}/; //máximo 1
	var car=new Array();

	for (a=0; a<10; a++)
	{
		car[a]='';	
	}
	var b;
	for (a=0; a<txt.length; a++)
	{
		ok=false;
		l=txt.charAt(a);
		if (reg1.test(l) && l==car[0] && l==car[1] && l==car[2] && l==car[3] && l==car[4] && l==car[5] && l==car[6] && l==car[7] && l==car[8] && l==car[9])
			ok=true;
				
		if (reg2.test(l) && l==car[0] && l==car[1] && l==car[2])
			ok=true;
			
		if (reg3.test(l) && l==car[0])
			ok=true;
			
		if (ok)
		{	
			txt=txt.substr(0, a)+txt.substr(a+1, txt.length);
			a--;
		}
		else
		{
			for (b=9; b>0; b--)
			{
				car[b]=car[b-1];
			}
			car[0]=l;
		}
	}
	return txt;
}

function contarMayusculas(txt)
{
	var cant=0;
	var regul=/[A-ZÁ-ÚÀ-ÙÄ-ÜÂ-ÛÑÇ]/;
	var l;
	if (txt.length!='')
	{
		if (txt.length>1000)
		{
			alert ('El comentario tiene '+txt.length+' caracteres y solo se permiten 1000.\nPor favor resume la idea que estás expresando.');
		}
		else
		{
			for (var a=0;a<txt.length;a++)
			{
				l=txt.charAt(a);
				if (regul.test(l))
					cant++;
			}
			if ((cant*100/txt.length)<20)
				return true;
			else
			{
				alert ('El comentario contiene muchas mayúsculas, te pedimos que escribas en minúsculas y utilices el ícono "N" si querés resaltar parte del texto.');
				return false;
			}
		}
	}
	else
	{
		alert ('Ingresa un texto antes de enviar el comentario.');
			return false;
	}
}

function insertCursor(txtArea, txt)
{
	var input=get(txtArea);
	
	if(typeof document.selection!='undefined' && document.selection)
	{
		var str=document.selection.createRange().text;
		input.focus();
		var sel=document.selection.createRange();
		sel.text=txt;
		input.focus();
	}
	else if(typeof input.selectionStart!='undefined')
	{
		var start=input.selectionStart;
		var end=input.selectionEnd;
		//var insText=input.value.substring(start, end);
		input.value=input.value.substr(0, start)+txt+input.value.substr(end);
		if (start==end)
		{
			input.selectionStart=start+txt.length;
			input.selectionEnd=start+txt.length;
		}
		else
		{
			input.selectionStart=start;
			input.selectionEnd=start+txt.length;
		}
		input.focus();
	}
}

function negrita(txtArea)
{
	var input=get(txtArea);
	
	if(typeof document.selection!='undefined' && document.selection)
	{
		var str=document.selection.createRange().text;
		input.focus();
		var sel=document.selection.createRange();
		sel.text='[b]'+str+'[/b]';
		input.focus();
	}
	else if(typeof input.selectionStart!='undefined')
	{
		var start=input.selectionStart;
		var end=input.selectionEnd;
		var insText=input.value.substring(start, end);
		input.value=input.value.substr(0, start)+'[b]'+insText+'[/b]'+input.value.substr(end);
		input.selectionStart=start+3;
		input.selectionEnd=end+3;
		input.focus();
	}
}

//Navegacion por formularios de logueo:
function UserNuevo()
{
	get('regMensaje').style.display='none';
	get('regNombre').value=get('ingNombre').value;
	get('regPass1').value='';
	get('regPass2').value='';
	get('regError').style.display='none';
	get('regValidar').style.display='none';
		
	get('ingreso').style.display='none';
	get('registro').style.display='block';
}

function CancelRegistro()
{
	get('ingNombre').value=get('regNombre').value;
	get('ingPass').value='';
	get('ingError').style.display='none';
	get('ingMensaje').style.display='none';
	get('ingValidar').style.display='none';
		
	get('registro').style.display='none';
	get('ingreso').style.display='block';
}

function ingRecuperar()
{
	get('recError').style.display='none'
	get('recValidar').style.display='none';
	
	get('ingreso').style.display='none';
	get('recuperar').style.display='block';
}

function regRecuperar()
{
	get('recEmail').value=get('ingEmail').value;
	get('recError').style.display='none'
	get('recValidar').style.display='none';
	
	get('registro').style.display='none';
	get('recuperar').style.display='block';
}

function CancelarRecuperar()
{
	get('ingPass').value='';
	get('ingError').style.display='none';
	get('ingMensaje').style.display='none';
	get('ingValidar').style.display='none';
	
	get('recuperar').style.display='none';
	get('ingreso').style.display='block';
}


function ingValidacion()
{
	get('valError').style.display='none'
	
	get('ingreso').style.display='none';
	get('validar').style.display='block';
}

function regValidacion()
{
	get('valEmail').value=get('regEmail').value;
	get('valError').style.display='none'
	
	get('registro').style.display='none';
	get('validar').style.display='block';
}

function recValidacion()
{
	get('valEmail').value=get('recEmail').value;
	get('valError').style.display='none'
	
	get('recuperar').style.display='none';
	get('validar').style.display='block';
}

function CancelarValidar()
{
	get('ingPass').value='';
	get('ingError').style.display='none';
	get('ingMensaje').style.display='none';
	get('ingValidar').style.display='none';
	
	get('validar').style.display='none';
	get('ingreso').style.display='block';
}

//Interacciones con el servidor:
function Ingresar()
{
	var Respuesta;
	var txtError='';
	var Pub=null;
	var Nom=get('ingNombre').value;
	var Pass=get('ingPass').value;
	
	if (get('ingPub1').checked) Pub=1;
	if (get('ingPub2').checked) Pub=0;
	
	//Validacion:
	if (Nom.length<2)
		txtError='El nombre de usuario no es válido, debe contener al menos 2 caracteres.';
	else if (Nom.length>30)
		txtError='El nombre de usuario es muy extenso, debe contener 30 caracteres o menos.';
	else if (!ValidarUser(Nom))
		txtError='El nombre de usuario no es válido, debe contener solo letras, números y espacios.';
	else if (Pass.length<4)
		txtError='La contraseña no es válida, debe contener al menos 4 caracteres.';
	else if (Pass.length>20)
		txtError='La contraseña no es muy extensa, debe contener 20 caracteres o menos.';
	else if (!ValidarPass(Pass))
		txtError='La contraseña no es válida, debe contener solo letras, números.';
	else if (Pub==null)
		txtError='Debe indicarse si la PC es compartida o privada.';
	
	if (txtError=='')
	{
		//Ingresando:
		get('ingValidar').style.display='none';
		get('ingreso').style.display='none';
		get('mensaje').innerHTML='<p style="color: #FF0000">INGRESANDO...</p>';
		get('mensaje').style.display='block';
	
		//Conexión ajax:
		ajax=nuevoAjax();
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==4 && tout)
			{
				tout=false;
				Respuesta=ajax.responseText;
				if (Respuesta=='e1')
				{
					//Cuenta inactiva
					txtError='La cuenta está inactiva. tenés que validarla desde el e-mail que enviamos a tu casilla de correo. Revisá la bandeja de correo no deseado o antispam. O enviá  el e-mail de validaci&oacute;n nuevamente.';
					get('ingValidar').style.display='block';
				}
				else if (Respuesta=='e2')
				{
					//Contraseña incorrecta:
					txtError='La contrase&ntilde;a es incorrecta, Ingres&aacute; la contrase&ntilde;a correctamente (verific&aacute; may&uacute;sculas y min&uacute;sculas) o recuper&aacute; los datos si no la record&aacute;s.';
				}
				else if (Respuesta=='e3')
				{
					//No existe 
					txtError='No existe un usuario con ese nombre o el nombre es incorrecto. Ingres&aacute; un nombre v&aacute;lido, registrate como nuevo usuario o recuper&aacute; los datos.';
				}
				else if (Respuesta=='e4')
				{
					txtError='ERROR: Faltan datos en la comunicaci&oacute;n con el servidor. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				else if (Respuesta=='e5')
				{
					txtError='La Cuenta está temporalmente suspendida por no respetar las reglas del foro.';
				}
				else if (Respuesta=='e6')
				{
					txtError='La cuenta está suspendida definitivamente por no respetar las reglas del foro.';
				}
				else if (Respuesta.length!=17)
				{
					txtError='ERROR: El servidor envi&oacute; una respuesta inesperada. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				if (txtError!='')
				{
					get('ingPass').value='';
					get('ingMensaje').style.display='none';
					get('ingError').innerHTML=txtError;
					get('ingError').style.display='block';
				
					get('mensaje').style.display='none';
					get('ingreso').style.display='block';
					UserID='';
					userNombre='';
				}
				else
				{
					userNombre=Nom;
					get('userNombre').innerHTML=Nom;
					get('userError').style.display='none';
					
					get('mensaje').style.display='none';
					get('usuario').style.display='block';
					UserID=Respuesta;
				}
			}
		}
		ajax.open('POST', 'login.php', true);	
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');	
		ajax.send('n='+escape(Nom)+'&p='+escape(Pass)+'&pub='+Pub);
		tout=true;
		setTimeout('acctout("ingreso", "ingError", "ERROR: El servidor no ha enviado respuesta. Volv&eacute; a repetir la operaci&oacute; nuevamente.")', 20000);
	}
	else
	{
		//Error:
		get('ingError').innerHTML=txtError;
		get('ingError').style.display='block';
	}
}

function UserRegistro()
{
	var Respuesta;
	var txtError='';
	
	get('regError').innerHTML='';
	get('regError').style.display='none';
	
	var Nom=get('regNombre').value;
	var Pass1=get('regPass1').value;
	var Pass2=get('regPass2').value;
	var Email=get('regEmail').value;
	
	//Validacion:
	if (Nom.length<2)
		txtError='El nombre de usuario no es válido, debe contener al menos 2 caracteres.';
	else if (Nom.length>30)
		txtError='El nombre de usuario es muy extenso, debe contener 30 caracteres o menos.';
	else if (!ValidarUser(Nom))
		txtError='El nombre de usuario no es válido, debe contener solo letras, números y espacios.';
	else if (!ValidarEmail(Email))
		txtError='El e-mail no es válido.';
	else if (Pass1.length<4)
		txtError='La contraseña no es válida, debe contener al menos 4 caracteres.';
	else if (Pass1.length>20)
		txtError='La contraseña no es muy extensa, debe contener 20 caracteres o menos.';
	else if (!ValidarPass(Pass1))
		txtError='La contraseña no es válida, debe contener solo letras, números.';
	else if (Pass1!=Pass2)
		txtError='La contraseña y su confirmación no coinciden.';
	
	if (txtError=='')
	{
		//Registrando:
		get('regValidar').style.display='none';
		
		get('registro').style.display='none';
		get('mensaje').innerHTML='<p style="color: #FF0000">REGISTRANDO NUEVO USUARIO...</p>';
		get('mensaje').style.display='block';
		
		ajax=nuevoAjax();
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==4 && tout)
			{
				tout=false;
				Respuesta=ajax.responseText;
				if (Respuesta=='e1')
				{
					//e-mail ya está registrado sin validación:
					txtError='El e-mail ingresado ya est&aacute; registrado pero la cuenta a&uacute;n no est&aacute; validada. Para validar la cuenta ten&eacute;s que seguir las instrucciones del e-mail que hemos enviado a tu casilla de correo. Revis&aacute; la bandeja de correo no deseado o antispam. O enviá  el e-mail de validaci&oacute;n nuevamente.';
					get('regValidar').style.display='block';
				}
				else if (Respuesta=='e2')
				{
					//e-mail ya está registrado con validación:
					txtError='El e-mail ingresado ya est&aacute; registrado. Cancel&aacute; para ingresar o recuper&aacute; los datos.';
				}
				else if (Respuesta=='e3')
				{
					//Nombre ya registrado por otro usuario:
					txtError='El nombre ingresado ya est&aacute; registrado por otro usuario. Reemplazalo por otro.';
				}			
				else if (Respuesta=='e4')
				{
					txtError='ERROR: Faltan datos en la comunicaci&oacute;n con el servidor. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				else if (Respuesta=='e5')
				{
					txtError='El e-mail ingresado ya está registrado en una cuenta temporalmente suspendida por no respetar las reglas del foro.';
				}
				else if (Respuesta=='e6')
				{
					txtError='El e-mail ingresado ya está registrado en una cuenta suspendida definitivamente por no respetar las reglas del foro.';
				}
				else if (Respuesta.length!=17)
				{
					txtError='ERROR: El servidor envi&oacute; una respuesta inesperada. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				if (txtError!="")
				{
					get('regMensaje').style.display='none';
					get('regError').innerHTML=txtError;
					get('regError').style.display='block';
				
					get('mensaje').style.display='none';
					get('registro').style.display='block';
				}
				else
				{
					get('ingNombre').innerHTML=Nom;
					get('ingMensaje').innerHTML='Hemos enviado un e-mail a la casilla de correo '+Email+', desde all&iacute; pod&eacute;s validar la cuenta para terminar con el proceso de registro.';
					get('ingMensaje').style.display='block';
					get('ingError').style.display='none';
					
					get('mensaje').style.display='none';
					get('ingreso').style.display='block';
				}
				UserID='';
			}
		}
		ajax.open('POST', 'registro.php', true);
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
		ajax.send('n='+escape(Nom)+'&p='+escape(Pass1)+'&e='+escape(Email));
		tout=true;
		setTimeout('acctout("registro", "regError", "ERROR: El servidor no ha enviado respuesta. Volv&eacute; a repetir la operaci&oacute; nuevamente.")', 20000);
	}
	else
	{
		//Error:
		get('regError').innerHTML=txtError;
		get('regError').style.display='block';
	}
}

function EnviarValidacion()
{
	var Respuesta;
	var txtError='';
	var txtMsg='';
	var Email=get('valEmail').value;
	
	get('recValidar').style.display='none';
	get('valError').style.display='none';
	get('valError').innerHTML='';
		
	//Validacion:
	if (!ValidarEmail(Email))
		txtError='El e-mail no es válido.';
	
	if (txtError=='')
	{
		//Enviando email de validacion:
		get('validar').style.display='none';
		get('mensaje').innerHTML='<p style="color: #FF0000">ENVIANDO E-MAIL DE VALIDACI&Oacute;N...</p>';
		get('mensaje').style.display='block';
		
		//Conexión ajax:
		ajax=nuevoAjax();
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==4 && tout)
			{
				tout=false;
				Respuesta=ajax.responseText;
				if (Respuesta=='e1')
				{
					//Cuenta activa
					txtMsg='El e-mail ingresado pertenece a una cuenta que ya fue activada anteriormente. Ingresá con tu nombre de usuario y la contraseña o recuperá los datos.';
					get('recValidar').style.display='block';
				}
				else if (Respuesta=='e2')
				{
					txtError='El e-mail ingresado es erroneo o no está registrado como usuario. Volvé a ingresar el e-mail correctamente o registrate como nuevo usuario.';
				}
				else if (Respuesta=='e3')
				{
					//Faltaron datos en el envío al servidor
					txtError='ERROR: Faltan datos en la comunicaci&oacute;n con el servidor. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				else if (Respuesta=='e4')
				{
					//Faltaron datos en el envío al servidor
					txtError='Tu cuenta está temporalmente suspendida por no ajustarse a las reglas del foro.';
				}
				else if (Respuesta=='e5')
				{
					//Faltaron datos en el envío al servidor
					txtError='Tu cuenta está definitivamente suspendida por no ajustarse a las reglas del foro.';
				}
				else if (Respuesta=='ok')
				{
					txtMsg='Hemos enviado un e-mail a la casilla de correo '+Email+', desde all&iacute; pod&eacute;s validar la cuenta para terminar con el proceso de registro.';
				}
				else
				{
					txtError='ERROR: El servidor envi&oacute; una respuesta inesperada. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				
				if (txtError!='')
				{
					get('valError').innerHTML=txtError;
					get('valError').style.display='block';
										
					get('mensaje').style.display='none';
					get('validar').style.display='block';
				}
				else
				{
					get('ingNombre').value='';
					get('ingMensaje').innerHTML=txtMsg;
					get('ingMensaje').style.display='block';
					get('ingNombre').value='';
					get('ingPass').value='';
					get('ingPub1').checked=false;
					get('ingPub2').checked=false;
					get('ingError').value='';
					get('ingError').style.display='none';
					get('ingValidar').style.display='none';
					get('mensaje').style.display='none';
					get('ingreso').style.display='block';
					get('recEmail').value=Email;
				}
				UserID=0;
			}
		}
		ajax.open('POST', 'emailvalidacion.php', true);	
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');	
		ajax.send('e='+escape(Email));
		tout=true;
		setTimeout('acctout("validar", "valError", "ERROR: El servidor no ha enviado respuesta. Volv&eacute; a repetir la operaci&oacute; nuevamente.")', 20000);
	}
	else
	{
		//Error:
		get('valError').innerHTML=txtError;
		get('valError').style.display='block';
	}
}

function RecuperarDatos()
{
	var Respuesta;
	var txtError='';
	var txtMsg='';
	var Email=get('recEmail').value;
	
	get('recError').style.display='none';
	get('recError').innerHTML='';
		
	//Validacion:
	if (!ValidarEmail(Email))
		txtError='El e-mail no es válido.';
	
	if (txtError=='')
	{
		//Enviando email de validacion:
		
		get('mensaje').innerHTML='<p style="color: #FF0000">ENVIANDO E-MAIL CON INFORMACION DE CUENTA...</p>';
		get('recuperar').style.display='none';
		get('mensaje').style.display='block';
		
		//Conexión ajax:
		ajax=nuevoAjax();
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==4 && tout)
			{
				tout=false;
				Respuesta=ajax.responseText;
				if (Respuesta=='e1')
				{
					//Cuenta activa
					txtMsg='El e-mail ingresado pertenece a una cuenta que a&uacute;n no est&aacute; validada. Para validar la cuenta ten&eacute;s que seguir las instrucciones del e-mail que hemos enviado a tu casilla de correo. Revis&aacute; la bandeja de correo no deseado o antispam. O enviá  el e-mail de validaci&oacute;n nuevamente.';
					get('ingValidar').style.display='block';
				}
				else if (Respuesta=='e2')
				{
					txtError='El e-mail ingresado es erroneo o no está registrado como usuario. Volvé a ingresar el e-mail correctamente o registrate como nuevo usuario.';
				}
				else if (Respuesta=='e3')
				{
					//Faltaron datos en el envío al servidor
					txtError='ERROR: Faltan datos en la comunicaci&oacute;n con el servidor. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				else if (Respuesta=='e4')
				{
					//Faltaron datos en el envío al servidor
					txtError='Tu cuenta está temporalmente suspendida por no ajustarse a las reglas del foro.';
				}
				else if (Respuesta=='e5')
				{
					//Faltaron datos en el envío al servidor
					txtError='Tu cuenta está definitivamente suspendida por no ajustarse a las reglas del foro.';
				}
				else if (Respuesta=='ok')
				{
					txtMsg='Hemos enviado un e-mail a la casilla de correo '+Email+', con la información para poder ingresar al foro.';
				}
				else
				{
					txtError='ERROR: El servidor envi&oacute; una respuesta inesperada. Volv&eacute; a intentar la operaci&oacute;n nuevamente.';
				}
				if (txtError!='')
				{
					get('recError').innerHTML=txtError;
					get('recError').style.display='block';
										
					get('mensaje').style.display='none';
					get('recuperar').style.display='block';
				}
				else
				{
					get('ingNombre').value='';
					get('ingMensaje').innerHTML=txtMsg;
					get('ingMensaje').style.display='block';
					get('ingNombre').value='';
					get('ingPass').value='';
					get('ingPub1').checked=false;
					get('ingPub2').checked=false;
					get('ingError').value='';
					get('ingError').style.display='none';
					get('mensaje').style.display='none';
					get('ingreso').style.display='block';
					get('valEmail').value=Email;
				}
			}
		}
		ajax.open('POST', 'emaildatos.php', true);	
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');	
		ajax.send('e='+escape(Email));
		tout=true;
		setTimeout('acctout("recuperar", "recError", "ERROR: El servidor no ha enviado respuesta. Volv&eacute; a repetir la operaci&oacute; nuevamente.")', 20000);
	}
	else
	{
		//Error:
		get('recError').innerHTML=txtError;
		get('recError').style.display='block';
	}
}

function Logout()
{
	var Logout='';
	
	get('mensaje').innerHTML='<p style="color: #FF0000">CERRANDO SESI&Oacute;N...</p>';
	get('usuario').style.display='none';
	get('mensaje').style.display='block';

	ajax=nuevoAjax();
	ajax.onreadystatechange=function()
	{ 
		if (ajax.readyState==4 && tout)
		{
			tout=false;
			Logout=ajax.responseText;
			if (Logout=='logout')
			{
				//Limpia los campos y los mensajes:
				get('ingNombre').value="";
				get('ingPass').value="";
				get('ingPub1').checked=false;
				get('ingPub2').checked=false;
				get('ingMensaje').style.display='none';
				get('ingError').style.display='none';
				
				//Cierra el mensaje y abre el formulario de ingreso:
				get('mensaje').style.display='none';
				get('ingreso').style.display='block';
				UserID='';
			}
			else
			{
				get('userError').innerHTML='ERROR: el servidor envi&oacute; una respuesta inesperada. Volv&eacute; a intentar la operaci&oacute;n.';
				get('userError').style.display='block';
				get('mensaje').style.display='none';
				get('usuario').style.display='block';
			}
		}
	}
	ajax.open('POST', 'logout.php', true);
	ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');	
	ajax.send('');
	tout=true;
	setTimeout('acctout("usuario", "userError", "ERROR: El servidor no ha enviado respuesta. Intente la operaci&oacute;n nuevamente.")', 20000);
}

//Validaciones:
function ValidarUser(str)
{
	var ok=true;	
	str=str.toLowerCase();
	var l="";
	if (str.length<2 || str.length>30)
		ok=false;
	else
	{
		for (var a=0;a<str.length;a++)
		{
			l=str.substring(a,a+1);
			if ((l<"a" || l>"z") && (l<"0" || l>"9") && l!=" " && (l<"á" || l>"ú") && (l<"Á" || l>"Ú") && l!="ñ" && l!="Ñ")
			{
				ok=false;
				break;
			}
		}
	}
	return ok;	
}

function ValidarPass(str)
{
	var ok=true;	
	str=str.toLowerCase();
	var l="";
	if (str.length<4 || str.length>20)
		ok=false;
	else
	{
		for (var a=0;a<str.length;a++)
		{
			l=str.substring(a,a+1);
			if ((l<"a" || l>"z") && (l<"0" || l>"9"))
			{
				ok=false;
				break;
			}
		}
		return ok;
	}
}

function ValidarEmail(str)
{
	var ok=true;
	str=str.toLowerCase();
	var l="";
	var pre="";
	var arroba=false;
	
	for (var a=0;a<str.length;a++)
	{
		l=str.substring(a,a+1);
		if (a==0 || a==(str.length-1))
		{
			if ((l<"a" || l>"z") && (l<"0" || l>"9"))
			{
				ok=false;
				break;
			}
		}
		else
		{
			if ((l<"a" || l>"z") && (l<"0" || l>"9") && l!="_" && l!="-" && l!="@" && l!=".")
			{
				ok=false;
				break;
			}
		}
		if (pre=="." && (l=="@" || l=="."))
		{
			ok=false;
			break;
		}
		if (l=="@")
		{
			if (arroba)
			{
				ok=false;
				break;
			}
			else
				arroba=true;
		}
		pre=l;
	}
	if (!arroba)
		ok=false;
	
	return ok;
}

//Timeout de servidor:
function acctout(obj, objError, msg)
{
	if (tout)
	{
		tout=false;
		get(objError).innerHTML=msg;
		get(objError).style.display='block';
		get('mensaje').style.display='none';
		get(obj).style.display='block';
	}
}

//Reglas:
function reglas()
{
	cerrarTodo();
	get('Reglas').style.display='block';
	location='#1';
	vistaAct=4;
}


//Formulario Contacto:
function contactar()
{
	cerrarTodo();
	if (UserID!='')
	{
		get('contactoInput1').style.display='none';
		get('contactoInput2').style.display='none';
		get('contactoTitulo2').style.display='none';
		get('contactoTexto1').innerHTML=userNombre;
		get('contactoTexto1').style.display='block';
	}
	else
	{
		get('contactoTexto1').style.display='none';
		get('contactoInput1').style.display='block';
		get('contactoInput2').style.display='block';
		get('contactoTitulo2').style.display='block';
	}
	get('ContactoEnviando').style.display='none';
	get('ContactoMensaje1').style.display='none';
	get('ContactoMensaje2').style.display='none';
	get('ContactoForm').style.display='block';
	get('Contacto').style.display='block';
	location='#1';
	vistaAct=3;
}

function enviarContacto()
{
	var msg='';
	var mensaje=get('contactoTexto').value;
	mensaje=escape(mensaje);
	if (mensaje=='')
	{
		alert('Escribí un menaje antes de enviar.');
	}
	else
	{
		if (UserID!='')
		{
			msg='u='+UserID+'&m='+mensaje;
		}
		else
		{
			var Nombre=get('contactoNombre').value;
			var email=get('contactoEmail').value;
			if (!ValidarEmail(email))
			{
				alert('Ingresá un e-mail válido.');
			}
			else
			{
				Nombre=escape(Nombre);
				msg='n='+Nombre+'&e='+email+'&m='+mensaje;
			}
		}
	}
	if (msg!='')
	{
		ajax=nuevoAjax();
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==4)
			{
				var txt=ajax.responseText;
				if (txt=='ok0')
				{	
					//Mensaje enviado por validar:
					get('ContactoEnviando').style.display='none';
					get('contactoTexto').value='';
					get('ContactoMensaje1').style.display='block';
				}
				else if (txt=='ok1')
				{
					//Mensaje enviado con usuario:
					get('ContactoEnviando').style.display='none';
					get('contactoTexto').value='';
					get('ContactoMensaje2').style.display='block';
				}
				else if (txt=='e1')
				{
					get('ContactoEnviando').style.display='none';
					get('ContactoForm').style.display='block';
					alert ('Código de usuario invalido o error de base de datos. El mensaje no fue enviado.');
				}
				else if (txt=='e2')
				{
					get('ContactoEnviando').style.display='none';
					get('ContactoForm').style.display='block';
					alert ('Faltan datos en la comunicación con el servidor. El mensaje no fue enviado.');
				}
				else if (txt!='')
				{
					get('ContactoEnviando').style.display='none';
					get('ContactoForm').style.display='block';
					alert ('Error desconocido en el servidor. El mensaje no fue enviado.\n'+txt);
				}
			}
		}
		//Enviando el mensaje:
		get('ContactoForm').style.display='none';
		get('ContactoEnviando').style.display='block';
		
		ajax.open('POST', 'enviarmensaje.php', true);
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
		ajax.send(msg);
	}
}

//Foros Menu:
function forosMenu(cat)
{
	cerrarTodo();
	forosCat(cat);
	get('ForosMenu').style.display='block';
	vistaAct=1;
	location='#1';
}

function forosCat(cat)
{
	if (cat!=null)
	{
		var a;
		var cAux=0;
		var txt='';
		if (cat!=0)
		{
			aux=catCat[cat];
			while (aux!=(-1))
			{
				txt1='<table class="MenuForo" cellpadding="0" cellspacing="0" border="0" width="100%">';
				txt1+='<tr><td width="40">';
				if (aux!=0)
				{
					txt1+='<a href="javascript: forosCat('+aux+')"><img src="/imagenes/mas.gif" width="20" height="20" border="0"></a></td><td><h4>'+nomCat[aux]+'</h4></td></tr>';
				}
				else
				{
					txt1+='<a href="javascript: forosCat('+aux+')"><img src="/imagenes/mas.gif" width="20" height="20" border="0"></a></td><td><h4>Menú principal</h4></td></tr>';
				}
				txt1+='<tr><td>&nbsp;</td><td>';
				if (aux==0)
					aux=-1;
				else
					aux=catCat[aux];
				
				txt=txt1+txt;
				cAux++;
			}
		}
		txt='<h2>Menú de foros</h2>'+txt;
		
		txt+='<table class="MenuForo" cellpadding="0" cellspacing="0" border="0" width="100%">';
		txt+='<tr><td width="40">';
		
		if (cat!=0)
			txt+='<a href="javascript: forosCat('+catCat[cat]+')"><img src="/imagenes/menos.gif" width="20" height="20" border="0"></a></td><td><h3>'+nomCat[cat]+'</h3></td></tr>';
		else
			txt+='&nbsp;</td><td><h3>Menú principal</h3></td></tr>';
		
		var ini=true;
		for (a=0;a<=maxForo;a++)
		{
			if (catForo[a]==cat)
			{
				if (ini)
				{
					txt+='<tr><td width="40">&nbsp;</td><td>';
					txt+='<table class="MenuForo" cellpadding="0" cellspacing="0" border="0" width="100%">';
					ini=false;
				}
				txt+='<tr><td><h5><a href="javascript: irForo('+a+', 0)">'+titForo[a]+'</h5></td></tr>';
			}
		}
		if (!ini)
		{
			txt+='</table>';
			txt+='</td></tr>';
		}
	
		ini=true;
		for (a=0;a<=maxCat;a++)
		{
			if (catCat[a]==cat)
			{
				if (ini)
				{
					txt+='<tr><td width="40">&nbsp;</td><td>';
					txt+='<table class="MenuForo" cellpadding="5" cellspacing="0" border="0" width="100%">';
					ini=false;
				}
				txt+='<tr><td><tr><td width="40"><a href="javascript: forosCat('+a+')"><img src="/imagenes/mas.gif" width="20" height="20" border="0"></td><td><h4>'+nomCat[a]+'</h4></td></tr>';
			}
		}
		if (!ini)
		{
			txt+='</table>';
			txt+='</td></tr>';
		}
		txt+='</table>';
		
		for (a=0;a<cAux;a++)
		{
			txt+='</td></tr></table>';
		}
		get('ForosMenu').innerHTML=txt;
	}
}

//Lógica de FORO:
function responder(id)
{
	if (inhibe)
		setTimeout('responder('+id+')', 300);
	else
	{
		act=false;
		txt='<div id="formCom'+id+'" style="display: block;">\n';
		txt+='<table class="Foros" cellpadding="0" cellspacing="0" border="0" width="100%">\n';
		txt+='<tr><th align="left">Agregá tu respuesta a este comentario:</th></tr>\n';
		txt+='<tr><td align="center"><textarea class="Texto" id="comentario2" cols="83" rows="5"></textarea></td></tr>\n';
		txt+='<tr><td>\n';
		txt+='<table cellpadding="0" cellspacing="0" border="0" width="100%">\n';
		txt+='<tr>\n';
		txt+='<td width="26%">&nbsp;</td>\n';
		txt+='<td width="3%"><img src="/gestos/sonrisa.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:)]\')" onmouseover="window.status=\'Agregar gesto de sonrisa\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/risa.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:d]\')" onmouseover="window.status=\'Agregar gesto de risa\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/guino.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[;)]\')" onmouseover="window.status=\'Agregar gesto de guiño\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/sorpresa.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:o]\')" onmouseover="window.status=\'Agregar gesto de sorpresa\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/lengua.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:p]\')" onmouseover="window.status=\'Agregar gesto de lengua\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/enfadado.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:@]\')" onmouseover="window.status=\'Agregar gesto de enfadado\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/confundido.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:s]\')" onmouseover="window.status=\'Agregar gesto de confundido\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/ruborizado.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:$]\')" onmouseover="window.status=\'Agregar gesto de ruborizado\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/triste.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:(]\')" onmouseover="window.status=\'Agregar gesto de triste\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/lloron.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:\\\'(]\')" onmouseover="window.status=\'Agregar gesto de llorón\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/decepcionado.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[:|]\')" onmouseover="window.status=\'Agregar gesto de decepcionado\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/dientes.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[8o|]\')" onmouseover="window.status=\'Agregar gesto de dientes\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/dormido.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[|)]\')" onmouseover="window.status=\'Agregar gesto de dormido\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/corazon.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[(l)]\')" onmouseover="window.status=\'Agregar gesto de corazón\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/corazonroto.gif" width="23" height="19" border="0" onclick="insertCursor(\'comentario2\', \'[(u)]\')" onmouseover="window.status=\'Agregar gesto de corazón roto\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="3%"><img src="/gestos/negrita.gif" width="23" height="23" border="0" onclick="negrita(\'comentario2\')" onmouseover="window.status=\'Resaltar texto seleccionado\'" onmouseout="window.status=\'\'"></td>\n';
		txt+='<td width="26%">&nbsp;</td>\n';
		txt+='</tr>\n';
		txt+='</table>\n';
		txt+='</td></tr>\n';
		txt+='<tr><td colspan="2" align="center"><input class="Boton" type="button" value="ENVIAR" onclick="enviarComentario('+id+')" onmouseover="window.status=\'Enviar respuesta a este comentario\'" onmouseout="window.status=\'\'"><input class="Boton" type="button" value="CANCELAR" onclick="cancelarComentario('+id+')" onmouseover="window.status=\'Cancelar respuesta a este comentario\'" onmouseout="window.status=\'\'"></td></tr>\n';
		txt+='</table>\n';
		txt+='</div>\n';
		txt+='<div id="formEnv'+id+'" style="display: none;">\n';
		txt+='<table class="Foros" cellpadding="0" cellspacing="0" border="0" width="100%">\n';
		txt+='<tr><th align="center">ENVIANDO COMENTARIO...</th></tr>\n';
		txt+='<tr><td align="center">Presione el botón de continuar si en unos segundos la página no se actualiza.</td></tr>\n';
		txt+='<tr><td align="center"><input type="button" class="Boton" value="CONTINUAR" onclick="continuar('+id+')"></td></tr>\n';
		txt+='</table>\n';
		txt+='</div>\n';
		txt+='<div id="formError'+id+'" style="display: none;">\n';
		txt+='<table class="Foros" cellpadding="0" cellspacing="0" border="0" width="100%">\n';
		txt+='<tr><th align="center">ERROR AL ENVIAR EL COMENTARIO</th></tr>\n';
		txt+='<tr><td id="msgError" align="justify"></td><tr>\n';
		txt+='<tr><td align="center"><input type="button" class="Boton" value="CONTINUAR" onclick="continuar('+id+')"></td></tr>\n';
		txt+='</table>\n';
		txt+='</div>\n';
		txt+='<div id="formLog'+id+'" style="display: none;">\n';
		txt+='<table class="Foros" cellpadding="0" cellspacing="0" border="0" width="100%">\n';
		txt+='<tr><th align="center">FALTA REGISTRO DE USUARIO</th></tr>\n';
		txt+='<tr><td align="center">Tenés que registrarte antes de dejar tu comentario</td></tr>\n';
		txt+='<tr><td align="center"><input type="button" class="Boton" value="REGISTRARSE" onclick="location=\'#logueo\'; get(\'formLog'+id+'\').style.display=\'none\'; get(\'formCom'+id+'\').style.display=\'block\';"></td></tr>\n';
		txt+='</table>\n';
		txt+='</div>\n';
		get('r'+id).innerHTML=txt;
		if (respAct!=0)
		{
			cancelarComentario(respAct);
			act=false;
		}
		respAct=id;
		if (foroPagAct==foroPaginas)
			get('formCom0').style.display='none';
	}
}

function keypr()
{
	if (get('comentario').value!='' && respAct==0)
	{
		act=false;
		window.status='Mientras estás escribiendo un comentario el foro no se actualiza... Clickeá en "Limpiar" para borrar el mensaje y reestablecer la actualización del foro.';
	}
	else
	{
		act=act2;
		window.status='Actualización automática activada';
	}
}

function keyanul()
{
	window.status="Mientras estás escribiendo un comentario el foro no se actualiza...";
	if (counter>0)
	{
		counter--;
		setTimeout('keyanul()', 1000);
	}
	else
		window.status="";
}

function cancelarComentario(id)
{
	if (id!=0)
	{
		get('r'+id).innerHTML='<a href="javascript: responder('+id+');">Responder este comentario</a>';
		respAct=0;
		if (foroPagAct==foroPaginas)
		{
			get('formCom0').style.display='block';
		
			if (get('comentario').value=='')
			{
				window.status='Actualización automática activada';
				act=act2;
			}
			else
			{
				window.status='Mientras estás escribiendo un comentario el foro no se actualiza... Clickeá en "Limpiar" para borrar el mensaje y reestablecer la actualización del foro.';
			}
		}
		
	}
	else
	{
		get('comentario').value='';
		window.status='Actualización automática activada';
		act=act2;
	}
}

function continuar(comID)
{
	inhibe=false;
	get('formError'+comID).style.display='none';
	get('formEnv'+comID).style.display='none';
	get('formCom'+comID).style.display='block';
	irPagina(foroPagAct,-1);
	location='#Programa';
}

function enviarComentario(comID)
{
	if (UserID=='')
	{
		get('formCom'+comID).style.display='none';
		get('formLog'+comID).style.display='block';
	}
	else
	{
		var c='comentario';
		if (comID!=0)
			c+='2';
		
		if (contarMayusculas(get(c).value))
		{
			get('formCom'+comID).style.display='none';
			get('formEnv'+comID).style.display='block';
			irPagina(0, comID);
		}
	}
}

function revisar(comID)
{
	ajax=nuevoAjax();
	ajax.onreadystatechange=function()
	{ 
		if (ajax.readyState==4)
		{
			var txt=ajax.responseText;
			if (txt=='ok')
				alert ('Sugeriste revisar el comportamiento de este forista.\nMuchas gracias por colaborar con el foro.');
			else if (txt=='e1')
				alert ('Ya sugeriste revisar el comportamiento de este usuario anteriormente.\nNo es necesario que vuelvas a repetir la sugerencia.');
			else if (txt=='e2' || txt=='e4')
				alert ('Petición inválida. No ha podido realizarse la operación solicitada.');
			else if (txt=='e3')
				alert ('Usuario no válido o cuenta suspendida. No se ha podido realizar esta operación.');
			else if (txt=='e5')
				alert('Tenés que estar registrado e iniciar la sesión para realizar esta operación. Tu sesión puede haber caducado.');
			else
				alert ('El servido ha enviado una respuesta inesperada. No ha podido realizarse la operación solicitada.');
		}
	}
	ajax.open('POST', 'expulsar.php', true);
	ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
	ajax.send('c='+comID);
}

function irForo(fID, pag)
{
	var txt='<h2>'+titForo[fID]+'</h2>';
	txt+=txtForo[fID];
	if (cerForo[fID]==1)
		txt+='<p>El foro se encuentra cerrado no se admiten nuevos comentarios pero podés recorrerlo y leerlo.</p>';
	
	get('tituloForo').innerHTML=txt;
	cerrarTodo();
	
	if (prgForo[fID]!=0)
		ponerPrograma(prgForo[fID]);
	
	get('Foros').style.display='block';
	
	if (foroID!=fID)
	{
		foroPaginas=0;
		foroPagAct=0;
		foroUltID=0;
		respAct=0;
		txtPage=new Array();
		numPage=new Array();
		comPage=new Array();
		txtPage[0]='';
		numPage[0]=-1;
		comPage[0]=true;
		ultPage[0]=0;
	
		foroID=fID;
		get('cuerpoForo').innerHTML='';
		irPagina(pag, -1);
	}
	else
	{
		if (pag==0)
			irPagina(foroPagAct, -1);
		else
			irPagina(pag, -1);
	}
	vistaAct=2;
}

function ponerPrograma(programa)
{
	txt='<table class="Programa" cellpadding="0" cellspacing="0" border="0" width="100%">';
	txt+='<tr>';
	txt+='<td width="92"><img src="/imagenes/'+logProg[programa]+'" width="92" height="92" border="0" alt="'+nomProg[programa]+'"></td>';
	txt+='<td>';
	txt+='<h1>'+nomProg[programa]+'</h1>';
	txt+=txtProg[programa];
	txt+='</td>';
	txt+='<td width="92"><img src="/imagenes/'+logCanal[canProg[programa]]+'" width="92" height="92" border="0" alt="'+nomCanal[canProg[programa]]+'"></td>';
	txt+='</tr>';
	txt+='</table>';
	get('Programa').innerHTML=txt;
	get('Programa').style.display='block';
}

function irPagina(pagina, envioCom)
{
	if (inhibe)
		setTimeout('irPagina('+pagina+', '+envioCom+')', 300);
	else
	{
		act=false;
		act2=false;
		if (foroPaginas!=0)
		{
			get('paginador1').innerHTML='CARGANDO PÁGINA...';
			get('paginador2').innerHTML='CARGANDO PÁGINA...';
		}
		solicitarPagina(pagina, true, envioCom);
	}
}

function actualizar()
{
	if (vistaAct==2)
	{
		if (act && counter==0 && !inhibe)
			solicitarPagina(foroPagAct, true, -1);
		else
			setTimeout('actualizar()',20000);
	}
}

function solicitarPagina(pagina, imprimir, envioCom)
{
	//Busca página en memoria o solicita página al servidor
	var registro=memoPagina(pagina);
	if (registro==0)
	{
		//No existe página en memoria
		serverPagina(pagina, imprimir, 0, envioCom);
	}
	else if (comPage[registro])
	{
		//Existe página completa
		if (imprimir) impMemo(a, -1);
	}
	else
	{
		//Existe página incompleta
		serverPagina(pagina, imprimir, registro, envioCom);
	}
	return registro;
}

function memoPagina(pagina)
{
	var registro=0;
	for (a=1;a<numPage.length;a++)
	{
		if (numPage[a]==pagina)
		{
			registro=a;
			break;
		}
	}
	return registro;
}

function impMemo(registro, envioCom)
{
	//Imprime en la página el foro:
	foroPagAct=numPage[registro];
	if (foroPagAct==(-1))
		foroPagAct=1;
	
	respAct=0;
	var paginador=ponerPaginador();
	var txt='<div class="Paginador" id="paginador1">'+paginador+'</div>';
	txt+='<table class="Foros" cellpadding="0" cellspacing="0" border="0" width="100%">';
	if (txtPage[registro]=='')
	{
		txt+='<tr><td align="center"><strong> -- -- TODAVÍA NO HAY COMENTARIOS EN ESTE FORO -- -- </strong></td></tr>';
		txt+='<tr><td align="center">¡Podés ser el primero en participar!</td></tr>';
	}
	else
		txt+=txtPage[registro];
	
	txt+='<tr><th colspan="2">ACTUALIZACIÓN AUTOMÁTICA</th></tr>';
	txt+='<tr><td colspan="2" align="center" style="font-size: 12px; line-height: 16px;"><strong>No es necesario presionar F5 o cliquear en el ícono actualizar.<br>Este foro se actualiza automáticamente al recibir nuevos comentarios.<br>Todos los comentarios nuevos y respuestas a comentarios existentes se insertan al final del foro.</strong></td></tr>';
	txt+='</table>';
	txt+='<div class="Paginador" id="paginador2">'+paginador+'</div>';
	get('cuerpoForo').innerHTML=txt;
		
	if (foroPagAct<(foroPaginas-1))
		solicitarPagina(foroPagAct+1, false, -1);
		
	if (foroPagAct>1)
		solicitarPagina(foroPagAct-1, false, -1);
	
	if (!act)
	{
		get('formCom0').style.display='none';
		get('formEnv0').style.display='none';
		get('formError0').style.display='none';
		get('formLog0').style.display='none';
		get('comentario').value='';
	}
	
	if (foroPagAct==foroPaginas && get('formCom0').style.display=='none' && get('formEnv0').style.display=='none' && get('formError0').style.display=='none' && get('formLog0').style.display=='none' && cerForo[foroID]==0)
		get('formCom0').style.display='block';
	else if (foroPagAct!=foroPaginas || cerForo[foroID]==1)
	{
		get('formCom0').style.display='none';
		get('formEnv0').style.display='none';
		get('formError0').style.display='none';
		get('formLog0').style.display='none';
	}
	if (!act && envioCom==-1)
		location='#1';
	else if (envioCom!=-1)
		location='#formCom0';
		
	if (foroPagAct==foroPaginas)
	{
		act=true;
		act2=true;
		setTimeout('actualizar()', 20000);
	}
	else
	{
		act2=false;
		act=false;
	}
}

function ponerPaginador()
{
	var txt="";
		
	var ini=foroPagAct-10;
	if (ini<1) ini=1;
	var fin=foroPagAct+5;
	if (fin>foroPaginas) fin=foroPaginas;
	if (ini>1)
		txt+='<a href="javascript: irPagina(1, -1);">1</a>';
	
	if (ini>2)
		txt+=' | ...';
		
	for (var a=ini;a<=fin;a++)
	{
		if (txt!='')
			txt+=' | ';
		
		if (a!=foroPagAct)
			txt+='<a href="javascript: irPagina('+a+', -1);">';
		else
			txt+='PÁGINA ';
		
		txt+=a;
		
		if (a!=foroPagAct)
			txt+='</a>';
	}
	
	if (fin<(foroPaginas-1))
		txt+=' | ...';
		
	if (fin<foroPaginas)
		txt+=' | <a href="javascript: irPagina('+foroPaginas+', -1);">'+foroPaginas+'</a>';
		
	return txt;
}

function addMemo(registro, txt, completo, ult)
{
	//Agrega pagina a la memoria:
	if (numPage[registro]!=null)
	{
		txtPage[registro]+=filtrarMalasP(agregarGestos(txt));
		comPage[registro]=completo;
		ultPage[registro]=ult;
		return true;
	}
	else
		return false;
}

function addMemoPagina(pagina, txt, completo, ult)
{
	var registro;
	if (numPage.length==null)
		registro=0;
	else
		registro=numPage.length;
	
	numPage[registro]=pagina;
	txtPage[registro]=filtrarMalasP(agregarGestos(txt));
	comPage[registro]=completo;
	ultPage[registro]=ult;
	return registro;
}

function serverPagina(pagina, imprimir, registro, envioCom)
{
	if (!inhibe)
	{
		inhibe=true;
		ajax=nuevoAjax();
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==4 && inhibe)
			{
				var txt=ajax.responseText;
				if (txt>="e1" && txt<="e5" && envioCom!=(-1))
				{
					get('formEnv'+envioCom).style.display='none';
					get('formError'+envioCom).style.display='block';
				}
				else
				{
					procesarPagina(txt, pagina, imprimir, registro, envioCom);
					inhibe=false;
				}
			}
		}
		
		ajax.open('POST', 'foro.php', true);
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
		if (envioCom==(-1))
		{	
			var ff='';
			if (pagina!=0)
				ff='&p='+pagina+'&u='+ultPage[registro];
			
			ajax.send('f='+foroID+ff);
		}
		else
		{
			var com;
			if (envioCom==0)
				com=get('comentario').value;
			else
				com=get('comentario2').value;

			com=escape(adaptar(com));
			ajax.send('f='+foroID+'&u='+foroUltID+'&cid='+envioCom+'&c='+com);
		}
	}
	else
		setTimeout('serverPagina('+pagina+', '+imprimir+', '+registro+', '+envioCom+')', 500);
}

function procesarPagina(txt, pagina, imprimir, registro, envioCom)
{
	var char=rescatarDatos(txt);
	var ultID=0;
	if (char!=null)
	{
		var elem=txt.substring(1, char);
		var x=elem.split(",");
		var nPage=pagina;
		if (x[0]!=0 && x[1]!=0)
		{
			nPage=parseInt(x[0]);
			foroPaginas=parseInt(x[1]);
			ultID=parseInt(x[2]);
			if (foroUltID<ultID)
				foroUltID=ultID;
		}
		if (nPage!=0)
		{
			registro=memoPagina(nPage);
			
			var txt1=txt.substring((char+1), txt.length);
			if (txt1!='' || (pagina==0 && registro==0) || !comPage[registro])
			{
				if (foroPaginas>nPage)
					completo=true;
				else
					completo=false;
				
				if (ultID!=0)
				{
					if (registro!=0)
						addMemo(registro, unescape(txt1), completo, ultID);
					else
						registro=addMemoPagina(nPage, unescape(txt1), completo, ultID);
				}
			}
			if (imprimir)
				impMemo(registro, envioCom);
		}
	}
}

function rescatarDatos(txt)
{
	if (txt.charAt(0)=="<")
	{
		for (var a=1;a<txt.length;a++)
		{
			if (txt.charAt(a)==">")
			{
				return a;
				break;
			}
		}
	}
	else
		return null;
}

//Conexion ajax:
function nuevoAjax()
{
	var xmlhttp=false;
	try
	{
		//creacion del objeto ajax para navegadores distintos a ie
		xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch (e)
	{
		try
		{
			//creacion del objeto ajax para ie
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch (E)
		{
			xmlhttp=false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
		xmlhttp=new XMLHttpRequest();

	return xmlhttp;
}

function get(obj)
{
	if (document.all)
		return document.all[obj];
	else if (document.getElementById)
		return document.getElementById(obj);
	else
		return null;
}

var Gesto=new Array(new RegExp);
var aGesto=new Array();
var Eti=new Array(new RegExp);
var HTML=new Array();
var malasP=new Array(new RegExp);
var Acentos=new Array(new RegExp);
var AcentosCambio=new Array();

Gesto[0]=/\[:\)\]/g; aGesto[0]='sonrisa.gif';
Gesto[1]=/\[:d\]/gi; aGesto[1]='risa.gif';
Gesto[2]=/\[;\)\]/g; aGesto[2]='guino.gif';
Gesto[3]=/\[:o\]/gi; aGesto[3]='sorpresa.gif';
Gesto[4]=/\[:p\]/gi; aGesto[4]='lengua.gif';
Gesto[5]=/\[:\@\]/g; aGesto[5]='enfadado.gif';
Gesto[6]=/\[:s\]/gi; aGesto[6]='confundido.gif';
Gesto[7]=/\[:\$\]/g; aGesto[7]='ruborizado.gif';
Gesto[8]=/\[:\(\]/g; aGesto[8]='triste.gif';
Gesto[9]=/\[:\'\(\]/g; aGesto[9]='lloron.gif';
Gesto[10]=/\[:\|\]/g; aGesto[10]='decepcionado.gif';
Gesto[11]=/\[8o\|\]/gi; aGesto[11]='dientes.gif';
Gesto[12]=/\[\|\)\]/g; aGesto[12]='dormido.gif';
Gesto[13]=/\[\(l\)\]/gi; aGesto[13]='corazon.gif';
Gesto[14]=/\[\(u\)\]/gi; aGesto[14]='corazonroto.gif';

Eti[0]=/\[e\]/g; HTML[0]='<tr><th align="left">Comentario de ';
Eti[1]=/\[e2\]/g; HTML[1]='<tr><th align="left">Respuesta de ';
Eti[2]=/\[e3\]/g; HTML[2]='<tr><th align="left">Comentario original de ';
Eti[3]=/\[\/e\]/g; HTML[3]=': <a href="javascript: revisar(';

Eti[4]=/\[\/m\]/g; HTML[4]=':</th><th align="right">';
Eti[5]=/\[\/m1\]/g; HTML[5]=': <a href="javascript: amarillo(';
Eti[6]=/\[\/m2\]/g; HTML[6]=': <a href="javascript: naranja(';
Eti[7]=/\[\/m3\]/g; HTML[7]=': <a href="javascript: rojo(';
Eti[8]=/\[\/m4\]/g; HTML[8]=': <img src="/imagenes/byn.gif" width="14" height="14" border="0" align="absmiddle"> <a href="javascript: borrar(';
Eti[9]=/\[\/m5\]/g; HTML[9]=': <img src="/imagenes/negro.gif" width="14" height="14" border="0" align="absmiddle"> <a href="javascript: borrar(';

Eti[10]=/\[f\]/g; HTML[10]=');"><img src="/imagenes/expulsar.gif" width="14" height="14" border="0" align="absmiddle"></th><th align="right">';
Eti[11]=/\[f1\]/g; HTML[11]=');"> <img src="/imagenes/amarilla.gif" width="14" height="14" border="0" align="absmiddle"> <a href="javascript: borrar(';
Eti[12]=/\[f2\]/g; HTML[12]=');"> <img src="/imagenes/naranja.gif" width="14" height="14" border="0" align="absmiddle"> <a href="javascript: borrar(';
Eti[13]=/\[f3\]/g; HTML[13]=');"> <img src="/imagenes/roja.gif" width="14" height="14" border="0" align="absmiddle"> <a href="javascript: borrar(';

Eti[14]=/\[\/f\]/g; HTML[14]='</th></tr>';
Eti[15]=/\[c\]/g; HTML[15]='<tr><td colspan="2" style="text-align: justify">';
Eti[16]=/\[\/c\]/g; HTML[16]='</td></tr>';
Eti[17]=/\[t\]/g; HTML[17]='<tr><td colspan="2" align="center"><table class="ForosR" cellpadding="0" cellspacing="0" border="0" width="100%">';
Eti[18]=/\[\/t\]/g; HTML[18]='</table></td></tr>';
Eti[19]=/\[r\]/g; HTML[19]='<tr><td id="r';
Eti[20]=/\[r1\]/g; HTML[20]='" colspan="2" align="right">&nbsp;</td></tr>';
Eti[21]=/\[r2\]/g; HTML[21]='" colspan="2" align="right"><a href="javascript: responder(';
Eti[22]=/\[\/r\]/g; HTML[22]=');\">Responder este comentario</a></td></tr>';
Eti[23]=/\[\/\]/g; HTML[23]='<br>';
Eti[24]=/\[b\]/gi; HTML[24]='<strong>';
Eti[25]=/\[\/b\]/gi; HTML[25]='</strong>';

malasP[0]=/(\Wp)ut[ao]s?(\W)/gi;
malasP[1]=/(\Wp)utaz[ao]s?(\W)/gi;
malasP[2]=/(\Wp)ut&oacute;n(\W)/gi;
malasP[3]=/(\Wp)uton[as]?[es]?(\W)/gi;
malasP[4]=/(\Wp)utit[oa]s?(\W)/gi;
malasP[5]=/(\Wp)ute[ao][rs]?(\W)/gi;
malasP[6]=/(\Wp)utean?[do]?(\W)/gi;
malasP[7]=/(\Wp)ute&oacute;(\W)/gi;
malasP[8]=/(\Wp)uter&iacute;[oa]s?(\W)/gi;
malasP[9]=/(\Wp)uteri[oa]s?(\W)/gi;

malasP[10]=/(\Wm)ierd\w*(\W)/gi;
malasP[11]=/(\Wp)ajer\w*(\W)/gi;
malasP[12]=/(\Wj)eropas?(\W)/gi;
malasP[13]=/(\Wf)orr[ao]s?(\W)/gi;
malasP[14]=/(\Wf)orrit[ao]s?(\W)/gi;
malasP[15]=/(\Wf)orra[sz][ao]s?(\W)/gi;
malasP[16]=/(\Ws)oret\w*(\W)/gi;

malasP[17]=/(\Wc)ag&aacute;s?(\W)/gi;
malasP[18]=/(\Wc)aga[nsr]?[tes]?(\W)/gi;
malasP[19]=/(\Wc)ag&oacute;n?(\W)/gi;
malasP[20]=/(\Wc)agon?[ea]?s?(\W)/gi;
malasP[21]=/(\Wc)agos?(\W)/gi;
malasP[22]=/(\Wc)agad[ao][re]?s?(\W)/gi;
malasP[23]=/(\Wc)agando(\W)/gi;
malasP[24]=/(\Wc)agadores(\W)/gi;
malasP[25]=/(\Wc)agadar[ln]os?(\W)/gi;
malasP[26]=/(\Wc)aga[rzs]o[sn]?(\W)/gi;
malasP[27]=/(\Wc)ague[ns]?(\W)/gi;
malasP[28]=/(\Wc)agu&eacute;s?(\W)/gi;
malasP[29]=/(\Wc)agaria[ns]?(\W)/gi;
malasP[30]=/(\Wc)agar&iacute;a[ns]?(\W)/gi;

malasP[31]=/(\Wp)elotud\w*(\W)/gi;

malasP[32]=/(\Wb)olud\w*(\W)/gi;

malasP[33]=/(\Wc)ulon?[es]?a?s?(\W)/gi;
malasP[34]=/(\Wc)ul&oacute;n(\W)/gi;
malasP[35]=/(\Wc)ulitos?(\W)/gi;

malasP[36]=/(\Wc)ul[ei]ad[ao]s?(\W)/gi;
malasP[37]=/(\Wc)ul[ei]aos?(\W)/gi;
malasP[38]=/(\Wc)ulea[rns]?(\W)/gi;
malasP[39]=/(\Wc)ul[ie]&aacute;s?[tes]?(\W)/gi;
malasP[40]=/(\Wc)ul[ie]ndo(\W)/gi;
malasP[41]=/(\Wc)ulee[ns]?(\W)/gi;
malasP[42]=/(\Wc)ul&eacute;e[ns]?(\W)/gi;

malasP[43]=/(\Wg)arch\w*(\W)/gi;
malasP[44]=/(\Wo)[gj]et\w*(\W)/gi;
malasP[45]=/(\Wo)rtos?(\W)/gi;

malasP[46]=/(\Wc)o[gj]e[nrs]?(\W)/gi;
malasP[47]=/(\Wc)o[gj]&eacute;s?(\W)/gi;
malasP[48]=/(\Wc)o[gj]id[oa]s?(\W)/gi;
malasP[49]=/(\Wc)o[gj]iendo(\W)/gi;
malasP[50]=/(\Wc)o[gj]&iacute;a[ns]?(\W)/gi;
malasP[51]=/(\Wc)o[gj]ete(\W)/gi;

malasP[52]=/(\Wp)edos?(\W)/gi;
malasP[53]=/(\Wp)edorr[ao]s?(\W)/gi;
malasP[54]=/(\Wch)upa[ns]?[me]? [unlos] huevos?(\W)/gi;
malasP[55]=/(\Wch)upa[ns]?[me]? [las] pelotas?(\W)/gi;
malasP[56]=/(\Wch)upa[ns]?[me]? [las] bolas?(\W)/gi;

malasP[57]=/(\Wc)onch[ud]?[it]?[ao]s?(\W)/gi;
malasP[58]=/(\Wc)ajetas?(\W)/gi;
malasP[59]=/(\Wc)ajetud[ao]s?(\W)/gi;
malasP[60]=/(\Wp)ijas?(\W)/gi;
malasP[61]=/(\Wp)ij&oacute;n[es]*(\W)/gi;
malasP[62]=/(\Wp)ijon[es]?(\W)/gi;
malasP[63]=/(\Wp)ija[sz]os?(\W)/gi;
malasP[64]=/(\Wv)ergas?(\W)/gi;
malasP[65]=/(\Wv)erg&oacute;n[es]?(\W)/gi;
malasP[66]=/(\Wv)ergon[es]?(\W)/gi;
malasP[67]=/(\Wv)erga[sz]os?(\W)/gi;
malasP[68]=/(\Wp)orongas?(\W)/gi;
malasP[69]=/(\Wp)orong&oacute;n[es]?(\W)/gi;
malasP[70]=/(\Wp)orongon[es]?(\W)/gi;
malasP[71]=/(\Wp)oronga[sz]os?(\W)/gi;
malasP[72]=/(\Wh)\.?d\.?p\.?(\W)/gi;

Acentos[0]=/à/g; AcentosCambio[0]='á';
Acentos[1]=/è/g; AcentosCambio[1]='é';
Acentos[2]=/ì/g; AcentosCambio[2]='í';
Acentos[3]=/ò/g; AcentosCambio[3]='ó';
Acentos[4]=/ù/g; AcentosCambio[4]='ú';
Acentos[5]=/À/g; AcentosCambio[5]='Á';
Acentos[6]=/È/g; AcentosCambio[6]='É';
Acentos[7]=/Ì/g; AcentosCambio[7]='Í';
Acentos[8]=/Ò/g; AcentosCambio[8]='Ó';
Acentos[9]=/Ù/g; AcentosCambio[9]='Ú';

