function showFrame_div_servicos_1() {
	document.getElementById('div_servicos_1').style.display = "block";
	document.getElementById('div_servicos_selecionado_1').style.display = "block";
	document.getElementById('div_servicos_2').style.display = "none";
	document.getElementById('div_servicos_selecionado_2').style.display = "none";
	document.getElementById('div_servicos_3').style.display = "none";
	document.getElementById('div_servicos_selecionado_3').style.display = "none";
}
function showFrame_div_servicos_2() {
	document.getElementById('div_servicos_1').style.display = "none";
	document.getElementById('div_servicos_selecionado_1').style.display = "none";
	document.getElementById('div_servicos_2').style.display = "block";
	document.getElementById('div_servicos_selecionado_2').style.display = "block";
	document.getElementById('div_servicos_3').style.display = "none";
	document.getElementById('div_servicos_selecionado_3').style.display = "none";
}
function showFrame_div_servicos_3() {
	document.getElementById('div_servicos_1').style.display = "none";
	document.getElementById('div_servicos_selecionado_1').style.display = "none";
	document.getElementById('div_servicos_2').style.display = "none";
	document.getElementById('div_servicos_selecionado_2').style.display = "none";
	document.getElementById('div_servicos_3').style.display = "block";
	document.getElementById('div_servicos_selecionado_3').style.display = "block";
}

function showFrame_div_produtos_1() {
	document.getElementById('div_produtos_1').style.display = "block";
	document.getElementById('div_produtos_selecionado_1').style.display = "block";
	document.getElementById('div_produtos_2').style.display = "none";
	document.getElementById('div_produtos_selecionado_2').style.display = "none";
	document.getElementById('div_produtos_3').style.display = "none";
	document.getElementById('div_produtos_selecionado_3').style.display = "none";
}
function showFrame_div_produtos_2() {
	document.getElementById('div_produtos_1').style.display = "none";
	document.getElementById('div_produtos_selecionado_1').style.display = "none";
	document.getElementById('div_produtos_2').style.display = "block";
	document.getElementById('div_produtos_selecionado_2').style.display = "block";
	document.getElementById('div_produtos_3').style.display = "none";
	document.getElementById('div_produtos_selecionado_3').style.display = "none";
}
function showFrame_div_produtos_3() {
	document.getElementById('div_produtos_1').style.display = "none";
	document.getElementById('div_produtos_selecionado_1').style.display = "none";
	document.getElementById('div_produtos_2').style.display = "none";
	document.getElementById('div_produtos_selecionado_2').style.display = "none";
	document.getElementById('div_produtos_3').style.display = "block";
	document.getElementById('div_produtos_selecionado_3').style.display = "block";
}

function valida_formulario_locacao()
{
	if (document.getElementById('destino').value==''){ alert("Preencha o campo destinatario"); document.getElementById('destino').focus(); return false; }
	if (document.getElementById('empresa').value==''){ alert("Preencha o campo empresa"); document.getElementById('empresa').focus(); return false; }
	if (document.getElementById('cnpj').value==''){ alert("Preencha o campo cnpj"); document.getElementById('cnpj').focus(); return false; }
	if (document.getElementById('nome').value==''){ alert("Preencha o campo nome"); document.getElementById('nome').focus(); return false; }
	if (document.getElementById('cargo').value==''){ alert("Preencha o campo cargo"); document.getElementById('cargo').focus(); return false; }
	if (document.getElementById('telefone').value==''){ alert("Preencha o campo telefone"); document.getElementById('telefone').focus(); return false; }
	if (document.getElementById('email').value==''){ alert("Preencha o campo e-mail"); document.getElementById('email').focus(); return false; }		
	if (document.getElementById('email').value!=""){
	if (document.getElementById('email').value.indexOf("@") < 1 || document.getElementById('email').value.indexOf(".") < 1) {alert("Preencha o campo e-mail corretamente"); document.getElementById('email').focus(); return false;} }	
	form_locacao.action='envia_mail_locacao.asp';
	form_locacao.submit();
}

