function comprobarLongitudNick(whatYouTyped) {
	//var fieldset = whatYouTyped.parentNode;
	var txt = whatYouTyped.value;
	if (txt.length > 5) {
		document.getElementById("etiqueta_nick").style.color = "black";
		document.getElementById("etiqueta_nick").innerHTML = "Longitud del nick correcta";
	}
	else {
		document.getElementById("etiqueta_nick").style.color = "red";
		document.getElementById("etiqueta_nick").innerHTML = "Longitud de nick demasiado corta.";
	}
}

function comprobarPassword(whatYouTyped) {
	//var fieldset = whatYouTyped.parentNode;
	var txt = whatYouTyped.value;
	if (txt.length > 5 && txt.length < 7) {
		document.getElementById("etiqueta_pass").style.color = "gray";
		document.getElementById("etiqueta_pass").innerHTML = "Longitud de Password no recomendable";		
	} else if (txt.length >= 7) {
		document.getElementById("etiqueta_pass").style.color = "black";
		document.getElementById("etiqueta_pass").innerHTML = "Longitud de Password correcta";		
		} else {
			document.getElementById("etiqueta_pass").style.color = "red";
		document.getElementById("etiqueta_pass").innerHTML = "Longitud de Password insuficiente";		
	}
}

// If the password is at least 4 characters long, the containing 
// fieldset is assigned class="kindagood".
// If it's at least 8 characters long, the containing
// fieldset is assigned class="welldone", to give the user
// the indication that they've selected a harder-to-crack
// password.

function comprobarPasswordIgual(whatYouTyped, otro) {
	//var fieldset = whatYouTyped.parentNode;
	var txt = whatYouTyped.value;
	
	if (txt == document.getElementById(otro).value) {
		document.getElementById("etiqueta_igual").style.color = "black";
		document.getElementById("etiqueta_igual").innerHTML = "Confirmación de Password igual";
		//fieldset.className = "welldone";
	} else {
		document.getElementById("etiqueta_igual").style.color = "red";
		document.getElementById("etiqueta_igual").innerHTML = "Confirmación de Password distinto";
		//fieldset.className = "";
	}
}

function comprobarEmailIgual(whatYouTyped, otro) {
	//var fieldset = whatYouTyped.parentNode;
	var txt = whatYouTyped.value;
	if (txt == otro.value) {
		document.getElementById("etiqueta_mail_repetido").style.color="black";
		document.getElementById("etiqueta_mail_repetido").innerHTML = "Confirmación de email igual";
		//fieldset.className = "welldone";
	} else {
		document.getElementById("etiqueta_mail_repetido").style.color="red";
		document.getElementById("etiqueta_mail_repetido").innerHTML = "Confirmación de email distinto";
		//fieldset.className = "";
	}
}

// This function checks the email address to be sure
// it follows a certain pattern:
// blah@blah.blah
// If so, it assigns class="welldone" to the containing
// fieldset.

function comprobarEmail(whatYouTyped) {	
	var txt = whatYouTyped.value;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt)) {
		document.getElementById("etiqueta_mail").style.color = "black";
		document.getElementById("etiqueta_mail").innerHTML = "Formato de mail correcto";		
	} else {
		document.getElementById("etiqueta_mail").style.color = "red";
		document.getElementById("etiqueta_mail").innerHTML = "Formato de mail incorrecto";		
	}
}

//Función para abrir un popup con la página deseada, el ancho y el alto
function popup(direccionURL,widthw,heightw) {
 var estilo = "resizable=1,menubar=0,toolbar=0,location=0,personalbar=0"+
                 ",status=0,scrollbars=1,width="+widthw+",height="+heightw+",top="+
                 (screen.height-heightw)/2+",left="+(screen.width-widthw)/2;
 return window.open(direccionURL,"Popup",estilo);
}

// Funcion Necesarias para los paginadores del Administrador
function irapagina(PosPagUsuario,PaginaMysql){	
	//document.getElementById("PosPagUsuario").value=PosPagUsuario;
	document.getElementById("PaginaMysql").value=PaginaMysql;
	document.getElementById("formulario").submit();
}

function irapaginaBus(PaginaMysql){
	document.getElementById("PaginaMysqlBus").value=PaginaMysql;
}
//Funcion para mostrar el primer campo y ocultar el segundo.
function mostrar_ocultar_campos(campos1,campos2){
	if(campos1!=''){document.getElementById(campos1).style.display="";}
	if(campos2!=''){document.getElementById(campos2).style.display="none";}
}
//Funcion para mostrar un bloque si esta oculto y cambiar el boton del desplegable.
function mostrar_ocultar_desglose(id1,id2,texto){
	if(document.getElementById(id1).style.display=="none"){
		document.getElementById(id1).style.display="";
		document.getElementById(id2).innerHTML="<a href='#' onclick='javascript:mostrar_ocultar_desglose(\""+id1+"\",\""+id2+"\",\""+texto+"\")'><img src='img/bt_menos.jpg' alt='boton más' /></a> "+texto;
	}else{
		document.getElementById(id1).style.display="none";
		document.getElementById(id2).innerHTML="<a href='#' onclick='javascript:mostrar_ocultar_desglose(\""+id1+"\",\""+id2+"\",\""+texto+"\")'><img src='img/bt_mas.jpg' alt='boton más' /></a> "+texto;
	}
}
//Funcion de ajax que pone en el html etiqueta el resultado de resolver la url especificada.
function ajaxupdater(etiqueta,URL, etiqueta_carga){	
	document.getElementById(etiqueta_carga).innerHTML="Comprobando.";
	new Ajax.Updater(etiqueta,URL);
	if(etiqueta!=etiqueta_carga){
		document.getElementById(etiqueta_carga).innerHTML="";
	}	
}