// JavaScript Document
function comprobarDatos() 
{
	with (document.f) 
	{
		if (nombre.value == "") 
		{
			alert("Debes introducir tu nombre");
			nombre.focus();
			return false;
		}
		else 
		{
			if (telefono.value == "" && mail.value == "") 
			{
				alert("Debes introducir un teléfono o un mail de contacto");
				return false;
			}
			if (mail.value != "")
			{
				if (mail.value.indexOf("@") == -1)
				{
					alert("La dirección de correo electrónico no es válida");
					mail.focus();
					return false;
				}
			}
			if (telefono.value != "")
			{
				if (telefono.value.length != 9)
				{
					alert("El teléfono debe tener 9 dígitos");
					telefono.focus();
					return false;
				}
				if (isNaN(telefono.value))
				{
					alert("El teléfono no es válido");
					telefono.focus();
					return false;
				}
			}			
		}
		if (comentario.value == "")
		{
			alert("Debes introducir tu comentario");
			comentario.focus();
			return false;
		}
	}
	return true;
}

function comprobarDades() 
{
	with (document.f) 
	{
		if (nombre.value == "") 
		{
			alert("Has d'introduir el teu nom");
			nombre.focus();
			return false;
		}
		else 
		{
			if (telefono.value == "" && mail.value == "") 
			{
				alert("Has d'introduir un telèfon o un mail de contacte");
				return false;
			}
			if (mail.value != "")
			{
				if (mail.value.indexOf("@") == -1)
				{
					alert("L'adreça de correu electrònic no és vàlida");
					mail.focus();
					return false;
				}
			}
			if (telefono.value != "")
			{
				if (telefono.value.length != 9)
				{
					alert("El telèfon ha de tenir 9 dígits");
					telefono.focus();
					return false;
				}
				if (isNaN(telefono.value))
				{
					alert("El telèfon no és vàlid");
					telefono.focus();
					return false;
				}
			}			
		}
		if (comentario.value == "")
		{
			alert("Has d'introduir el teu comentari");
			comentario.focus();
			return false;
		}
	}
	return true;
}

