
function AbrirCondiciones(){
	ventana_secundaria = window.open("./components/RRHH/protecciondatos.php","proteccciondatos","width=440,height=375,menubar=no");
}

function comprobar() 
{
	var f = document.getElementById("frmRRHH");
	var ok;
	ok = true;
	var ext = f.archivo.value.toLowerCase().substring(f.archivo.value.length-4);
	
	
	if (f.nombre.value=="") {
		alert("Debe introducir el nombre / Debe introducir o nome");
		ok = false;
		f.nombre.focus();
	}
	if ((ok)&&(f.direcc_postal.value=="")) {
		alert("Debe introducir la dirección postal / Debe introducir a dirección postal");
		ok = false;
		f.direcc_postal.focus();
	}
	if ((ok)&&(f.telefono.value=="")) {
		alert("Debe introducir el teléfono / Debe introducir o teléfono");
		ok = false;
		f.telefono.focus();
	}
	if ((ok)&&(f.email.value=="")) {
		alert("Introduzca correctamente el email / Introduza correctamente o email");
		ok = false;
		f.email.focus();
	}
	if ((ok)&&(formatoEmail(f.email.value) == false))
	{
		alert("El email no es válido / O email non é válido");
		ok = false;
		f.email.focus();
	}
	if ((ok)&&(f.web.value=="")) {
		alert("Debe introducir la página web / Debe introducir a páxina web");
		ok = false;
		f.web.focus();
	}
	if ((ok)&&(f.archivo.value=="")) {
		alert("Debe introducir el CV / Debe introducir o CV");
		ok = false;
	}
	if ((ok)&&(ext != ".pdf" && ext!=".doc" && ext!=".txt")) {
		alert("La extensión del CV debe ser pdf, doc o txt.");
		ok = false;
	}
	if ((ok)&&(f.condiciones.checked!=true)){
		alert("Debe estar de acuerdo con las Condiones Generales de protección de datos.");
		ok = false;
	}
	
	

	return ok;
}


function enviar() 
{
	var f = document.getElementById("frmRRHH");
	
	if (comprobar()) {
		f.submit();
	}		
}


function borrar() 
{
	var f = document.getElementById("frmRRHH");

	f.reset();
}


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