/* +---------------------------------------------------------------------------+ */
/* | Glosario.NET															   | */
/* +---------------------------------------------------------------------------+ */ 
/* | funciones.js                                                              | */
/* +---------------------------------------------------------------------------+ */
/* | Copyright (C) 2006 HispaNetwork Servicios Informaticos SL                 | */
/* |                                                                           | */
/* | Author: Manuel Merino <manuel ARROBA hispanetwork PUNTO com>              | */ 
/* |                                                                           | */
/* | Descr.: Librería de funciones JavaScript.                                 | */ 
/* |                                                                           | */ 
/* +---------------------------------------------------------------------------+ */


function validar_login(formulario_login) {
    if (formulario_login.USUARIO.value.length == 0)
		{
		alert("Escribe el usuario.");
		formulario_login.USUARIO.focus();
		return false;
		}
    if (formulario_login.PASSWORD.value.length == 0)
		{
		alert("Escribe el usuario.");
		formulario_login.PASSWORD.focus();
		return false;
		}
}

function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
		return true;
	} else {
		return false;
	}
}

function validar_alta(alta) {

  if (alta.NOMBRE.value.length == 0) {
    alert("Escribe tu NOMBRE.");
    alta.NOMBRE.focus();
    return false;
  }
  if (alta.CIUDAD.value.length == 0) {
    alert("Escribe tu ciudad.");
    alta.CIUDAD.focus();
    return false;
  }

  if (!validarEmail(alta.EMAIL.value)){
		alert("Debe informar correctamente el email.");
		alta.EMAIL.focus();
		alta.EMAIL.select();
		return false;
	}
  if (alta.PASSWORD.value.length == 0) {
    alert("Escribe tu pass.");
    alta.PASSWORD.focus();
    return false;
  }
  if (alta.PASSWORD.value != alta.PASSWORD2.value) {
    alert("Los passwords introducidos no coinciden.");
    alta.PASSWORD.focus();
    return false;
  }
}


function validar_busqueda(busqueda) {
		if (busqueda.P.value.length == 0 || busqueda.P.value == "palabra a buscar")
			{
			alert("Escriba el término.");
			busqueda.P.focus();
			return false;
			}
}