	function checkMail(mail){
        var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
        if(typeof(mail) == "string"){
                if(er.test(mail)){ return true; }
        }else if(typeof(mail) == "object"){
                if(er.test(mail.value)){ 
					return true; 
					}
        }else{
                return false;
                }
	}
	
	function Validafale(theForm){
		if(theForm.nome.value==""){
			alert("informe seu Nome!");
			theForm.nome.focus();
			return false;
		}
		if(theForm.email.value==""){
			alert("Informe seu e-mail!");
			theForm.email.focus();
			return false;
		}
        var email = theForm.email.value;
		if (!checkMail(email)) {
			alert("Insira um e-mail v\xe2lido!");
			return false;
		}
		if(theForm.assunto.value==""){
			alert("Insira o assunto!");
			theForm.assunto.focus();
			return false;
		}
		if(theForm.msg.value==""){
			alert("Deixe sua mensagem!");
			theForm.msg.focus();
			return false;
		}
	}
	
	function Busca(theForm){
		if(theForm.busca.value==""){
			alert("Digite a palavra que deseja pesquisar!");
			theForm.busca.focus();
			return false;	}
		var texto = theForm.busca.value
  		if (texto.length < 3){
  			alert("Digite no m\xednimo 3 caracteres da palavra que deseja pequisar!.");
    		theForm.busca.focus();
    		return false;	}}
			
	function LOGIN(theForm){
		if(theForm.user.value=="Usuario"){
			alert("Insira o C\xf3digo de Usu\xe1rio!");
			theForm.user.focus();
			return false;	}
		if(theForm.user.value==" "){
			alert("Insira o C\xf3digo de Usu\xe1rio!");
			theForm.user.value="";
			theForm.senha.value="";
			theForm.user.focus();
			return false;	}
		if(theForm.senha.value=="Senha"){
			alert("Insira sua senha!");
			theForm.senha.focus();
			return false;	}
		if(theForm.senha.value==" "){
			alert("Insira sua senha!");
			theForm.senha.value="";
			theForm.senha.focus();
			return false;	}
	}
	
function SoNumero(evtKeyPress) {
	var nTecla;
	nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;

	if(!(nTecla > 47 && nTecla < 58) && nTecla !=09 && nTecla !=08)
		return false;
	}
	
function Valida2(theForm){
		if (theForm.autor.value=="" && theForm.titulo.value=="" && theForm.espec.value=="" && theForm.isbn.value=="" &&theForm.editora.value==""){
			alert("Preencha um dos campos para continuar com sua pesquisa.\n- Autor\n- Titulo\n- ISBN\n- Especialidade\n- Editora");
			theForm.autor.focus();
			return false;
		}
		var texto = theForm.autor.value;
  		if (texto.length < 3 && theForm.titulo.value=="" && theForm.espec.value=="" && theForm.isbn.value=="" &&theForm.editora.value==""){
  			alert("Expecifique melhor sua busca.");
    		theForm.autor.focus();
    		return false;
		}
		var texto = theForm.titulo.value;
  		if (texto.length < 3 && theForm.autor.value=="" && theForm.espec.value=="" && theForm.isbn.value=="" &&theForm.editora.value==""){
  			alert("Expecifique melhor sua busca.");
    		theForm.autor.focus();
    		return false;
  		}
		var isbn = theForm.isbn.value;
		if(isbn.length < 13){
			var isbn = isbn.substring(0, 9);
			if (isNaN(isbn)){
				alert("ISBN incorreto!");
				theForm.isbn.focus();
				return false;	}
		}
		if(isbn.length=13){
			var isbn = isbn.substring(0, 12);
			if (isNaN(isbn)){
				alert("ISBN incorreto!");
				theForm.isbn.focus();
				return false;	}
		}
}

function ValidaADD(theForm){
	if(theForm.fantasy.value==""){
		alert("Digite a nome fant\xe1sia de sua Empresa!");
		theForm.fantasy.focus();
		return false;	}
	if(theForm.razao.value==""){
		alert("Digite a Raz\xe3o Social de sua Empresa!");
		theForm.razao.focus();
		return false;	}
	if(theForm.fund.value==""){
		alert("Digite a data de funda\xe7\xe3o de sua Empresa!");
		theForm.fund.focus();
		return false;	}
	if(theForm.contato.value==""){
		alert("Digite o nome de contato na Empresa!");
		theForm.contato.focus();
		return false;	}
	if(theForm.email.value==""){
		alert("Digite o e-mail do contato!");
		theForm.email.focus();
		return false;	}
	if(theForm.cnpj.value==""){
		alert("Digite o numero do CNPJ da Empresa!");
		theForm.cnpj.focus();
		return false;	}
	if(theForm.fat.value==""){
		alert("Digite o endere\xe7o de sua Empresa!");
		theForm.fat.focus();
		return false;	}
	if(theForm.fat_bairro.value==""){
		alert("Digite o Bairro!");
		theForm.fat_bairro.focus();
		return false;	}
	if(theForm.fat_city.value==""){
		alert("Digite a Cidade!");
		theForm.fat_city.focus();
		return false;	}
	if(theForm.fat_est.value==0){
		alert("Selecione o estado!");
		theForm.fat_est.focus();
		return false;	}
	if(theForm.fat_cep.value==""){
		alert("Digite o CEP!");
		theForm.fat_cep.focus();
		return false;	}
	if(theForm.fat_tell.value==""){
		alert("Digite o n\xfamero do telefone de sua Empresa!");
		theForm.fat_tell.focus();
		return false;	}
	if(theForm.s_nome.value==""){
		alert("Digite o nome do S\xf3cio da Empresa!");
		theForm.s_nome.focus();
		return false;	}
	if(theForm.s_rg.value==""){
		alert("Digite o RG do S\xf3cio da Empresa!");
		theForm.s_rg.focus();
		return false;	}
	if(theForm.sc_nun.value==""){
		alert("Digite o CPF do S\xf3cio da Empresa!");
		theForm.sc_nun.focus();
		return false;	}
	if(theForm.empresa.value==""){
		alert("Digite o nome de sua refer\xeancia comercial!");
		theForm.empresa.focus();
		return false;	}
	if(theForm.empr_tel.value==""){
		alert("Digite o telefone de sua refer\xeancia comercial!");
		theForm.empr_tel.focus();
		return false;	}
	if(theForm.banco.value==""){
		alert("Digite os dados do Banco e da Ag\xeancia banc\xe1ria!");
		theForm.banco.focus();
		return false;	}
	if(theForm.banc_tel.value==""){
		alert("Digite o telefone da Ag\xeancia bancária!");
		theForm.banc_tel.focus();
		return false;	}
	if(theForm.resp.value==""){
		alert("Digite o nome do respons\xe1vel pelas informa\xe7\xe3es!");
		theForm.resp.focus();
		return false;	}
	return true;	}
