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

function comprobar() 
{
	var f = document.getElementById("frmContacto");
	var ok;
	ok = true;
	
	if (f.nombre.value=="") {
		alert("Debe introducir el nombre / Debe introducir o nome / Enter name correctly");
		ok = false;
		f.nombre.focus();
	}
	if ((ok)&&(f.email.value=="")) {
		alert("Introduzca correctamente el email / Introduza correctamente o email / Enter email correctly");
		ok = false;
		f.email.focus();
	}
	if ((ok)&&(formatoEmail(f.email.value) == false))
	{
		alert("El email no es válido / O email non é válido / This email is not valid");
		ok = false;
		f.email.focus();
	}
	if ((ok)&&(f.mensaje.value=="")) {
		alert("Introduzca correctamente el mensaje / Introduza correctamente o  mensaxe ");
		ok = false;
		f.mensaje.focus();
	}
	
	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("frmContacto");
	
	if (comprobar()) {
		f.submit();
	}		
}


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

	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);
	}
