function chequeo_login() {
	if (document.acceso.usuario.value == "" || document.acceso.clave.value == "") {
		alert('Tienes que indicar tu nombre de usuario y clave de acceso');
		return false;
	}
	return true;
}

function chequeo_activacion() {
	if (document.activacion.codigoacceso.value == "") {
		alert('Tienes que indicar un código de activación');
		return false;
	}
	return true;
}

function chequeo_activacion2() {
	// return true;
	if (document.activacion.usuario.value == "" || document.activacion.clave1.value == "" || document.activacion.clave2.value == "" || document.activacion.email1.value == "" || document.activacion.email2.value == "" || document.activacion.nombre.value == "" || document.activacion.apellido1.value == "") {
		alert('Tiene que rellenar los campos obligatorios');
		return false;
	}
	var uInput = document.activacion.usuario.value;
	if (uInput.length >= 6 && uInput.length <= 12) {
		// return true;
	} else {
		// alert("El nombre de usuario ha de tener entre 6 y 12 caracteres");
		alert("El campo Usuario ha de tener entre 6 y 12 caracteres");
		return false;
	}
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if (document.activacion.usuario.value.match(alphaExp)) {
		// return true;
	} else {
		// alert("El nombre de usuario solo admite letras y números");
		alert("El campo Usuario sólo admite letras y números, sin espacios");
		return false;
	}
	if (document.activacion.clave1.value != document.activacion.clave2.value) {
		alert('La clave y la repetición no coinciden');
		return false;
	}
	strEmail = document.activacion.email1.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El correo electrónico no tiene un formato válido");
		return false;
	}
	if (document.activacion.email1.value != document.activacion.email2.value) {
		alert('El email y la repetición no coinciden');
		return false;
	}
	if(!document.activacion.acepto.checked){
		alert("Tiene que aceptar las condiciones de uso y la política de protección de datos");
		return false;
	}
	return true;
}

function chequeo_activacionx() {
	if (document.activacionx.codigoacceso2.value == "") {
		alert('Tienes que indicar un código de activación');
		return false;
	}
	return true;
}

function chequeo_ampliacion() {
	if (document.nuevocodigo.nuevocodigo.value == "") {
		alert("Tienes que indicar el código que quieres activar");
		return false;
	}
	return true;
}

function chequeo_misdatos() {
	// return true;
	if ((document.misdatos.clave1.value != "" && document.misdatos.clave2.value == "") || (document.misdatos.clave1.value == "" && document.misdatos.clave2.value != "") || document.misdatos.email1.value == "" || document.misdatos.email2.value == "" || document.misdatos.nombre.value == "" || document.misdatos.apellido1.value == "") {
		alert('Tiene que rellenar los campos obligatorios');
		return false;
	}
	if (document.misdatos.clave1.value != document.misdatos.clave2.value) {
		alert('La clave y la repetición no coinciden');
		return false;
	}
	strEmail = document.misdatos.email1.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El correo electrónico no tiene un formato válido");
		return false;
	}
	if (document.misdatos.email1.value != document.misdatos.email2.value) {
		alert('El email y la repetición no coinciden');
		return false;
	}
	return true;
}

function chequeo_verificacion() {
	if (document.verificacion.usuario.value == "" || document.verificacion.email.value == "") {
		alert('Todos los campos son obligatorios');
		return false;
	}
	strEmail = document.verificacion.email.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El correo electrónico no tiene un formato válido");
		return false;
	}
	return true;
}

function chequeo_recuperacion() {
	if (document.recuperacion.usuario.value == "" || document.recuperacion.email.value == "") {
		alert('Todos los campos son obligatorios');
		return false;
	}
	strEmail = document.recuperacion.email.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El correo electrónico no tiene un formato válido");
		return false;
	}
	return true;
}

function chequeo_restauracion() {
	if (document.restauracion.clave.value == "" || document.restauracion.clave2.value == "") {
		alert('Todos los campos son obligatorios');
		return false;
	}
	if (document.restauracion.clave.value != document.restauracion.clave2.value) {
		alert('La clave y la repetición no coinciden');
		return false;
	}
	return true;
}

function chequeo_participa() {
	if (document.participa.asunto.value == "" || document.participa.mensaje.value == "") {
		alert('Tienes que indicar un asunto y escribir un mensaje');
		return false;
	}
	return true;
}

function chequeo_envia() {
	if (document.envia.nombre.value == "" || document.envia.nombrecolega.value == "" || document.envia.emailcolega.value == "") {
		alert('Tienes que indicar tu nombre, y el nombre y correo electrónico de tu colega');
		return false;
	}
	strEmail = document.envia.emailcolega.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El correo electrónico de tu colega no tiene un formato válido");
		return false;
	}
	return true;
}

function chequeo_notifica() {
	if (document.notifica.motivo.value < 0) {
		alert('Tienes que seleccionar el motivo de tu notificación');
		return false;
	}
	return true;
}

function limpia_buscador_principal() {
	if (document.buscador_principal.pclave.value == "Búsqueda por nombre de producto") {
		document.buscador_principal.pclave.value = "";
	}
}
function rellena_buscador_principal() {
	if (document.buscador_principal.pclave.value == "") {
		document.buscador_principal.pclave.value = "Búsqueda por nombre de producto";
	}
}

function busquedas() {
	/* document.busqueda.accion.value = "refrescar"; */
	document.busqueda.submit();
}

function busqueda_libre() {
	/* document.busqueda.accion.value = "refrescar"; */
	var palabro = document.buscar.pclave.value;
	if (document.buscar.pclave.value == "" || palabro.length < 3) {
		alert('Tienes que indicar un mínimo de tres caracteres para hacer la búsqueda');
		return false;
	}
}

function confirma_eliminar(texto,id) { 
	if (confirm("¿Desea eliminar " + texto + " de sus favoritos?")) { 
		document.location = '/usuario/favoritos/productos/eliminar/' + id + '/';   
	} else {
		return false;
	}
}

function chequeo_accesogratis() {
	if (document.accesogratis.nombre.value == "" || document.accesogratis.apellidos.value == "" || document.accesogratis.email.value == "" || document.accesogratis.email2.value == "") {
		alert('Todos los campos son obligatorios');
		return false;
	}
	strEmail = document.accesogratis.email.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El correo electrónico no tiene un formato válido");
		return false;
	}
	if (document.accesogratis.email.value != document.accesogratis.email2.value) {
		alert('La dirección de correo electrónico no coincide con su repetición');
		return false;
	}
	if (document.accesogratis.guia.value < 0) {
		alert('Elige la guía a la que quieres acceder');
		return false;
	}
	if (!document.accesogratis.acepto.checked) {
		alert('Tienes que aceptar los términos de uso de Guiavet');
		return false;
	}
	return true;
}

