﻿var ie = /msie/i.test(navigator.userAgent);
function ValidarCPF(Objcpf)
{        
	var cpf = Objcpf.value;        
	exp = /\.|\-/g        
	cpf = cpf.toString().replace( exp, "" );         
	var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10));        
	var soma1=0, soma2=0;        
	var vlr = 11;                
	for(i=0;i<9;i++)
	{                
		soma1+=eval(cpf.charAt(i)*(vlr-1));                
		soma2+=eval(cpf.charAt(i)*vlr);                
		vlr--;        
	}               
	soma1 = (((soma1*10)%11)==10 ? 0:((soma1*10)%11));        
	soma2=(((soma2+(2*soma1))*10)%11);                
	soma2=(((soma2)==10) ? 0: (soma2));
	var digitoGerado=(soma1*10)+soma2;        
	if(digitoGerado!=digitoDigitado)  
	{                      
		alert('CPF Invalido!');      
	}
	else 
	{
        document.formulario.CPFIDF.style.color='#036110';
		abrirPag2('valida_cnpj.php?cnpj=' + document.getElementById('CPFIDF').value);
		return false;
	} 
		return true;	
		
		
}

function validaCNPJ(flag) 
{
	
                CNPJ = document.formulario.CNPJIDF.value;
                erro = new String;
				if (CNPJ.length == 0) 
				{
				    return false;
				}
                if (CNPJ.length < 18) erro += "É necessario preencher corretamente o número do CNPJ! \n\n";
                if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-"))
				{
					if (erro.length == 0) erro += "É necessário preencher corretamente o número do CNPJ! \n\n";
                }
                //substituir os caracteres que não são números
               if(document.layers && parseInt(navigator.appVersion) == 4){
                       x = CNPJ.substring(0,2);
                       x += CNPJ.substring(3,6);
                       x += CNPJ.substring(7,10);
                       x += CNPJ.substring(11,15);
                       x += CNPJ.substring(16,18);
                       CNPJ = x;
               } else {
                       CNPJ = CNPJ.replace (".","");
                       CNPJ = CNPJ.replace (".","");
                       CNPJ = CNPJ.replace ("-","");
                       CNPJ = CNPJ.replace ("/","");
               }
               var nonNumbers = /\D/;
               if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n";
               var a = [];
               var b = new Number;
               var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
               for (i=0; i<12; i++){
                       a[i] = CNPJ.charAt(i);
                       b += a[i] * c[i+1];
               }
               if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
               if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
               b = 0;
               for (y=0; y<13; y++) {
                       b += (a[y] * c[y]);
               }
               if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
               if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
                       erro +="Verifique o numero e tente novamente!";
               }
               if (erro.length > 0){
                       document.formulario.CNPJIDF.style.color='#ff0000';
                       alert(erro);
					   document.getElementById('CNPJIDF').value = '';
					   
                       //return false;
               } else {

                       document.formulario.CNPJIDF.style.color='#036110';
				
						if(flag != 1)
							
							abrirPag('valida_cnpj.php?cnpj=' + document.getElementById('CNPJIDF').value);
							
							return false;
						} 
					return true;	
               }

 function FormataCnpj(campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 14)
	{
	   if (tam == 3)
	      campo.value = vr.substr(0, 2) + '.';
	   if (tam == 6)
	      campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 5) + '.';
	  if (tam == 10)
	      campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(6, 3) + '/';
	  if (tam == 15)
		campo.value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + '.' + vr.substr(6, 3) + '/' + vr.substr(9, 4) + '-' + vr.substr(13, 2);
	}
}

