function verifica_contacto(){

	if (document.contacto.t_nome.value==""){
		msg= "Tem que preencher o campo NOME." + "\n" ;
		window.alert (msg);
		document.contacto.t_nome.focus(); 
		return false;
	} else if (document.contacto.t_nome.value.length<5){
		msg= "O campo NOME tem que ter pelo menos 5 dígitos." + "\n" ;
		window.alert (msg);
		document.contacto.t_nome.focus(); 
		return false;
	}
	
	if ((document.contacto.t_email.value=="") && (document.contacto.t_telef.value==""))
	{
		msg= "Tem que preencher o campo E-MAIL ou TELEFONE." + "\n" ;
		window.alert (msg);
		document.contacto.t_email.focus(); 
		return false;
	}	
	else
	{
		if (document.contacto.t_email.value!="")
		{
			if (!(valida_email(document.contacto.t_email.value)))
			{
				document.contacto.t_email.focus(); 
				return false;
			}
		}
		else
		{
			if (document.contacto.t_telef.value=="")
			{
				msg= "Tem que preencher o campo TELEFONE." + "\n" ;
				window.alert (msg);
				document.contacto.t_telef.focus(); 
				return false;
			}	
		}
	}	
	
	if (document.contacto.t_info.value==""){
		msg= "Tem que preencher o campo INFORMAÇÃO." + "\n" ;
		window.alert (msg);
		document.contacto.t_info.focus(); 
		return false;
	} else if (document.contacto.t_info.value.length>255){
		msg= "O campo INFORMAÇÃO não pode conter mais do que 255 caracteres." + "\n" ;
		window.alert (msg);
		document.contacto.t_info.focus(); 
		return false;	
	}	
	return true
}

function verifica_pub(){
	if ((document.pub.t_nome.value=="") && (document.pub.t_empresa.value==""))
	{
		msg= "Tem que preencher o campo NOME ou EMPRESA." + "\n" ;
		window.alert (msg);
		document.pub.t_nome.focus(); 
		return false;
	}
	else
	{
		if ((document.pub.t_nome.value!=""))
		{
			if (document.pub.t_nome.value.length<5)
			{
				msg= "O campo NOME tem que ter pelo menos 5 dígitos." + "\n" ;
				window.alert (msg);
				document.pub.t_nome.focus(); 
				return false;
			}
		}
		else
		{
			if (document.pub.t_empresa.value.length<5)
			{
				msg= "O campo EMPRESA tem que ter pelo menos 5 dígitos." + "\n" ;
				window.alert (msg);
				document.pub.t_empresa.focus(); 
				return false;
			}
		}
	}
	if ((document.pub.t_email.value=="") && (document.pub.t_telef.value==""))
	{
		msg= "Tem que preencher o campo E-MAIL ou TELEFONE." + "\n" ;
		window.alert (msg);
		document.pub.t_email.focus(); 
		return false;
	}	
	else
	{
		if (document.pub.t_email.value!="")
		{
			if (!(valida_email(document.pub.t_email.value)))
			{
				document.pub.t_email.focus(); 
				return false;
			}
		}
		else
		{
			if (document.pub.t_telef.value=="")
			{
				msg= "Tem que preencher o campo TELEFONE." + "\n" ;
				window.alert (msg);
				document.pub.t_telef.focus(); 
				return false;
			}	
		}
	}	
	if (document.pub.t_inf.value=="")
	{
		msg= "Tem que preencher o campo INFORMAÇÃO PRETENDIDA." + "\n" ;
		window.alert (msg);
		document.pub.t_inf.focus(); 
		return false;
	}
	else if (document.pub.t_inf.value.length>255)
	{
		msg= "O campo INFORMAÇÃO não pode conter mais do que 255 caracteres." + "\n" ;
		window.alert (msg);
		document.pub.t_inf.focus(); 
		return false;	
	}		
	return true
}


function valida_email(email)
{
	var result = /^.+\@.+\..+$/ ;

	if ((email == null) || (email.length == 0)) {
       	if (valida_email.arguments.length == 1) {
       		alert("Tem que preencher um E-Mail válido.");
       		return false ;
       	} else {
       		if (!(valida_email.arguments[1] == true)) {
       			alert("Tem que preencher um E-Mail válido.");
       		}
       		return (valida_email.arguments[1] == true);
       	}
    } else {
		if (!(result.test(email))) {
			alert("Tem que preencher um E-Mail válido.");
		}
       return result.test(email);
    }
}