function validate(){
	if(formX.nome.value==""){
		erro("O campo nome é obrigatório!", formX.nome);
		return false;
	}
	if(formX.email.value==""){
		erro("O campo e-mail é obrigatório!", formX.email);
		return false;
	}
	if(!verifica_email(formX.email)){
		erro("Informe um e-mail válido!", formX.email);
		return false;
	}
	if(formX.telefone.value==""){
		erro("O campo telefone é obrigatório!", formX.telefone);
		return false;
	}
	if(formX.assunto.value==""){
		erro("O campo assunto é obrigatório!", formX.assunto);
		return false;
	}
	if(formX.mensagem.value==""){
		erro("O campo mensagem é obrigatório!", formX.mensagem);
		return false;
	}
}

function erro(msg, campo){
	var obj = document.getElementById("warning");
	obj.style.display = "block";
	obj.innerHTML = msg
	campo.focus();
}

function verifica_email(txtEmail){
	var email = txtEmail.value;
	var regex = new RegExp("^[a-zA-Z\\d\\._-]*@[a-zA-Z0-9-]*(\\.[a-zA-Z]*)(\\.[a-zA-Z]*)?(\\.[a-zA-Z]{2})?");

	if(!regex.test(email))
		return false;
	
	email = email.replace(regex, "");
	if(email.length>=1){
		return false;
	}

	return true;
}

function formata(campo,estilo,sonum,e) {
	if(estilo == 'cnpj')
		estilo = '##.###.###/####-##';
		
	if(estilo == 'cep')
		estilo = '#####-###';
		
	if(estilo == 'dd-tel')
		estilo = '(##) ####-####';
	
	if(estilo == 'tel')
		estilo = '####-####';
		
	if(estilo == 'rg')
		estilo = '##.###.###-#';
		
	if(estilo == 'cpf')
		estilo = '###.###.###-##';
		
	if(estilo == 'data')
		estilo = '##/##/####';
		
	if(estilo == 'hora')
		estilo = '##:##:##';
		
	if(estilo == 'horaMin')
		estilo = '##:##';
		
	if(estilo == 'ie' && document.cadastro.estado.value == ""){
		document.cadastro.estado.focus();
		estilo = '#';
	}
	
	if(estilo == 'ie' && document.cadastro.estado.value == 'AC')
		estilo = '##.###.###/###-##';

	if(estilo == 'ie' && (document.cadastro.estado.value == 'AL' || document.cadastro.estado.value == 'AP'
												|| document.cadastro.estado.value == 'CE' || document.cadastro.estado.value == 'ES'
												|| document.cadastro.estado.value == 'MA' || document.cadastro.estado.value == 'MS'
												|| document.cadastro.estado.value == 'PA' || document.cadastro.estado.value == 'PB'
												|| document.cadastro.estado.value == 'PI'))
		estilo = '##.######-#';
			
	if(estilo == 'ie' && document.cadastro.estado.value == 'AM')
		estilo = '##.###.###-#';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'BA')
		estilo = '###.###-##';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'DF')
		estilo = '##.######.###-##';

	if(estilo == 'ie' && (document.cadastro.estado.value == 'GO' || document.cadastro.estado.value == 'RN'))
		estilo = '##.###.###-#';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'MT')
		estilo = '####.######-#';
	
	if(estilo == 'ie' && document.cadastro.estado.value == 'MG')
		estilo = '###.###.###/####';
		
	if(estilo == 'ie' && (document.cadastro.estado.value == 'SP' || document.cadastro.estado.value == '0'))
		estilo = '###.###.###.###';
	
	if(estilo == 'ie' && document.cadastro.estado.value == 'PR')
		estilo = '###.#####-##';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'PE')
		estilo = '##.#.###.#######-#';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'RJ')
		estilo = '##.###.##-#';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'RS')
		estilo = '###/######-#';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'RO')
		estilo = '#############-#';
	
	if(estilo == 'ie' && (document.cadastro.estado.value == 'RR' || document.cadastro.estado.value == 'SE'))
		estilo = '########-#';
		
	if(estilo == 'ie' && document.cadastro.estado.value == 'SC')
		estilo = '###.###.###';

	if(estilo == 'ie' && document.cadastro.estado.value == 'TO')
		estilo = '##########-#';			


	var keycode;
	if(window.event)
		keycode = e.keyCode;
	else if(e.which)
		keycode = e.which;
	
	if(keycode == 8 || keycode == 46 || keycode == null){
		return true;
	}else{
		cnum = false;
		
		for(i=48;i<=57;i++){
			if(keycode == i)
				cnum = true;
		}
		
		for(i=96;i<=105;i++){
			if(keycode == i)
				cnum = false;
		}
	
		if(sonum && !cnum)
			return false;
	
		retorno = "";
	
		for(i=0;i<=campo.value.length;i++){
			if(i < estilo.length){
				if(estilo.charAt(i) == '#')
					retorno += campo.value.charAt(i);
				else
					retorno += estilo.charAt(i);
			}
			else{
				return false;
			}
		}
	
		campo.value = retorno;
	}
}