function PermiteNumeros()
{
   var tecla = window.event.keyCode;
  tecla     = String.fromCharCode(tecla);
  if(!((tecla >= "0") && (tecla <= "9")))
  {
    
	window.event.keyCode = 0;
  }
}
function MascaraTelefone(objeto)
{ 
   if(objeto.value.length == 0)
     objeto.value = '(' + objeto.value;

   if(objeto.value.length == 3)
      objeto.value = objeto.value + ')';

 if(objeto.value.length == 8)
     objeto.value = objeto.value + '-';
}
function valida_relatorio()
{
	if(document.formulario.data_inicial.value == '')
	{
         alert('O campo Data Inicial deve ser preenchido!')
		 document.formulario.data_inicial.focus();
		 return false;	
	}
	if(document.formulario.data_final.value == '')
	{
         alert('O campo Data Final deve ser preenchido!')
		 document.formulario.data_final.focus();
		 return false;	
	}	
	document.formulario.submit();
}
function valida_relatorio_detalhe()
{
	if(document.formulario.NR_PEDIDO.value == '')
	{
         alert('O campo Nr Pedido deve ser preenchido!')
		 document.formulario.NR_PEDIDO.focus();
		 return false;	
	}	
	document.formulario.submit();
}
function valida_departamento()
{
	if(document.formulario.nome.value == '')
	{
         alert('O campo Nome deve ser preenchido!')
		 document.formulario.nome.focus();
		 return false;	
	}
	if(document.formulario.email.value == '')
	{
         alert('O campo E-mail deve ser preenchido!')
		 document.formulario.email.focus();
		 return false;	
	}	
	else
	{
		var obj = eval("document.formulario.email");
		var txt = obj.value;
		if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 4)))
		{
			alert('Preencha E-mail com um endereco valido');
			obj.focus();
			return false;
		}
		
	}	
	if(document.formulario.fone.value == '')
	{
         alert('O campo Telefone deve ser preenchido!')
		 document.formulario.fone.focus();
		 return false;	
	}
	if(document.formulario.fone.value.length < 13)
	{
         alert('Numero Tel inválido!')
		 document.formulario.fone.focus();
		 return false;		
	}
	if(document.formulario.departamento.value == '')
	{
         alert('O campo Departamento deve ser preenchido!')
		 document.formulario.departamento.focus();
		 return false;	
	}
	document.formulario.submit();
}
function mostra_frame_carrinho(fl)
        {
			document.getElementById('iframe_carrinho').style.visibility='visible';
            document.iframe_carrinho.location = 'iframe_carrinho.php?fl='+ fl;
        }