function valida_formulario_contato()
{
	if (document.getElementById('destino').value==''){ alert("Preencha o campo destinatario"); document.getElementById('destino').focus(); return false; }
	if (document.getElementById('empresa').value==''){ alert("Preencha o campo empresa"); document.getElementById('empresa').focus(); return false; }
	if (document.getElementById('nome').value==''){ alert("Preencha o campo nome"); document.getElementById('nome').focus(); return false; }
	if (document.getElementById('cargo').value==''){ alert("Preencha o campo cargo"); document.getElementById('cargo').focus(); return false; }
	if (document.getElementById('telefone').value==''){ alert("Preencha o campo telefone"); document.getElementById('telefone').focus(); return false; }
	if (document.getElementById('email').value==''){ alert("Preencha o campo e-mail"); document.getElementById('email').focus(); return false; }		
	if (document.getElementById('email').value!=""){
	if (document.getElementById('email').value.indexOf("@") < 1 || document.getElementById('email').value.indexOf(".") < 1) {alert("Preencha o campo e-mail corretamente"); document.getElementById('email').focus(); return false;} }	
	
	var captcha1 = document.getElementById("captcha1").value
	var captcha2 = document.getElementById("captcha2").value
	if (captcha1 != captcha2) {
		alert("O codigo de segurança esta errado"); document.getElementById('captcha1').focus(); return false;
	}
	
	form_contato.action='envia_mail_contato.asp';
	form_contato.submit();
}

function valida_formulario_contato_refresh()
{
	form_contato.submit();
}

function valida_formulario_rh()
{
	if (document.getElementById('nome').value==''){ alert("Preencha o campo nome"); document.getElementById('nome').focus(); return false; }
	if (document.getElementById('telefone').value==''){ alert("Preencha o campo telefone"); document.getElementById('telefone').focus(); return false; }
	if (document.getElementById('email').value==''){ alert("Preencha o campo e-mail"); document.getElementById('email').focus(); return false; }		
	if (document.getElementById('email').value!=""){
	if (document.getElementById('email').value.indexOf("@") < 1 || document.getElementById('email').value.indexOf(".") < 1) {alert("Preencha o campo e-mail corretamente"); document.getElementById('email').focus(); return false;} }	
	
	var captcha1 = document.getElementById("captcha1").value
	var captcha2 = document.getElementById("captcha2").value
	if (captcha1 != captcha2) {
		alert("O codigo de segurança esta errado"); document.getElementById('captcha1').focus(); return false;
	}
	
	form_rh.action='envia_mail_rh.asp';
	form_rh.submit();
}

function valida_formulario_rh_refresh()
{
	form_rh.submit();
}
function valida_formulario_rh_anexo()
{
	form_rh.action='rh_salva_anexo.asp';
	form_rh.submit();
}

function valida_formulario_busca()
{
	form_busca.action='busca.asp';
	form_busca.submit();
}

function manutencao()
{
	if (document.getElementById('plano').value==''){ alert("Em manutenção."); document.getElementById('plano').focus(); return false; }
	form_contrato.action='contrato.asp';
	form_contrato.submit();
}

function abreMenu(url)
{
	window.location.href=url;
}

