function flotar(event, tipo){
	tipo = "globo_"+tipo;
	imagen = document.getElementById(tipo);
	imagen.style.visibility = "visible";
	y = event.pageY;
	y = y-78;
	imagen.style.top = y+"px";
	x = event.pageX;
	x = x-48;
	imagen.style.left = x+"px";
}

function desflotar(tipo){
	tipo = "globo_"+tipo;
	imagen = document.getElementById(tipo);
	imagen.style.visibility = "hidden";
}

function precarga(){
/*
	var i;
	var imagenes = new Array("imagen2.gif","imagen3.gif");
	var lista_imagenes = new Array();

	for(i in imagenes){
	lista_imagenes[i] = new Image();
	lista_imagenes[i].src = imagenes[i];
	}*/
}

function rollover(tipo){
	imagen = document.getElementById(tipo);
	imagen.src = "images/"+tipo+"2.png";
	
}

function rolloverOff(tipo){
	imagen = document.getElementById(tipo);
	imagen.src = "images/"+tipo+".png";
	
}

function limpiarCampo(valor){
	var campo;
	campo = document.getElementById(valor);
	if(
	(campo.value=="Usuario"&&valor=="nick")||
	(campo.value=="xxxxxx"&&valor=="password")
	){
	campo.value="";
	}
}

function limpiarCampo2(valor){
	var campo;
	campo = document.getElementById(valor);
	if(
	(campo.value=="Introduce tu contraseña"&&valor=="password_r")||
	(campo.value=="Confirma la contraseña"&&valor=="password_r2"))
	{
		campo.type="password";
	}
	if(
	(campo.value=="Nombre de usuario"&&valor=="nick_r")||
	(campo.value=="Correo electrónico"&&valor=="email_r")||
	(campo.value=="Introduce tu contraseña"&&valor=="password_r")||
	(campo.value=="Confirma la contraseña"&&valor=="password_r2")||
	(campo.value=="Buscar en elreino.net"&&valor=="busca")||
	(campo.value=="Buscar en el foro"&&valor=="busqueda_foro")
	){
	campo.value="";
	campo.style.color="#545454";
	}
	if(
	(campo.value=="Título del tema"&&valor=="titulo")
	){
	campo.value="";
	campo.style.color="black";
	}
}

function registro(){
	ajaxRegistro();
	var popup,fondo_oculto;
	popup = document.getElementById("popup");
	popup.style.visibility = "visible";
	fondo_oculto = document.getElementById("fondo_oculto");
	fondo_oculto.style.visibility = "visible";
}
function cerrarPopup(){
	var popup,fondo_oculto;
	popup = document.getElementById("popup");
	popup.style.visibility = "hidden";
	fondo_oculto = document.getElementById("fondo_oculto");
	fondo_oculto.style.visibility = "hidden";
}
function registroCondiciones(){
	var imagen = document.getElementById("registro_checkbox_img");
	var hidden = document.getElementById("registro_checkbox_hidden");
	if (hidden.value == 0) {
		imagen.src = "images/registro_checkbox_on.png";
		hidden.value="1";
	}else{
		imagen.src = "images/registro_checkbox.png";
		hidden.value="0";
		
	}
}
function precargaRegistro(){

	var imagen = new Image();
	imagen.src = "images/registro_checkbox_on.png";
	
}
function pestana(cat){
	div = document.getElementById(cat);
	div.className = "pestaña_juego_on";
	
}
function pestanaOff(cat){
	div = document.getElementById(cat);
	div.className = "pestaña_juego_off";
}
function ocultarDiv(id){
	var div = document.getElementById(id);
	if(div.style.display=="block")
		div.style.display = "none";
	else
		div.style.display = "block";
}
function imagen(imagen,juego){
	ajaxImagen(imagen,juego);
	var popup,fondo_oculto;
	popup = document.getElementById("popup");
	popup.style.visibility = "visible";
	fondo_oculto = document.getElementById("fondo_oculto");
	fondo_oculto.style.visibility = "visible";
}
function imagen2(imagen,juego){
	ajaxImagen2(imagen,juego);
	var popup,fondo_oculto;
	popup = document.getElementById("popup");
	popup.style.visibility = "visible";
	fondo_oculto = document.getElementById("fondo_oculto");
	fondo_oculto.style.visibility = "visible";
}
function reproducirVideo(id,primero){
	var ahora = $f().getClip();
	if(ahora==undefined){
		document.getElementById('play'+primero).src = "images/play_mini.png";
	}else{
		ahora = ahora['url'].substr(7);
		ahora = ahora.substr(0,ahora.length-4);
		document.getElementById('play'+ahora).src = "images/play_mini.png";	
	}
	$f().play('videos/'+id+'-SD.mp4');
	document.getElementById('play'+id).src = "images/play_mini_rep.png";
	document.getElementById('titulo').innerHTML = document.getElementById('comentario'+id).innerHTML;
	document.getElementById('fecha').innerHTML = "Añadido el "+document.getElementById('fecha'+id).value;
	
}
function getElementByClass(theClass) {
	//SIN TERMINAR
var sol = new Array();
//Create Array of All HTML Tags
var allHTMLTags=document.getElementsByTagName("*");
//Loop through all tags using a for loop
for (i=0; i<allHTMLTags.length; i++) {
//Get all tags with the specified class name.
if (allHTMLTags[i].className==theClass) {
sol[0] = allHTMLTags[i];
}
}
return sol;
}
function reproducirPodcast(titulo, numero_total, fecha){
	document.getElementById('titulo').innerHTML = titulo;
	document.getElementById('numero_total').innerHTML = numero_total;
	document.getElementById('fecha').innerHTML = fecha;	
}
function reproducirEntrevista(titulo, fecha){
	document.getElementById('titulo').innerHTML = titulo;
	document.getElementById('fecha').innerHTML = fecha;	
}
function pestana2(cat){
	div = document.getElementById(cat);
	div.className = cat+"_on";
	
}
function pestanaOff2(cat){
	div = document.getElementById(cat);
	div.className = cat+"_off";
}
function next(elem) {
    do {
        elem = elem.nextSibling;
    } while (elem && elem.nodeType != 1);
    return elem;                
}
function spoiler(id){
	var div = next(id);
	if(div.style.display == "none")
	div.style.display = "block";
	else
	div.style.display = "none";
}

//Validacion

function validarRegistro(){
	var error=false;
	var nick = document.getElementById("nick_r");
	/*var password = document.getElementById("password");
	var password_r = document.getElementById("password_r");
	var email = document.getElementById("email");*/
	
	if(nick.value=="" || nick.value == "Nombre de usuario"){
		error=true;
		document.getElementById("nick_r_label").style.color = "red";
	}
	/*if(password.value==""){
		error=false;
		aviso_error+="Debes introducir tu contrase&ntilde;a.<br/>";
	}
	if(password.value!=password_r.value){
		error=false;
		aviso_error+="Las contrase&ntilde;as deben coincidir.<br/>";
	}
	if(email.value==""){
		error=false;
		aviso_error+="Debes introducir tu email.<br/>";
	}*/
	
	
		return false;
	//ajaxRegistroOk()
}