function txtBoxFormat(objForm, strField, sMask, evtKeyPress, evtBotao)
{
 var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	var ie = /msie/i.test(navigator.userAgent);
	var ieBox = ie && (document.compatMode == null || document.compatMode == "BackCompat");

	if (ie)
		nTecla = evtKeyPress.keyCode;
	else
		nTecla = evtKeyPress.which;

    if (evtBotao == "enter" || nTecla == 13) document.formulario.submit();
	if (nTecla == 8) return true;
	if (nTecla == 0) return true;

	/*if(document.formulario) { // Internet Explorer
	  nTecla = evtKeyPress.keyCode; }
	  else if(document.formulario) { // Nestcape
	  nTecla = evtKeyPress.which;
	  }*/

	sValue = objForm[strField].value;
	// Limpa todos os caracteres de formatação que
	// já estiverem no campo.
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( "-", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( ".", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "/", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( "(", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( ")", "" );
	sValue = sValue.toString().replace( " ", "" );
	sValue = sValue.toString().replace( " ", "" );
        sValue = sValue.toString().replace( ":", "" );
	fldLen = sValue.length;
	mskLen = sMask.length;

	i = 0;
	nCount = 0;
	sCod = "";
	mskLen = fldLen;

	while (i <= mskLen) {
		bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ":") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
			bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

			if (bolMask) {
				sCod += sMask.charAt(i);
				mskLen++; }
			else {
				sCod += sValue.charAt(nCount);
				nCount++;
			}
		i++;
	}

	objForm[strField].value = sCod;
	if (nTecla != 8) { // backspace
		if (sMask.charAt(i-1) == "9") { // apenas números...
			return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
		else { // qualquer caracter...
			return true;
		}
	} else {
		return true;
	}
}

function numbers(evt, bloqueio_especial)
    {
        
		var key_code = evt.keyCode  ? evt.keyCode  :
                       evt.charCode ? evt.charCode :
                       evt.which    ? evt.which    : void 0;


		
		if (bloqueio_especial == key_code)
        {            
			return false;
        }
		// Habilita teclas <DEL>, <TAB>, <ENTER>, <ESC> e <BACKSPACE>
        
		if (key_code == 8  ||  key_code == 9  ||  key_code == 27  ||  key_code == 46||  key_code == 44)
        {
            return true;
        }

        // Habilita teclas <HOME>, <END>, mais as quatros setas de navegação (cima, baixo, direta, esquerda)
        //else if ((key_code >= 35)  &&  (key_code <= 40))
        //{
        //    return true
        //}

        // Habilita números de 0 a 9
        else if ((key_code >= 48)  &&  (key_code <= 57))
        {
            return true
        }

        return false;
    }

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

function pega_cod_stq(cod_stq)
{
	 document.conteudo.cod_stq.value = cod_stq;	 	 
	 //alert('oi');
}

function add_cart_1(campo_qtde)
{
	
	qtd = campo_qtde;

	if(qtd !=0)
	{
		cod_stq = document.formulario.cod_stq.value;
		document.getElementById('iframe_detalhe_carrinho').src = 'iframe_detalhe_carrinho.php?productId=' + cod_stq + '&add=' + cod_stq + '&fl=1&qtd=' + qtd;
		document.getElementById('iframe_detalhe_carrinho').style.visibility='visible';
		document.getElementById('iframe_detalhe_carrinho2').style.visibility='hidden';
		document.getElementById('iframe_detalhe_carrinho5').style.visibility='hidden';
	}
	else
	{
	    return false;
	}
}

function add_cart_2(campo_qtde)
{
	
	qtd = campo_qtde;
	if(qtd !=0)
	{
		cod_stq = document.formulario.cod_stq.value;
		document.getElementById('iframe_detalhe_carrinho2').src = 'iframe_detalhe_carrinho2.php?productId=' + cod_stq + '&add=' + cod_stq + '&fl=2&qtd=' + qtd;
		document.getElementById('iframe_detalhe_carrinho2').style.visibility='visible';
		document.getElementById('iframe_detalhe_carrinho').style.visibility='hidden';
		document.getElementById('iframe_detalhe_carrinho5').style.visibility='hidden';
		}
	else
	{
	   return false;
	}
}

function add_cart_3(campo_qtde)
{
	qtd = campo_qtde;
	if(qtd !=0)
	{
		cod_stq = document.formulario.cod_stq.value;
		document.getElementById('iframe_detalhe_carrinho3').src = 'iframe_detalhe_carrinho3.php?productId=' + cod_stq + '&add=' + cod_stq + '&fl=3&qtd=' + qtd;
		document.getElementById('iframe_detalhe_carrinho3').style.visibility='visible';
		document.getElementById('iframe_detalhe_carrinho2').style.visibility='hidden';
		document.getElementById('iframe_detalhe_carrinho').style.visibility='hidden';
		document.getElementById('iframe_detalhe_carrinho5').style.visibility='hidden';
		}
	else
	{
	   return false;
	}
}

function add_cart_5(campo_qtde)
{
	qtd = campo_qtde;
	if(qtd !=0)
	{
		cod_stq = document.formulario.cod_stq.value;
		document.getElementById('iframe_detalhe_carrinho5').src = 'iframe_detalhe_carrinho5.php?productId=' + cod_stq + '&add=' + cod_stq + '&fl=5&qtd=' + qtd;
		document.getElementById('iframe_detalhe_carrinho5').style.visibility='visible';
		document.getElementById('iframe_detalhe_carrinho').style.visibility='hidden';
		document.getElementById('iframe_detalhe_carrinho2').style.visibility='hidden';
	}
	else
	{
	     return false;
	}	
}



function ordenar() {
   var ordem=document.getElementById('ordena').value;
   var itens=document.getElementById('itens').value;   
   window.location = 'm_search.php?ordem='+ordem+'&itens='+itens+'&pag=1';
}
function pega_cod_stq(cod_stq)
{
	 document.formulario.cod_stq.value = cod_stq;
}



var lista="";
var qtd="";
var cod="";


function valida_qtde_limite(unid_lote, limite, qtde)
{
	var calcula = (qtde.value / unid_lote);
	valor = parseInt(calcula);
	
	if(unid_lote > 1)
	{	  
	  if (valor == calcula) 
	  {     
		if(qtde.value > limite)
		{
			alert('O numero de itens selecionados é maior do que o disponível em estoque. Favor verificar!');
			return false;
		}
		if(qtde.value > 150)
		{
			alert('Excedido o limite de 150 itens por produto. Favor verificar!');		
			return false;
		}
		return true;
      }
	  else
	  {
			alert("O produto pode ser vendido apenas em multiplos de " + unid_lote + " Unidade(s)");
			return false; 
	  }
	}
	else if(unid_lote == 1)
	{
		if(qtde.value > limite)
		{
			alert('O numero de itens selecionados é maior do que o disponível em estoque. Favor verificar!');
			return false;
		}
		if(qtde.value > 150)
		{
			alert('Excedido o limite de 150 itens por produto. Favor verificar!');		
			return false;
		}
		return true;
	}	
}
function valida_valor_faturamento_direto(pr_minimo, pr)
{
	//alert(pr.value);
	//pr.value=pr.value.replace(',','.')
	if(pr_minimo > pr.value)
	{

		alert('O valor deve ser igual ou superior ao preço para a revenda!');
		return false;
	}
	return true;
}
function valida_hora(hora,campo_formulario) //coloca mascara para hora
{
                var myhora = '';

                myhora = myhora + hora;

                if (myhora.length == 2){
                               myhora = myhora + ':';
                               campo_formulario.value = myhora;
                }
                if (myhora.length == 5){
                               verifica_hora(campo_formulario);
                }
} 

function verifica_hora(campo_formulario)
{

	
	hrs = (campo_formulario.value.substring(0,2));
    min = (campo_formulario.value.substring(3,5));
    situacao = "";
    // verifica data e hora
    if ((hrs < 00 ) || (hrs > 23) || ( min < 00) ||( min > 59))
	{
		alert("o campo HORÁRIO deve ser preenchido corretamente!");
        campo_formulario.focus();	
		return false;
    }

    if (campo_formulario.value == "") 
	{
        alert("o campo HORÁRIO deve ser preenchido corretamente!");
        campo_formulario.focus();
		return false;
    }

    if ((hrs < 08 ) || (hrs > 17) || ( min < 00) ||( min > 59))
	{
		alert("o campo HORÁRIO deve ser preenchido de acordo com nosso horário de atendimento!");
        campo_formulario.focus();	
		return false;
    }
								
}




function valida()

{
	var subtotal = document.getElementById('subtotal').value;
	if(subtotal < 300)
	{
		alert('O pedido mínimo permitido é de R$ 300,00 para pagamento a vista e R$ 500,00 para faturamento.Complete seu pedido!');
		return false;
	} 
var atransp = document.getElementsByName("frete");
if (atransp.length > 0) {

for (var i=0;i<atransp.length;i++){ 
	if (atransp[i].checked)  { transp = atransp[i].value;  }
 }
document.getElementById("fretecif").value ="S";
    
if (transp == 999) {
	//if (!validaCNPJ()) { alert("É necessário preencher um CNPJ válido da transportadora!"); 	return false;	}
	//if (document.getElementById("transpnome").value == '') { alert("É necessário preencher o nome da transportadora!");	return false;	}
	//if (document.getElementById("transptel").value == '') {	alert("É necessário preencher o telefone da transportadora!");	return false;	}
	
	document.getElementById("obscar").value = 'Logistica (TRANSP:'+document.getElementById("transpnome").value+',CNPJ:'+document.getElementById("CNPJID").value+')';
    document.getElementById("transpcodigo").value =document.getElementById("transpcodigo").value;
	document.getElementById("fretecif").value ="N";
}

if (transp == 13) {
	//if (document.getElementById("pnome").value == '') {	alert("É necessário preencher o nome do portador!");	return false;	}
	//if (document.getElementById("prg").value == '') { alert("É necessário preencher o RG do portador!");	return false;	}
	//if (document.getElementById("phora").value == '') { alert("É necessário preencher o horário da retirada!");	return false;	}	
	document.getElementById("obscar").value = 'Logistica (NOME:'+document.getElementById("pnome").value+',RG:'+document.getElementById("prg").value+')';
    document.getElementById("fretecif").value ="N";    
}

}

document.paga.submit();
}


function Lista1(){
    lista="";
    var aChk = document.getElementsByName("qtd");  
 for (var i=0;i<aChk.length;i++){  
      if (aChk[i].checked == true){  
         lista = lista+aChk[i].value;
      }  
      
 }
}

function Lista(fl, cod_stq_excluir)
{

 var aChk2 = document.getElementsByName("set");      
 var aChk = document.getElementsByName("qtd");  
 
 for (var i=0;i<aChk.length;i++){  
         
		 cod = cod+aChk2[i].value+",";			 
		 if(aChk2[i].value == cod_stq_excluir)
		 {		
			qtd = qtd+"0,";
		 }
		 else
		 {		
			qtd = qtd+aChk[i].value+",";
		 }
         
 }
cod=cod.substring(0, cod.length-1);
qtd=qtd.substring(0, qtd.length-1);

    window.location = 'm_carrinho.php?cod='+cod+'&qtd='+qtd+'&fl='+fl;   
}

function ListaIntermediacao(fl){
 
 var aChk2 = document.getElementsByName("set");      
 var aChk = document.getElementsByName("qtd");  
 var aChk3 = document.getElementsByName("intermediacao");  
 var intermediacao = '';
 
 for (var i=0;i<aChk.length;i++){  
         qtd = qtd+aChk[i].value+",";
         cod = cod+aChk2[i].value+",";
		 intermediacao_string = intermediacao+aChk3[i].value.replace(",", ".");
		 intermediacao = intermediacao_string+",";
 }
cod=cod.substring(0, cod.length-1);
qtd=qtd.substring(0, qtd.length-1);
intermediacao=intermediacao.substring(0, intermediacao.length-1);
window.location = 'm_carrinho.php?cod='+cod+'&qtd='+qtd+'&fl='+fl+'&intermediacao='+intermediacao;   
}

function carList(){
    window.location = 'm_carrinho.php?cod='+cod+'&qtd='+qtd;  
}

function enviar_cnpj(flag)
{	
	if ((window.event ? event.keyCode : event.which) == 13)
    {  		
		
		if(validaCNPJ(flag.value) == false)
		{		    
			alert('Verifique o CNPJ');
			return false;
		}
		else
		{		
			abrirPag('../includes/testacadastro.php?cnpj=' + document.getElementById('CNPJIDF').value);
			return true;
		}
    }

}

function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}
function validaDat(campo,valor) {
	var date=valor;
	var ardt=new Array;
	var ExpReg=new RegExp("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[12][0-9]{3}");
	ardt=date.split("/");
	erro=false;
	if ( date.search(ExpReg)==-1){
		erro = true;
		}
	else if (((ardt[1]==4)||(ardt[1]==6)||(ardt[1]==9)||(ardt[1]==11))&&(ardt[0]>30))
		erro = true;
	else if ( ardt[1]==2) {
		if ((ardt[0]>28)&&((ardt[2]%4)!=0))
			erro = true;
		if ((ardt[0]>29)&&((ardt[2]%4)==0))
			erro = true;
	}
	if (erro) {
		alert("\"" + valor + "\" não é uma data válida!!!");
		campo.value = "";
		campo.focus();		
		return false;
	}
	
	return true;
}
function F5(event) 
{var tecla = document.all ? window.event.keyCode : event.which;if (document.all) 
	{ window.event.keyCode = 0; window.event.returnValue = false; }
	if (tecla == 116) return false;
}

function CalculaMargem(fl)
{
var aChk2 = document.getElementsByName("set");      
var aChk = document.getElementsByName("margem");  
for (var i=0;i<aChk.length;i++)
{  
    margem = margem+aChk[i].value+",";
    margem = margem+aChk2[i].value+",";
 }
cod=cod.substring(0, cod.length-1);
margem=margem.substring(0, qtd.length-1);
} 
function valida_rma()
{
	d = document.form_dados;

	if(d.nome_tecnico.value == '')
	{
         alert('O campo Nome do técnico deve ser preenchido!')
		 document.form_dados.nome_tecnico.focus();
		 return false;		 
	}
	if(d.tel_tecnico.value == '')
	{
         alert('O campo Telefone do técnico deve ser preenchido!')
		 document.form_dados.tel_tecnico.focus();
		 return false;		 
	}	
	
	if(d.email_tecnico.value == '')
		{
			 alert('O campo E-mail do técnico deve ser preenchido!')
			 document.form_dados.email_tecnico.focus();
			 return false;	
		}
		else
		{
			var obj = eval("document.form_dados.email_tecnico");
			var txt = obj.value;
			if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 1)))
			{
				alert('Preencha com um endereco de email válido');
				obj.focus();
				return false;
			}
			
		}
		document.form_dados.submit();
}
function valida_tranp_fob()
{
	d = document.formulario;
	//alert(d.CNPJIDF.value);
	if(d.CNPJIDF.value == '')
	{
         alert('O campo cnpj deve ser preenchido!')
		 d.CNPJIDF.focus();
		 return false;		 
	}
	if(d.ie.value == '')
	{
         alert('O campo Inscrição Estadual deve ser preenchido!')
		 d.ie.focus();
		 return false;		 
	}	
	
	if(d.nfantasia.value == '')
	{
         alert('O campo nome fantasia deve ser preenchido!')
		 d.nfantasia.focus();
		 return false;		 
	}
	if(d.transportadora.value == '')
	{
         alert('O campo nome da transportadora deve ser preenchido!')
		 d.transportadora.focus();
		 return false;		 
	}
	if(d.contato.value == '')
	{
         alert('O campo contato deve ser preenchido!')
		 d.contato.focus();
		 return false;		 
	}
	if(d.endereco.value == '')
	{
         alert('O campo endereço deve ser preenchido!')
		 d.endereco.focus();
		 return false;		 
	}
	if(d.fone.value == '')
	{
         alert('O campo fone deve ser preenchido!')
		 d.fone.focus();
		 return false;		 
	}
	if(d.bairro.value == '')
	{
         alert('O campo bairro deve ser preenchido!')
		 d.bairro.focus();
		 return false;		 
	}
	if(d.cep.value == '')
	{
         alert('O campo cep deve ser preenchido!')
		 d.cep.focus();
		 return false;		 
	}
	if(d.cidade.value == '')
	{
         alert('O campo cidade deve ser preenchido!')
		 d.cidade.focus();
		 return false;		 
	}
	if(d.uf.value == '')
	{
         alert('O campo UF deve ser preenchido!')
		 d.uf.focus();
		 return false;		 
	}
	document.formulario.submit();
}
	function mostra_div()
	{
		document.getElementById('transp_cadastradas').style.visibility = 'hidden'; 
		document.getElementById('frete_fob').style.visibility = 'visible';
	}