function valida_formulario_newsletter()
{
	document.getElementById('botao').value='salva';
	if (document.getElementById('nome').value==''){ alert("Preencha o campo nome"); document.getElementById('nome').focus(); return false; }
	if (document.getElementById('empresa').value==''){ alert("Preencha o campo empresa"); document.getElementById('empresa').focus(); return false; }
	if (document.getElementById('email').value==''){ alert("Preencha o campo e-mail"); document.getElementById('email').focus(); return false; }		
	if (document.getElementById('email').value!=""){
	if (document.getElementById('email').value.indexOf("@") < 1 || document.getElementById('email').value.indexOf(".") < 1) {alert("Preencha o campo e-mail corretamente"); document.getElementById('email').focus(); return false;} }	
	form_newsletter.action='envia_mail_newsletter.asp';
	form_newsletter.submit();
}
function valida_formulario_newsletter2()
{
	document.getElementById('botao').value='salva';
	if (document.getElementById('nome').value==''){ alert("Preencha o campo nome"); document.getElementById('nome').focus(); return false; }
	if (document.getElementById('empresa').value==''){ alert("Preencha o campo empresa"); document.getElementById('empresa').focus(); return false; }
	if (document.getElementById('email').value==''){ alert("Preencha o campo e-mail"); document.getElementById('email').focus(); return false; }		
	if (document.getElementById('email').value!=""){
	if (document.getElementById('email').value.indexOf("@") < 1 || document.getElementById('email').value.indexOf(".") < 1) {alert("Preencha o campo e-mail corretamente"); document.getElementById('email').focus(); return false;} }	
	form_newsletter.action='newsletter.asp';
	form_newsletter.submit();
}

function valida_formulario_orcamento()
{
	if (document.getElementById('destino').value==''){ alert("Preencha o campo destinatario"); document.getElementById('destino').focus(); return false; }
	if (document.getElementById('cotacao').value==''){ alert("Preencha o campo cotação"); document.getElementById('cotacao').focus(); return false; }
	if (document.getElementById('empresa').value==''){ alert("Preencha o campo empresa"); document.getElementById('empresa').focus(); return false; }
	if (document.getElementById('cnpj').value==''){ alert("Preencha o campo cnpj"); document.getElementById('cnpj').focus(); return false; }
	if (document.getElementById('nome').value==''){ alert("Preencha o campo nome"); document.getElementById('nome').focus(); return false; }
	if (document.getElementById('cargo').value==''){ alert("Preencha o campo cargo"); document.getElementById('cargo').focus(); return false; }
	if (document.getElementById('telefone').value==''){ alert("Preencha o campo telefone"); document.getElementById('telefone').focus(); return false; }
	if (document.getElementById('email').value==''){ alert("Preencha o campo e-mail"); document.getElementById('email').focus(); return false; }		
	if (document.getElementById('email').value!=""){
	if (document.getElementById('email').value.indexOf("@") < 1 || document.getElementById('email').value.indexOf(".") < 1) {alert("Preencha o campo e-mail corretamente"); document.getElementById('email').focus(); return false;} }	
	form_orcamento.action='envia_mail_orcamento.asp';
	form_orcamento.submit();
}

function PrintElementID(id, pg) {
        var oPrint, oJan;
        oPrint  = window.document.getElementById(id).innerHTML;
        oJan    = window.open(pg);
        oJan.document.write(oPrint);
        oJan.history.go();
        oJan.window.print();
}

function showFrame_div_orcamento() {
	document.getElementById('orcamento').style.display = "block";
}


// JavaScript Document
function abreMenu(varURL)
{
	window.location.href=varURL;
}

function zeraDisplayMSGNewsIndex()
{
	document.getElementById("DisplayMSGNewsIndex").innerHTML = "";
	clearInterval(rep_zeraDisplayMSGNewsIndex); 
}

function buscaRapida(varBusca)
{
	if (varBusca != "Busca Rápida..." && varBusca != ""){
		alert(varBusca);
	};
}

