var host = document.location.href.substring(7,document.location.href.length);
http_host = host.substring(0,host.indexOf("/"));

function agregatag(id,fecha,nick,mensaje) {
	if(typeof(mensajes_tag_id) == 'undefined') {
		mensajes_tag_id = new Array();
		mensajes_tag_fecha = new Array();
		mensajes_tag_nick = new Array();
		mensajes_tag_mensaje = new Array();		
	}
	mensajes_tag_id.push(id);
	mensajes_tag_fecha.push(fecha);
	mensajes_tag_nick.push(nick);
	mensajes_tag_mensaje.push(mensaje);	
}
function mandatag() {
	var donde = document.getElementById('tagmens');
	if (document.getElementById('tapamensajes') != null) { 
		var fondo = document.getElementById('tapamensajes'); 
		donde.removeChild(fondo);
		if(document.getElementById('ponnuevomensaje') != null) {
			donde.removeChild(document.getElementById('ponnuevomensaje'));
		}
		return;
	}
	var fondo = document.createElement("div");
	fondo.setAttribute("id", "tapamensajes");
	var mensaje = document.createElement("div");
	mensaje.setAttribute("id", "ponnuevomensaje");
	donde.appendChild(fondo);
	donde.appendChild(mensaje);
	carga('extremidades/inicio/agregatag.php','ponnuevomensaje');
}
function agregando_tag(que,donde){
	if ((que == "Nick") || (que == "Mensaje")) { donde.value = ''; }
	if (que == "Enviar") { 
	var nick = escape(document.getElementsByName('tag_nick')[0].value);
	var mensaje = escape(document.getElementsByName('tag_mensaje')[0].value);
	if ((nick == "Nick") || (nick == "")) { document.getElementsByName('tag_nick')[0].style.background = 'red'; } else { document.getElementsByName('tag_nick')[0].style.background = '#005E5E'; };
	if ((mensaje == "Mensaje") || (mensaje == "")) { document.getElementsByName('tag_mensaje')[0].style.background = 'red'; } else { document.getElementsByName('tag_mensaje')[0].style.background = '#005E5E'; }
	if ((nick == "Nick") || (nick == "") || (mensaje == "Mensaje") || (mensaje == "")) { return; }
	var nuevomensaje = mensaje.replace(/%0A/g,"<br />");
	cargapost('extremidades/inicio/nuevotag.php','nada','nick='+nick+'&mensaje='+nuevomensaje+'','nocarga');
	mandatag();
	}
}
function avientatagboard() {
	var donde = document.getElementById('tagboard_bloque_contenido');
	var tagmens = document.createElement("div");
	tagmens.setAttribute("id", "tagmens");
	donde.appendChild(tagmens);
	var mentags = document.createElement("div");
	mentags.setAttribute("id", "mentags");
	mentags.setAttribute("title", "Da click aqui para dejar un mensaje");
	mentags.setAttribute("onclick", "mandatag();");
	var mentags2 = document.createElement("div");
	mentags2.setAttribute("id", "mentags2");
	mentags.appendChild(mentags2);
	tagmens.appendChild(mentags);		
	var letagboard = document.createElement("div");
	letagboard.setAttribute("id", "el_tagboard");
	donde.appendChild(letagboard);
	mensajes_tag_id.reverse();
	mensajes_tag_fecha.reverse();
	mensajes_tag_nick.reverse();
	mensajes_tag_mensaje.reverse();		
	for(var x = 0; x < mensajes_tag_id.length; x++) {
	sacanuevotag(mensajes_tag_id[x],mensajes_tag_fecha[x],mensajes_tag_nick[x],mensajes_tag_mensaje[x]);
	}
	buscandotags = setTimeout("buscanuevotag();", 30000);
}
function sacanuevotag(id,fecha,nick,mensaje) {
	var donde = document.getElementById('el_tagboard');
	eval("var tag_" + id + " = document.createElement(\"div\")");
	eval("tag_" + id + ".setAttribute(\"class\", \"mensaje_tag\")");
	eval("tag_" + id + ".setAttribute(\"id\", \"" + id + "\")");
	var la_cabeza = document.createElement("div");
	la_cabeza.setAttribute("class", "la_cabeza");
	var el_nick = document.createElement("div");
	var la_fecha = document.createElement("div");
	var el_mensaje = document.createElement("div");
	el_nick.setAttribute("class", "mensaje_tag_nick");
	la_fecha.setAttribute("class", "mensaje_tag_fecha");
	el_mensaje.setAttribute("class", "mensaje_tag_mensaje");	
	var texto_nick = document.createTextNode(nick);
	var texto_fecha = document.createTextNode(fecha);
	var texto_mensaje = document.createTextNode(mensaje);
	el_nick.appendChild(texto_nick);
	la_fecha.appendChild(texto_fecha);
	mensaje = mensaje.replace(/&lt;br \/&gt;/gi,"<br>");
	el_mensaje.innerHTML = mensaje;
	la_cabeza.appendChild(el_nick);
	la_cabeza.appendChild(la_fecha);
	eval("tag_" + id + ".appendChild(la_cabeza)");
	eval("tag_" + id + ".appendChild(el_mensaje)");
	eval("donde.insertBefore(tag_" + id + ", donde.firstChild)");
}
function crece(cual,cuanto) {
	eval("" + cual + "_espera = 0");
	eval("if (typeof(" + cual + "_encoje) != 'undefined') { clearTimeout(" + cual + "_encoje); }");		
	var mide = document.getElementById(cual).clientHeight;
	if (mide < cuanto) {
		var aumenta = mide + 20;
		document.getElementById(cual).style.height = aumenta+'px';
		eval("" + cual + "_crecedor = setTimeout(function() {crece(cual,cuanto)},1)");		
	} else { eval("clearTimeout(" + cual +"_crecedor)"); document.getElementById(cual).style.overflow = 'visible'; };
}
function esperaencoje(cual,cuanto) {
	eval("" + cual + "_encoje = setTimeout(function() { "+ cual +"_espera = 1; encoje(cual,cuanto);}, 100)");
}
function encoje(cual,cuanto) {
	if(eval("" + cual + "_espera == 0")) { esperaencoje(cual,cuanto); } else {
	document.getElementById(cual).style.overflow = 'hidden';
	eval("if (typeof(" + cual + "_crecedor) != 'undefined') { clearTimeout(" + cual + "_crecedor); }");	
	var mide = document.getElementById(cual).clientHeight;
	if (mide > cuanto) {
		var aumenta = mide - 20;
		document.getElementById(cual).style.height = aumenta+'px';
		eval("" + cual + "_encoje = setTimeout(function() {encoje(cual,cuanto)},1)");
	} else { eval("clearTimeout(" + cual + "_encoje)"); };
	}
}
function totaltag(cuantos) {
	document.getElementById('tagboard_bloque_tittext').firstChild.nodeValue = 'Mensajes '+cuantos;
}

