// Utilizada para evitar digitar o document.getElementById
function gE(ID){
	return document.getElementById(ID);
}
function abrePagina(pUrl){	document.location = pUrl;}// abre pop-upfunction abrePopUp(url, id, largura, altura){	window.open(url, id, 'width='+largura+', height='+altura+', toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, menubar=no');}
// Utilizada para evitar digitar o document.getElementsByTagName
function gEs(tag) {
	return document.getElementsByTagName(tag);
}

/* funções para alterar o tamanho das fontes */
	var tam = 11;
	var lin = 1.5;
	function alterarTamanhoFonte(tipo, onde){
		
		var minimo = 7;
		var maximo = 20;
		vardomElement = gE(onde);
												  
		if( tipo == 'mais' ){
			if( tam < 16 ) tam += 2;
		}
		else{
			if( tam > 9 ) tam -= 2 ;
		}
		
		mudaFonte(tipo , document.getElementById(onde)) ;     
	}
	
	
	function mudaFonte( tipo , idM ){		
	  for( var i = 0 ; i < idM.childNodes.length ; i++ ){
		mudaFonte( tipo , idM.childNodes.item( i )  );
	  }
	  if( idM.style )
		idM.style.fontSize = tam+'px';
	}
// fim fas funções para alterar tamanho da fonte


// Chama a função loadFunctions ao carregar a página
window.onload = loadFunctions;

// Função que inicializa algumas funções
function loadFunctions() {
	limpaCamposInformativo();
}


// Função que valida o e-mail informado
function validaEmail(email){
	return email.search(/(\w[\w\.\+]+)@(.+)\.(\w+)$/)==0;
}



// função para lipar campos do formulario
function limpaCamposInformativo(){
	if (gE('id_info_nome')){
		gE('id_info_nome').onfocus = function(){
				gE('id_info_nome').value = '';
		}
	}
	
	if(gE('id_info_email')){
		gE('id_info_email').onfocus = function(){
				gE('id_info_email').value = '';
		}
	}
}
// fim da função limpa campo


// função para validação do formulario de informativo
function validaFrmInformativo(){
	var nome = gE('id_info_nome');
	var email = gE('id_info_email');
	
	if (nome.value == '' || nome.value == null || nome.value == 'Nome'){
		alert("Campo Nome em branco.");
		nome.focus();
		return false;
	}
	
	if (email.value == '' || email.value == null || nome.value == 'E-mail'){
		alert("Campo E-mail em branco");
		email.focus();
		return false;
	}
	
	var verificaEmail = validaEmail(email.value);
	
	if (verificaEmail == false){
		alert("E-mail inválido");		
		email.focus();
		return false;
	}
	
	return true;
}
// fim fa função para validção do formularioo de informativo




// função para validação do formulario de contato
function validaFrmContato(){
	if (!gE('frmContato')) return false;
	
	var nome = gE('f_cont_nome');
	var email = gE('f_cont_email');
	var assunto = gE('f_cont_assunto');
	var msg = gE('f_cont_msg');
	
	if (nome.value == '' || nome.value == null){
		alert("Campo Nome em branco.");
		nome.focus();
		return false;
	}
	
	if (email.value == '' || email.value == null){
		alert("Campo E-mail em branco");
		email.focus();
		return false;
	}
	
	var verificaEmail = validaEmail(email.value);
	
	if (verificaEmail == false){
		alert("E-mail inválido");		
		email.focus();
		return false;
	}
	
	if (assunto.value == '' || assunto.value == null){
		alert("Campo Assunto em branco");
		assunto.focus();
		return false;
	}
	
	if (msg.value == '' || msg.value == null){
		alert("Campo Mensagem em branco");
		msg.focus();
		return false;
	}
	
	return true;
}
// fim da validação do formulario de contato



// função para validar o formulario de trabalhe conosco
function validaFrmTrabalheConosco(){
	var nome = gE('id_cur_nome');
	var cidade = gE('id_cur_cid');
	var uf = gE('id_cur_uf');
	var email = gE('id_cur_email');
	var area = gE('id_cur_area');
	var file = gE('id_cur_file');
	
	if (nome.value == '' || nome.value == null){
		alert("Campo Nome em branco.");
		nome.focus();
		return false;
	}
	
	if (cidade.value == '' || cidade.value == null){
		alert("Campo Cidade em branco.");
		cidade.focus();
		return false;
	}
	
	if (uf.value == '' || uf.value == null){
		alert("Selecione um Estado.");
		return false;
	}
	
	if (email.value == '' || email.value == null){
		alert("Campo E-mail em branco.");
		email.focus();
		return false;
	}
	
	var verificaEmail = validaEmail(email.value);
	
	if (verificaEmail == false){
		alert("E-mail inválido");		
		email.focus();
		return false;
	}
	
	if (area.value == '' || area.value == null){
		alert("Selecione uma Área de Atuação.");		
		return false;
	}
	
	if (file.value == '' || file.value == null){
		alert("Anexe seu currículo.");
		file.focus();
		return false;
	}
	
	
	return true;
}
// fim da função da validação do formulario de trabalhe conosco



// função para validação do formulario de cotação
//função para validar alguns campos do formulario de cotação
function validaFrmCotacao(){	
	var nome = gE('f_cota_nome');	
	var ddd = gE('f_cota_ddd');
	var tel = gE('f_cota_tel');
	var email = gE('f_cota_email');
	var cidade = gE('f_cota_cidade');	
	var estado = gE('f_cota_uf');
	var cidadePr = gE('f_cota_cidade2');
	var estadoPr = gE('f_cota_uf2');
	var prod1 = gE('f_cota_producao1');
	var prod2 = gE('f_cota_producao2');
	var prod3 = gE('f_cota_producao3');
	
	window.location = '#topo';
		
	if (nome.value == '' || nome.value == null){
		alert("Campo Nome em branco.");
		nome.focus();		
		return false;
	}	
	
	if (ddd.value == '' || ddd.value == null){
		alert("Campo Telefone em branco.");
		ddd.focus();
		return false;
	}
	
	if (tel.value == '' || tel.value == null){
		alert("Campo Telefone em branco.");
		tel.focus();
		return false;
	}
	
	var verificaEmail = validaEmail(email.value);
	
	if (verificaEmail == false){
		alert("E-mail inválido");		
		email.focus();
		return false;
	}
	
	if (cidade.value == '' || cidade.value == null){
		alert("Campo Cidade em branco.");
		cidade.focus();
		return false;
	}
	
	if (estado.value == '' || estado.value == null){
		alert("Selecione um Estado.");
		estado.focus();
		return false;
	}
	
	if (cidadePr.value == '' || cidade.value == null){
		alert("Campo Cidade da Propriedade em branco.");
		cidadePr.focus();
		return false;
	}
	
	if (estadoPr.value == '' || estadoPr.value == null){
		alert("Selecione um Estado da Propriedade.");
		estadoPr.focus();
		return false;
	}
	
	var producao = '';
	
	if (prod1.checked)
		producao = 'ok';
	if (prod2.checked)
		producao = 'ok';
	if (prod3.checked)
		producao = 'ok';
		
	if (producao == '' || producao == null){
		alert('Selecione um Sistema de produção');
		return false;
	}
	
	return true;
}
// fim da validação do formulario de cotação