function newsletterIndex(varBusca)
{
	if (varBusca != "Entre com seu E-mail..." && varBusca != ""){
		if (varBusca == " "){alert('campo de email vazio...')}else{		
			if (checa('inpNewsletterIndex',varBusca))
			{
			ajax('CadNewsIndex.asp','DisplayMSGNewsIndex','busca='+varBusca,'','','');
			rep_zeraDisplayMSGNewsIndex = window.setInterval(zeraDisplayMSGNewsIndex,5000);
			document.getElementById('inpNewsletterIndex').value = "Entre com seu E-mail..."
			}
		}
	};
}
var varContato = '';
function enviarContato()
{
	if (document.getElementById("nome").value == ""){alert('campo nome vazio');document.getElementById("nome").focus();return false;}
	if (document.getElementById("dddTelefone").value == ""){alert('campo ddd do telefone vazio');document.getElementById("dddTelefone").focus();return false;}	
	if (document.getElementById("telefone").value == ""){alert('campo telefone vazio');document.getElementById("telefone").focus();return false;}
	if (document.getElementById("email").value == ""){
		alert('campo email vazio');
		document.getElementById("email").focus();
		return false;
	}else{
		if (checa('email',document.getElementById("email").value))
			{
			if (document.getElementById("empresa").value == ""){alert('campo empresa vazio');document.getElementById("empresa").focus();return false;}	
			if (document.getElementById("mensagem").value == ""){alert('campo mensagem vazio');document.getElementById("mensagem").focus();return false;}	
			formContato.submit();			
			}	
	}												
}
var varCliente = '';
function enviarCadastro()
{
	if (document.getElementById("nome").value == ""){alert('campo nome vazio');document.getElementById("nome").focus();return false;}	
	if (document.getElementById("razao").value == ""){alert('campo razao vazio');document.getElementById("razao").focus();return false;}
	if (document.getElementById("endereco").value == ""){alert('campo endereco vazio');document.getElementById("endereco").focus();return false;}
	if (document.getElementById("cidade").value == ""){alert('campo cidade vazio');document.getElementById("cidade").focus();return false;}
	if (document.getElementById("bairro").value == ""){alert('campo bairro vazio');document.getElementById("bairro").focus();return false;}
	if (document.getElementById("cep").value == ""){alert('campo cep vazio');document.getElementById("cep").focus();return false;}
	if (document.getElementById("estado").value == ""){alert('campo estado vazio');document.getElementById("estado").focus();return false;}
	if (document.getElementById("dddFax").value == ""){alert('campo ddd do fax vazio');document.getElementById("dddFax").focus();return false;}	
	if (document.getElementById("fax").value == ""){alert('campo fax vazio');document.getElementById("fax").focus();return false;}	
	if (document.getElementById("cnpj").value == ""){alert('campo cnpj vazio');document.getElementById("cnpj").focus();return false;}
	if (document.getElementById("inscricao").value == ""){alert('campo inscricao vazio');document.getElementById("inscricao").focus();return false;}
	if (document.getElementById("email").value == ""){
		alert('campo email vazio');
		document.getElementById("email").focus();
		return false;
	}else{
		if (checa('email',document.getElementById("email").value))
			{
			if (document.getElementById("tipo").value == ""){alert('campo tipo vazio');document.getElementById("tipo").focus();return false;}
			if (varCliente == ""){alert('Selecione cliente ou nao cliente?');return false;}
			document.getElementById("cliente").value = varCliente;
			formCliente.submit();			
			}	
	}											
}
function bsCampos ()
{
	if (document.getElementById("idCEP").value == "1"){	
		if (document.getElementById("idEnd").value){
				document.getElementById("endereco").value = document.getElementById("idEnd").value
				document.getElementById("bairro").value = document.getElementById("idBairro").value
				document.getElementById("cidade").value = document.getElementById("idCidade").value
				document.getElementById("estado").value = document.getElementById("idEstado").value
		}
	}else{
		document.getElementById("endereco").value = ""
		document.getElementById("bairro").value = ""
		document.getElementById("cidade").value = ""
		document.getElementById("estado").value = ""		
	}	
}