window.onscroll = function() {
	var explorador = navigator.userAgent;
	if (explorador.indexOf("MSIE") != -1) {
		muevey = document.documentElement.scrollTop;
		muevex = document.documentElement.scrollLeft;
	} else {
		muevey = window.scrollY;
		muevex = window.scrollX;
	}
	if (document.getElementById('menu_perfiles') != null) {
		document.getElementById('menu_perfiles').style.top = muevey + 'px';
	}
}
function accediendo(regresar_a) {
	var nick = document.acceder.nick_logueo;
	var pass = document.acceder.pass_logueo;
	var mensajes = document.getElementById('mensajes_logueo');
	if (nick.value == "") { nick.style.background = 'red'; mensajes.firstChild.nodeValue = 'Por favor pon tu NICK'; } else { nick.style.background = '#005E5E'; }
	if (pass.value == "") { pass.style.background = 'red'; mensajes.firstChild.nodeValue = 'Por favor pon tu CLAVE'; } else { pass.style.background = '#005E5E'; }
	if ((nick.value == "") && (pass.value == "")) { mensajes.firstChild.nodeValue = 'Por favor pon tu NICK y tu CLAVE'; }
	if ((nick.value == "") || (pass.value == "")) { return; }
	mensajes.firstChild.nodeValue = 'Comprobando tus datos';
	ajax = nouAjax();
	ajax.open('POST','cerebello/carrera/letrou.php?randomea='+Math.round(Math.random()*9999)+'', true);
	ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   	ajax.onreadystatechange = function() {	
    	if (ajax.readyState < 4) {
			mensajes.firstChild.nodeValue = 'Conexion establecida, esperando.';
    	}
		if (ajax.readyState == 4) {
			var respuesta = ajax.responseText;
			mensajes.firstChild.nodeValue = respuesta;
			if (respuesta.indexOf("Bienvenid@") != -1) {
				setTimeout(function() { if (document.cookie.indexOf('usuario') != -1) { mensajes.firstChild.nodeValue = 'Cookie creada con éxito. Redireccionando.'; setTimeout(function()  { if (regresar_a == "") { document.location.href = 'http://' + http_host + '/'; } else { document.location.href = regresar_a; }; }, 3000); } else { mensajes.firstChild.nodeValue = 'Lo sentimos. Al parecer no se pudo crear tu cookie de acceso. Por favor agrega The ViP ZoNe a tus sitios de confianza.'; }; }, 2000);
			}
		}
	}
	ajax.send('nick='+escape(nick.value)+'&clave='+escape(pass.value)+'');
	return false;
}
function titulo_pagina(cual) {
	document.title = cual;
}
function interperf(que,extra) {
	if ( document.cookie.indexOf('usuario') == -1) { alerta('Necesitas ACCEDER para poder interactuar con los perfiles'); return; }
	document.getElementById('mensaje_perf').style.display = 'none';
	if ( que == "lapiz_menu" ) { document.getElementById('mensaje_perf').style.display = 'block'; } 
	if ( que == "www_menu" ) { window.open(extra); }
	if ( que == "configuracion_menu") { document.location.href = 'http://' + http_host + '/configuracion'; }
}
function mensajeaperfil() {
	var mensaje = document.mensaje_perfil.mensaje_perf_mensaje;
	if ( mensaje.value == "" ) { mensaje.style.background = 'red'; setTimeout(function() { mensaje.style.background = '#FFF' }, 1000); return false; }
}
function cierra_mensaje_perf() {
	document.getElementById('mensaje_perf').style.display = 'none';
}
function alerta(que,titulo) {
	if (typeof(titulo) == "undefined") { var letitre = 'Error'; } else { var letitre = titulo; }
	if(document.getElementById('fondo_alerta') != null) {
		document.getElementsByTagName('body')[0].removeChild(document.getElementById('fondo_alerta'));
		document.getElementsByTagName('body')[0].removeChild(document.getElementById('mensaje_alerta'));
		document.getElementsByTagName('body')[0].style.overflow = 'auto';		
	} else {
		var explorador = navigator.userAgent;
		if (explorador.indexOf("MSIE") != -1) {
			muevey = document.documentElement.scrollTop;
			muevex = document.documentElement.scrollLeft;
		} else {
			muevey = window.scrollY;
			muevex = window.scrollX;
		}
		var cuerpo = document.getElementsByTagName('body')[0];
		var ancho = (document.documentElement.clientWidth + 20);
		var alto = (document.documentElement.clientHeight + 20);		
		var fondo_alerta = document.createElement("div");
		fondo_alerta.setAttribute("id", "fondo_alerta");
		fondo_alerta.setAttribute("style", "top:"+muevey+"px; left:"+muevex+"px; width:"+ancho+"px; height:"+alto+"px;");
		var mensaje_alerta = document.createElement("div");
		mensaje_alerta.setAttribute("id", "mensaje_alerta");
		mensaje_alerta.setAttribute("style", "top:"+(((alto/2)-70) + muevey)+"px; left:"+(((ancho/2)-250) + muevex)+"px;");		
		var mensaje_alerta_arriba = document.createElement("div");
		mensaje_alerta_arriba.setAttribute("id", "mensaje_alerta_arriba");
		mensaje_alerta.appendChild(mensaje_alerta_arriba);
		var mensaje_alerta_titulo = document.createElement("div")
		mensaje_alerta_titulo.setAttribute("id", "mensaje_alerta_titulo");
		mensaje_alerta_arriba.appendChild(mensaje_alerta_titulo);
		var titulo = document.createTextNode(letitre);
		mensaje_alerta_titulo.appendChild(titulo);
		var mensaje_alerta_cerrar = document.createElement("div");
		mensaje_alerta_cerrar.setAttribute("id", "mensaje_alerta_cerrar");
		mensaje_alerta_cerrar.setAttribute("onclick", "alerta();");
		var cerrar = document.createTextNode("X");
		mensaje_alerta_cerrar.appendChild(cerrar);
		mensaje_alerta_arriba.appendChild(mensaje_alerta_cerrar);		
		var mensaje_alerta_la_alerta = document.createElement("div");
		mensaje_alerta_la_alerta.setAttribute("id", "mensaje_alerta_la_alerta");
		mensaje_alerta.appendChild(mensaje_alerta_la_alerta);
		mensaje_alerta_la_alerta.innerHTML = que;
		cuerpo.appendChild(fondo_alerta);
		cuerpo.appendChild(mensaje_alerta);
		var ancho_alerta = document.getElementById('mensaje_alerta').clientWidth;
		cuerpo.style.overflow = 'hidden';
		//alerta_ancho();		
	}
}
function busca(que,tecla) {
	//var latecla = window.event ? tecla.keyCode : tecla.which;
	if (que.length > 2) {
		//if (latecla == 40) { document.getElementById('resultados_busqueda').focus(); }
		document.getElementById('resultados_busqueda').style.display = 'block';		
		cargapost('http://' + http_host + '/cerebello/carrera/busqueda.php','resultados_busqueda','busca=' + escape(que));
	} else {
		document.getElementById('resultados_busqueda').style.display = 'none';
	}
}
function quitabusca() {
	setTimeout(function() { document.getElementById('resultados_busqueda').style.display = 'none'; }, 1000);
}
function visitaperfil(cual) {
	document.location.href = 'http://' + http_host +'/p/'+cual;
}
function buscanuevotag() {
	if (typeof(buscandotags) != 'undefined') { clearTimeout(buscandotags); };
	var eltag = document.getElementById('el_tagboard').childNodes[0].id;
	carga('http://' + http_host + '/extremidades/inicio/checatags.php?id=' + eltag + '','nada','nocarga');
	buscandotags = setTimeout("buscanuevotag();", 30000);
}
function checa_registro(que) {
	var simbolos = /[*.+°¬~¨='"´;:,#$%&()\/\?¿¡!]/;
	var enes = /[ñÑ]/;
	var corrreo = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var espacios = /[ ]/;
	var acentos = /[áéíóúÁÉÍÓÚàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛäëïöüÄËÏÖÜ]/;
	var nick = document.registro.nick;
	var clave = document.registro.clave;
	var clave2 = document.registro.clave2;	
	var correo = document.registro.correo;
	var mensaje = document.getElementById('registro_res');	
	if (nick.value.length < 3) {
		mensaje.innerHTML = 'Tu Alias debe contener m&aacute;s de 2 car&aacute;cteres.';
		nick.style.background = 'red';
	   document.registro.enviar.disabled = true;		
		return;		
	}
	if (espacios.test(nick.value)) {
		mensaje.innerHTML = 'No permitimos espacios en los alias.';
		nick.style.background = 'red';
	   document.registro.enviar.disabled = true;
		return;		
	}	
	if (simbolos.test(nick.value)) {
		mensaje.innerHTML = 'Lo sentimos, no permitimos "*.+°¬\'~¨="´;:,#$%&()\/\?¿¡!" en los alias.';
		nick.style.background = 'red';
	   document.registro.enviar.disabled = true;		
		return;
	}
	mensaje.innerHTML = '';
	nick.style.background = 'green';
	if (que == "nick") {
		cargapost('http://' + http_host + '/extremidades/puerta/checanick.php','registro_res','nick=' + escape(nick.value));
	}
	if (clave.value == "") {
		clave.style.background = 'red';
		return;
	} 
	if (clave2.value == "") {
		clave2.style.background = 'red';
		return;
	} else {
		if (clave.value != clave2.value) { 
		mensaje.innerHTML = 'Tus claves no coinciden'; 
		clave.style.background = 'red'; 
		clave2.style.background = 'red';
	   	document.registro.enviar.disabled = true;		
		return;
		} else { clave.style.background = 'green'; clave2.style.background = 'green'; }
	}
	if (correo.value == "") {
		correo.style.background = 'red';
	   	document.registro.enviar.disabled = true;		
		return;		
	}
	if (corrreo.test(correo.value)) {
		correo.style.background = 'green';		
		mensaje.innerHTML = '';
	} else { 
		correo.style.background = 'red';
	  	mensaje.innerHTML = 'Tu correo no parece estar bien formado. Recuerda que es necesario para avisos o recuperar tu clave.';
	 	document.registro.enviar.disabled = true;
	   	return;
	}
	cargapost('http://' + http_host + '/extremidades/puerta/checanick.php','registro_res','nick=' + escape(nick.value),'nocarga');	
	document.registro.enviar.disabled = false;
	document.registro.enviar.style.background = 'green';
	if (que == "enviar") {
		cargapost('http://' + http_host + '/extremidades/puerta/checanick.php','registro_res','elnick=' + escape(nick.value) + '&laclave=' + escape(clave.value) + '&elcorreo=' + escape(correo.value));
		document.registro.enviar.disabled = true;
		document.registro.enviar.style.background = '#CCC';
	}
}
function confperf(que) {
	document.getElementById('resultados_conf').innerHTML = '';
	if (que == "misdatos") { carga('/usuarios/misdatos.php','datos_conf_perfil'); }
	if (que == "misimagenes") { carga('/usuarios/misimagenes.php','datos_conf_perfil'); }
	if (que == "mispreferencias") { carga('/usuarios/mispreferencias.php','datos_conf_perfil'); }
	if (que == "miclave") { carga('/usuarios/miclave.php','datos_conf_perfil'); }	
}
function cambiosusuario(seccion) {
	if (seccion == "misdatos") { 
		var alias = escape(document.getElementById('conf_usuario').value);
		var correo = escape(document.getElementById('conf_correo').value);
		var nacio = escape(document.getElementById('conf_nacio').value);		
		var vive = escape(document.getElementById('conf_vive').value);
		var dia = escape(document.getElementById('conf_dia').value);
		var mes = escape(document.getElementById('conf_mes').value);
		var ano = escape(document.getElementById('conf_ano').value);		
		var dia = escape(document.getElementById('conf_dia').value);
		var url1 = escape(document.getElementById('conf_url1').value);
		var acercade = escape(document.getElementById('conf_acercade').value);
		var hobby = escape(document.getElementById('conf_hobby').value);
		parametros = 'alias='+alias+'&correo='+correo+'&nacio='+nacio+'&vive='+vive+'&dia='+dia+'&mes='+mes+'&ano='+ano+'&url1='+url1+'&acercade='+acercade+'&hobby='+hobby+'';
		cargapost('/usuarios/misdatos.php','resultados_conf',parametros);
	}
}
function checalias(nick) {
	var simbolos = /[*.+°¬~¨='"´;:,#$%&()\/\?¿¡!]/;
	var espacio = /[ ]/;
	if(simbolos.test(nick)) { document.getElementById('resultados_conf').innerHTML = 'No permitimos "*.+°¬\'~¨="´;:,#$%&()\/\?¿¡!" en los alias.<br>Recuerda que si cambias tu alias, tambi&eacute;n cambiar&aacute; la direcci&oacute;n de tu perfil.';
	return;
	}
	if(espacio.test(nick)) {  document.getElementById('resultados_conf').innerHTML = 'No permitimos espacios en los alias.<br>Recuerda que si cambias tu alias, tambi&eacute;n cambiar&aacute; la direcci&oacute;n de tu perfil.';
	return;
	}
	var elnick = escape(nick);
	cargapost('../usuarios/checanick.php','resultados_conf','nick='+elnick);
}
function desactivarcambiodatos() {
	document.getElementById('manda1').disabled = true; 
	document.getElementById('manda2').disabled = true;
}
function activarcambiodatos() {
	document.getElementById('manda1').disabled = false; 
	document.getElementById('manda2').disabled = false;	
}
function accionfoto(que,cual) {
	if (que == "mostrar") { var parametros = "accion=mostrar&cual="+cual; }
	if (que == "esconder") { var parametros = "accion=esconder&cual="+cual; }
	if (que == "borrar") { var parametros = "accion=borrar&cual="+cual; }
	if (que == "cambiar") {
		var titulo = escape(document.getElementById('titulo_foto_'+cual).value);
		var descripcion = escape(document.getElementById('descripcion_foto_'+cual).value);
		var parametros = "accion=cambiar&cual="+cual+"&titulo="+titulo+"&descripcion="+descripcion;
	}
	cargapost('http://' + http_host + '/usuarios/cambiofoto.php','fotos_resultados',parametros);		
}
function checa_la_foto() {
	var foto = document.subiendo_la_foto.archivo.value;
	if (foto == "") { alerta('Por favor selecciona una imagen'); return false; }
	var extension = foto.substring((foto.lastIndexOf('.') + 1),foto.length);
	if ((extension.toLowerCase() != "jpg") && (extension.toLowerCase() != "jpeg")) {
		alerta('Solo aceptamos imagenes tipo JPG');
		return false;
	}
	document.subiendo_la_foto.submit();
}
function colorcambiofocus(cual) {
	color_cambio_focus = cual;
}
function selcolor(cual) {
	document.getElementById(color_cambio_focus).value = cual;
	document.getElementById(color_cambio_focus).style.background = cual;	
}
function abreforo(id,tipo) {
	document.location.href = 'http://'+http_host+'/foro/'+tipo+'/'+id+'';
}
function ontoy(blah) {
	document.getElementById('foro_estoy').innerHTML = blah;
}
function editamens(id) {
	cargapost('http://'+http_host+'/extremidades/perfiles/editarm.php','mensaje_'+id,'id='+id);
}
function editaresp(id) {
	cargapost('http://'+http_host+'/extremidades/foro/editaresp.php','resp_'+id,'id='+id);
}
function meditado(id) {
	var contenido = escape(document.getElementById('editando_'+id).value);
	cargapost('http://'+http_host+'/extremidades/perfiles/editarborrarm.php','mensaje_'+id,'id='+id+'&accion=editar&mensaje='+contenido);
}
function respeeditar(id) {
	var contenido = escape(document.getElementById('respu_'+id).value);
	cargapost('http://'+http_host+'/extremidades/foro/editarborrarm.php','resp_'+id,'id='+id+'&accion=editar&mensaje='+contenido);
}
function borrarmens(id) {
	cargapost('http://'+http_host+'/extremidades/perfiles/editarborrarm.php','mensaje_'+id,'id='+id+'&accion=borrar');
}
function borraresp(id) {
	cargapost('http://'+http_host+'/extremidades/foro/editarborrarm.php','resp_'+id,'id='+id+'&accion=borrar');
}
function ocultamens(id) {
	document.getElementById('mcon_'+id).style.display = 'none';
}
function ocultaresp(id) {
	document.getElementById('respuesta_'+id).style.display = 'none';
}
function nuevo_tema(sec) {
	carga("http://"+http_host+"/extremidades/foro/agredit.php?cat="+sec+"","nt_contenedor");
}
function feditor_hazlo(idsup,cat) {
	var titulo = escape(document.getElementById('feditor_titulo').value);
	var correo = escape(document.getElementById('feditor_correo').value);	
	var contenido = escape(document.getElementById('feditor_contenido').value);
	var avisos = document.getElementById('feditor_avisos').checked;
	var permisos = document.getElementById('feditor_perver').checked;
	if (titulo == "") {
		alerta("Por favor, agrega el título de tu tema.");
		return; 
	};
	if (contenido == "") {
		alerta("Por favor, agrega el contenido a tu tema");
		return;
	};
	var ca = escape(cat);
	var ids = escape(idsup);	
	cargapost("http://"+http_host+"/extremidades/foro/agregatema.php","","ids="+ids+"&cat="+ca+"&permisos="+permisos+"&avisos="+avisos+"&titulo="+titulo+"&correo="+correo+"&contenido="+contenido,"nocarga");
}
function feditor_vista(n) {
	var contenido = document.getElementById('feditor_contenido').value;
	var input = document.getElementById('feditor_contenido');
	var con = document.getElementById('feditor_vp');
	if (n == 0) { con.innerHTML = ''; con.style.display = 'none'; input.style.display = 'block';  }
	if (n == 1) { 
		con.innerHTML = contenido.replace(/\n\r?/g,'<br>');  
		input.style.display = 'none'; 
		con.style.display = 'block';
	}
}
function feditor_insertar(que) {
	feditor_vista(0);
	if (que == "enlace") { 
		alerta('Escribe la direcci&oacute;n completa del enlace:<br><input type="text" id="feditor_enlace" style="width:450px"><br>Titulo del enlace:<br><input type="text" id="feditor_titen" style="width:450px"><br><input type="button" onclick="feditor_enlace(document.getElementById(\'feditor_enlace\').value,\'enlace\',document.getElementById(\'feditor_titen\').value);" value="Insertar">','Insertar Enlace');
	}
	if (que == "imagen") { 
		alerta('Escribe la direcci&oacute;n completa de la im&aacute;gen:<br><input type="text" id="feditor_enlace" style="width:450px"><br>Ancho (opcional):<input type="text" id="feditor_iman" style="width:100px">&nbsp;&nbsp;Alto (opcional):<input type="text" id="feditor_imal" style="width:100px"><br><input type="button" onclick="feditor_enlace(document.getElementById(\'feditor_enlace\').value,\'imagen\',document.getElementById(\'feditor_iman\').value,document.getElementById(\'feditor_imal\').value);" value="Insertar">','Insertar Imágen');
	}
	if (que == "youtube") { 
		alerta('Pega o escribe la direcci&oacute;n del video:<br><input type="text" id="feditor_youtube" style="width:450px"><br><input type="button" onclick="feditor_enlace(document.getElementById(\'feditor_youtube\').value,\'youtube\');" value="Insertar">','Insertar Video de Youtube');
	}	
}
function feditor_enlace(contenido,tipo,a,b) {
	alerta();
	if (tipo == "enlace") {
		if (contenido == "") { return; };
		var buscar = /http:/;
		if (buscar.test(contenido) == true) { contenido = contenido; } else { contenido = "http://"+contenido; };
		if (a == "") { a = contenido; }
		var que = "<a href=\""+contenido+"\" target=\"_blank\">"+a+"</a>";
	}
	if (tipo == "imagen") {
		if (contenido == "") { return; };
		if (a != "") { var ancho = " width=\""+a+"\""; } else { var ancho = ""; }
		if (b != "") { var alto = " height=\""+b+"\""; } else { var alto = ""; }
		var que = "<img src=\""+contenido+"\""+ancho+alto+">";
	}
	if (tipo == "youtube") {
		if (contenido == "") { return; };
		if (contenido.indexOf('&') == "-1") { var hasta = contenido.length; } else { var hasta = contenido.indexOf('&'); }
		var de = contenido.indexOf('=')+1;
		var cuanto = hasta - de;
		var video = contenido.substr(de,cuanto);
		var que = '<embed src="http://www.youtube.com/v/'+video+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="301"></embed>'
	}
	document.getElementById('feditor_contenido').value = document.getElementById('feditor_contenido').value+que;
}
function nueva_respuesta_tema() {
	document.getElementById('nueva_respuesta').style.display = 'block';
}
function mocul_feditorco(estado) {
	if(estado == true) { document.getElementById('feditor_acorreo').style.display = 'block'; } else { document.getElementById('feditor_acorreo').style.display = 'none'; }
}
function nufores(cual) {
	var contenido = escape(document.getElementById('respondiendo').value);
	if (contenido == "") { return; }
	var avisos = document.getElementById('respavisos').checked;
	var correo = escape(document.getElementById('foresco').value);
cargapost("http://"+http_host+"/extremidades/foro/respuesta.php","respuestas_tema","id="+cual+"&avisos="+avisos+"&correo="+correo+"&contenido="+contenido);
}
function foreditar(cual) {
	cargapost("http://"+http_host+"/extremidades/foro/agredit.php","el_post_foro","t="+escape(cual));
}