function checkforblanks() {
	for (var i=0; i<arguments.length; i+=2) {
		if (!arguments[i]) {
			alert("El campo " + arguments[i+1] + " es obligatorio.");
			return false;
		}
	}
	return true;
}

function validate1() {
	var isFull = checkforblanks(document.getElementById("nombre").value, "[Nombre]",
	document.getElementById("apellidos").value, "[Apellidos]",
	document.getElementById("dni").value, "[DNI]",
	document.getElementById("direccion").value, "[Dirección]",
	document.getElementById("codpostal").value, "[Código Postal]",
	document.getElementById("poblacion").value, "[Población]",
	document.getElementById("telefono").value, "[Teléfono]",
	document.getElementById("movil").value, "[Móvil]",
	document.getElementById("email").value, "[E-Mail]",
	document.getElementById("curriculum").value, "[Curriculum]",
	document.getElementById("foto").value, "[Adjuntar Fotografía]");
	if (!isFull) {
		return false;
	}
	if(document.getElementById("provincia").value=='0') {
		alert("Elija una provincia.");
		return false;
	}
	var dirmail = document.getElementById("email").value;
	var filter = /^.+@.+\..{2,4}$/;
	if (!filter.test(dirmail)) {
		alert("La dirección de correo electrónico no es correcta.");
		return false;
	}
	var tespec=0;
	for (var i=1; i<=29; i++) {
		if(document.getElementById("dat"+i).checked==true) {
			tespec=tespec+1;
		}
	}
	if(tespec==0) {
		alert("Debe marcar al menos una especialización");
		return false;
	}
	var tcom=0;
	for (var i=1; i<=19; i++) {
		if(document.getElementById("com"+i).checked==true) {
			tcom=tcom+1;
		}
	}
	if(tcom==0) {
		alert("Debe marcar al menos una Comunidad Autónoma");
		return false;
	}
	
	if(document.getElementById("avlegal").checked==false) {
		alert("Debe leer y aceptar el aviso legal");
		return false;
	}
}

function validate2() {
	var isFull = checkforblanks(document.getElementById("nombre").value, "[Nombre]",
	document.getElementById("email").value, "[E-Mail]",
	document.getElementById("asunto").value, "[Asunto]",
	document.getElementById("comentario").value, "[Comentario]");
	if (!isFull) {
		return false;
	}
	var dirmail = document.getElementById("email").value;
	var filter = /^.+@.+\..{2,4}$/;
	if (!filter.test(dirmail)) {
		alert("La dirección de correo electrónico no es correcta.");
		return false;
	}
	if(document.getElementById("avlegal").checked==false) {
		alert("Debe leer y aceptar el aviso legal");
		return false;
	}

}

function MailLink (texto,usuario,dominio,tld) {
	var arroba = '@';
	var punto = '.';
	var etiqueta = 'ma' + '' + 'il';
	var dospuntos = 'to:';
	var localizador = usuario;
	localizador = localizador + arroba + dominio;
	localizador = localizador + punto + tld;
	if(texto=='') {
		texto = localizador;
	}
	document.write('<a href="' + etiqueta + dospuntos + localizador + '">' + texto + '</a>');
}

function fCapa(id) {
	if (document.getElementById(id).style.display=='block') {
		document.getElementById(id).style.display='none';
	} else {
		document.getElementById(id).style.display='block';
	}
}