////////////////////CAPTCHA///////////////////////
function localizando_objeto(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=localizando_objeto(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function checar_formulario() { //v4.66
//copyright (c)ByBuRCUVA maxasp.org
  var args = checar_formulario.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = localizando_objeto(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='senha'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = localizando_objeto(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = localizando_objeto(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&localizando_objeto(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&localizando_objeto(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='seleção-unica'||myObj.type=='seleção-multipla'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='area-de-texto'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('Erro encontrado !!!:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}
////////////////////////////////////////////////////







////////////////////PRODUTOS///////////////////////
//limpa o campo busca
function limpa_busca()
{
busca.value = "";
}
//limpa os campos select
function limpa_select()
{
marca.value="";
drop_aplicacao.value = "";
drop_motor.value = "";
produto.value="";
}
//carrega o selext com os tipos dos produtos
function lista_aplicacao()
{
ajax("produtos_filtros_lista.asp","idaplic","tipo=aplicacao&marca="+marca.value,"carregando aplicacoes...","lista_motor","","");
}
//carrega o selext com os tipos dos produtos
function lista_motor()
{
ajax("produtos_filtros_lista.asp","idmotor","tipo=motor&marca="+marca.value+"&aplicacao="+drop_aplicacao.value,"carregando motores...","carrega_produtos","","");
}
//carrega o resultado da pesquisa com os produtos
function carrega_produtos()
{
//alert(2)
if (buscacross.value != "" && buscacross.value != " Código")
{
carrega_cross();
}else{
document.getElementById("show_result").innerHTML = "";
disable_all();
ajax("produtos_filtros_lista.asp","show_result","tipo=lista&marca="+marca.value+"&motor="+drop_motor.value+"&aplicacao="+drop_aplicacao.value+"&buscacross="+buscacross.value.replace("Código","")+"&busca="+busca.value+"&produto="+produto.value,"<img src=images/loading.gif>","enable_all","","");
}
}
//carrega o resultado da pesquisa com os produtos
function carrega_cross()
{
if (buscacross.value != "" && buscacross.value != " Código")
{
if (buscacross.value==" Código"){ buscacross.value = ""; }
disable_all();
ajax("produtos_filtros_lista.asp","show_result","tipo=listacross&marca="+marca.value+"&campo="+marcas.value+"&motor="+drop_motor.value+"&aplicacao="+drop_aplicacao.value+"&busca="+busca.value+"&buscacross="+buscacross.value.replace("Código","")+"&produto="+produto.value,"<img src=images/loading.gif>","enable_all","","");
}else{
alert("O campo 'código' da busca de conversões está vazio.\nA busca será realizada de forma normal, sem exibir conversões.");
carrega_produtos()
}
}
//muda de pagina na paginação
function muda_pagina(p)
{
ajax("produtos_filtros_lista.asp","show_result","PageNo="+p+"&tipo=lista&marca="+marca.value+"&busca="+busca.value+"&produto="+produto.value,"<img src=images/loading.gif>","enable_all","","");
}
function muda_pagina2(p)
{
//alert(4)
ajax("produtos_filtros_lista.asp","show_result","PageNo="+p+"&tipo=lista&marca="+marca.value+"&motor="+drop_motor.value+"&aplicacao="+drop_aplicacao.value+"&buscacross="+buscacross.value.replace("Código","")+"&busca="+busca.value+"&produto="+produto.value,"<img src=images/loading.gif>","enable_all","","");
}
//mostra um produto quando selecionado
function show_produto(id,prod,save)
{
if (save != "1")
{
guarda.innerHTML = show_result.innerHTML;
}
ajax("produtos_filtros_lista.asp","show_result","tipo=show&codigo="+id+"&produto="+prod,"<img src=images/loading.gif>","enable_all","","");
BACKIMG.style.visibility="visible";
}
//volta para a listagem
function voltar()
{
show_result.innerHTML = guarda.innerHTML;
BACKIMG.style.visibility="hidden";
}
//disabilita os campos enquanto roda um ajax
function disable_all()
{
/*busca.disabled=true;
marca.disabled=true;
produto.disabled=true;
drop_aplicacao.disabled=true;
buscar.disabled=true;*/
}
//habilita de volta os campos quando termina de rodas o ajax
function enable_all()
{
/*busca.disabled=false;
marca.disabled=false;
produto.disabled=false;
drop_aplicacao.disabled=true;
buscar.disabled=false;*/
}
function selectiona_tipo(t)
{
produto.value = t;
carrega_produtos();
}
//carrega os campos iniciais
//carrega_prod();
if (busca.value != "")
{
carrega_produtos();
}
///////////////////////////////////////////////////
