/*
 Função para gerar um alerta nos links ainda não implementados.
 */
function lancaAlerta(){
    alert("Este material estara em breve disponivel.");
}

/*
 Função para limpar os campos do formulário
 Autor: Diemesleno Souza Carvalho
*/
function limpaCampos(){
       erro("");
       document.FormContato.nome.style.border = '';
       document.FormContato.nome.style.backgroundColor = '';
                
       document.FormContato.email.style.border = '';
       document.FormContato.email.style.backgroundColor = '';
                
       document.FormContato.assunto.style.border = '';
       document.FormContato.assunto.style.backgroundColor = '';
                
       document.FormContato.mensagem.style.border = '';
       document.FormContato.mensagem.style.backgroundColor = '';
}

/*
 Função para validar formulário de contato
 Autor: Diemesleno Souza Carvalho
*/
function validaForm(){
               
                // Limpa campos
                limpaCampos();   

		d = document.FormContato;
		if (d.nome.value == "" || d.nome.value == "Nome Completo"){
			//alert("O campo " + d.nome.name + " deve ser preenchido!");                                                
			erro("Digite o nome");
                        document.FormContato.nome.style.backgroundColor = '#ffff99';
			document.FormContato.nome.style.border = 'solid 1px #120acb';
                        d.nome.focus();
			return false;
		}		
		//validar email
		if (d.email.value == "" || d.email.value == "Seu E-mail"){
			//alert("O campo " + d.email.name + " deve ser preenchido!");
			erro("Digite o e-mail");
                        document.FormContato.email.style.backgroundColor = '#ffff99';
			document.FormContato.email.style.border = 'solid 1px #120acb';
                        d.email.focus();
			return false;
		}                
		//validar email(verificao de endereco eletronico)
		parte1 = d.email.value.indexOf("@");
		parte2 = d.email.value.indexOf(".");
		parte3 = d.email.value.length;
		if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
			//alert("O campo " + d.email.name + " deve ser conter um endereco eletronico!");
			erro("O campo e-mail deve conter um endereco eletronico!");
                        document.FormContato.email.style.backgroundColor = '#ffff99';
			document.FormContato.email.style.border = 'solid 1px #120acb';
                        d.email.focus();
			return false;
		}
                //validar assunto
		if (d.assunto.value == "" || d.assunto.value == "Seu Assunto"){
			//alert("O campo " + d.assunto.name + " deve ser preenchido!");
			erro("Digite o assunto");
                        document.FormContato.assunto.style.backgroundColor = '#ffff99';
			document.FormContato.assunto.style.border = 'solid 1px #120acb';
                        d.assunto.focus();
			return false;
		}
                //validar mensagem
		if (d.mensagem.value == "" || d.mensagem.value == "Sua Mensagem"){
			//alert("O campo " + d.mensagem.name + " deve ser preenchido!");
			erro("Digite a mensagem");
                        document.FormContato.mensagem.style.backgroundColor = '#ffff99';
			document.FormContato.mensagem.style.border = 'solid 1px #120acb';
                        d.mensagem.focus();
			return false;
		}
                erro("");
		return true;
                
	}

/*
 Função para validar formulário
 de Mensagens Rápidas.
 Autor: Diemesleno Souza Carvalho
 */
function validaFormM(){
                erroM("");
                document.mensagemRapida.nome.style.border = '';
                document.mensagemRapida.telefone.style.border = '';
                document.mensagemRapida.mensagem.style.border = '';
		d = document.mensagemRapida;
        // Validar nome
		if (d.nome.value == "Seu Nome" || d.nome.value == ""){			
			erroM("Digite o nome");
			document.mensagemRapida.nome.style.border = 'solid 1px #120acb';
                        d.nome.focus();
			return false;
		}
        // Validar telefone
        if (d.telefone.value == "Seu Telefone" || d.telefone.value == ""){			
			erroM("Digite o telefone");
			document.mensagemRapida.telefone.style.border = 'solid 1px #120acb';
                        d.telefone.focus();
			return false;
		}
        //validar mensagem
		if (d.mensagem.value == "Sua Mensagem" ||  d.mensagem.value == ""){			
			erroM("Digite a mensagem");
			document.mensagemRapida.mensagem.style.border = 'solid 1px #120acb';
                        d.mensagem.focus();
			return false;
		}
                erroM("");
		return true;

	}

/*
 Função para mensagens de erro
 Autor: Diemesleno Souza Carvalho
*/
function erro(mensagem) {
                document.getElementById('Error').innerHTML = mensagem;
               
}

/*
 Função para mensagens de erro Mensagem
 Autor: Diemesleno Souza Carvalho
*/
function erroM(mensagemM) {
                document.getElementById('ErrorM').innerHTML = mensagemM;
               
}
