// PRUEBASSSSSSSS
function cambiar_cat(campo) {

	if (campo[0].checked == false) {
		valor = false;
	} else {
		valor = true;
	}
	for (i=1;i< campo.length;i++) {
		campo[i].checked = valor;
	}

}

function comprobar_cat(campo) {

	valor = true;
	for (i=1;i< campo.length;i++) {
		if (campo[i].checked == false) {
			valor = false;
		} 
	}
	campo[0].checked = valor;
}
////////////////////////////////////


function cambiar_capa(capa) {

	if (document.getElementById(capa).style.display == "none") {
		document.getElementById(capa).style.display = "block"	
	} else {
		document.getElementById(capa).style.display = "none"
	}
}

function mostrar_capa(capa) {
	document.getElementById(capa).style.display = "block"
	//showObject(capa);	
}

function ocultar_capa(capa) {
	document.getElementById(capa).style.display = "none";
	//hideObject(capa);
}





//////////////////////////////////////////////////////////
// FUNCIONES DE LA PREVISUALIZACIÓN DE LOS COMENTARIOS: //
//////////////////////////////////////////////////////////

function previsualizar_datos() { //ejecutar la función cuando cargamos la páina, por si ya hay datos dentro que se rellene... también cuando pulsemos sobre "limpiar" o "reestablecer"....
	
	Nombre = document.getElementById('Nombre').value;
	Mail = document.getElementById('Mail').value;
	Web = document.getElementById('Web').value;

	if (document.getElementById('Mostrar_nombre').checked == false || Nombre == "" ) {
		Nombre = '"Cobarde Anónimo"';
	}
	
	cadena = 'Enviado por <b>';

	if (Web != "") {
		// aquí tenemos que mirar si la caden tiene http:// o https:// o algo de eso......
		cadena = cadena + '<a href="'+ Web +'" target="_blank" title="Link Externo: '+ Web +'">'+ Nombre +'</a>';
		
	} else {
		cadena = cadena + Nombre;
	}

	cadena = cadena + '</b> el ';

	// podemos mirar el tema de incluir la fecha como se mostrará en el comentario (con dí de la semana y nombre del mes.....), o por lo menos cambiar el formato de los nmeros.... (sale 1:2 y esas cosas)


var Nombre_mes = new Array();
var Nombre_dia = new Array();

Nombre_mes[1] = "Enero";
Nombre_mes[2] = "Febrero";
Nombre_mes[3] = "Marzo";
Nombre_mes[4] = "Abril";
Nombre_mes[5] = "Mayo";
Nombre_mes[6] = "Junio";
Nombre_mes[7] = "Julio";
Nombre_mes[8] = "Agosto";
Nombre_mes[9] = "Septiembre";
Nombre_mes[10] = "Octubre";
Nombre_mes[11] = "Noviembre";
Nombre_mes[12] = "Diciembre";


Nombre_dia[0] = "Domingo";
Nombre_dia[1] = "Lunes";
Nombre_dia[2] = "Martes";
Nombre_dia[3] = "Miércoles";
Nombre_dia[4] = "Jueves";
Nombre_dia[5] = "Viernes";
Nombre_dia[6] = "Sábado";




	hoy = new Date;
	
	if (hoy.getDate() < 10) {
		dia = '0' + hoy.getDate();
	} else {
		dia = hoy.getDate();
	}
	
	if (hoy.getHours() < 10) {
		horas = '0' + hoy.getHours();
	} else {
		horas = hoy.getHours();
	}
	
	if (hoy.getMinutes() < 10) {
		minutos = '0' + hoy.getMinutes();
	} else {
		minutos = hoy.getMinutes();
	}
	
	mes = hoy.getMonth()+1;
	dia_semana = hoy.getDay();
	
	fecha = Nombre_dia[dia_semana] + ' ' + dia + ' de ' + Nombre_mes[mes] + ' del ' + hoy.getFullYear();
	//fecha = hoy.getDate() + '/' + mes + '/' + hoy.getFullYear();
   hora = horas + ':' + minutos;

	cadena = cadena + fecha + ' a las ' + hora;

	document.getElementById('pre_datos').innerHTML = cadena;
}

function previsualizar_texto() {

	Texto = document.getElementById('texto_Comentario').value;

	//HAY QUE QUITAR TODOS LOS TAGS HTML
	Texto = Texto.replace(/</g,'&lt;');
	Texto = Texto.replace(/>/g,'&gt;');


	//retocar todo esto, y hacer que tambien pille con mayusculas.................
	Texto = Texto.replace(/\n/g,'<br />');
	Texto = Texto.replace(/\[b\](.*?)\[\/b\]/g,'<b>$1</b>');
	Texto = Texto.replace(/\[i\](.*?)\[\/i\]/g,'<i>$1</i>');
	Texto = Texto.replace(/\[u\](.*?)\[\/u\]/g,'<u>$1</u>');
	Texto = Texto.replace(/\[code\](.*?)\[\/code\]/g,'<code>$1</code>');
	Texto = Texto.replace(/\[pre\](.*?)\[\/pre\]/g,'<pre>$1</pre>');
	//Texto = Texto.replace(/\[link=(.*?)\](.*?)\[\/link\]/g,'<a href="$1">$2</a>');
	

	document.getElementById('pre_comentario').innerHTML = Texto;
}
