function validar(n){
        
	var form = document.getElementById(n);	  
	
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.mail.value)){
		alert("El email no es válido.");
		return false;
	}
		
	if (n == "news"){
	
		if(form.poblacion.value == ""){
			alert("El campo poblacion es obligatorio.");
			return false;
		}
		
		if (!form.acepto.checked){
			alert("Es obligatorio aceptar las condiciones.");
			return false;			
		}
		
	} else {
		
		if(form.name.value == ""){
			alert("El campo nombre es obligatorio.");
			return false;
		}
	
		if(form.name.value.match(/^[0-9!"Â·\$%\&]*$/i)){
			alert("El nombre no debe contener ni símbolos ni números.");
			return false;
		}
		
		if((/^[0-9]{2,3}-? ?[0-9]{6,7}$/).exec(form.tlf.value)==null){  
			alert("El teléfono no es válido.");
			return false;
		}
	
	}
        
	return true;

}

$(document).ready(function(){

	if($('.aviso').length){
		setInterval(
		function(){
			if($('.aviso').css('visibility') == 'visible'){
				$('.aviso').css('visibility','hidden');
			}
			else{
				$('.aviso').css('visibility','visible');
			}
		},
		500);
	}
});
