function CheckCampos(Form,campos) { 
var campos = campos;
	var controle = 0;
	var Formulario = "document." + Form;
	var formu = Form;
	var arr_campos = campos.split(",");
	for(i=0;i<=arr_campos.length-1;i++) { 
	 var Linha = document.getElementById('Linha'+arr_campos[i]);
	 var campo = arr_campos[i];
	if(document.getElementById(arr_campos[i]).value == '') { 
			Linha.style.display = '';
			var controle = 1
		}
	}
if(controle == 0) { 
		document.getElementById(formu).submit();
	}
}
// JavaScript Document
function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {

var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	
      if(document.all) { // Internet Explorer
        nTecla = evtKeyPress.keyCode; }
      else if(document.layers) { // 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( " ", "" );
      fldLen = sValue.length;
 
      i = 0;
      nCount = 0;
      sCod = "";
      mskLen = fldLen;

      while (i <= mskLen) {
        bolMask = ((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 valida_campos(){

	if(document.form.doc.value==''){
		alert('Por favor, preencha o campo CNPJ/CPF!');
		document.form.doc.focus()
		return false;
	}
	
	if(document.form.senha.value==''){
		alert('Por favor, insira a sua senha!');
		document.form.senha.focus()
		return false;
	}
	
		document.form.submit();
}

function mostrar(passo_a_passo){ 
document.getElementById(passo_a_passo).style.visibility="visible"; 
} 

function ocultar(passo_a_passo){ 
document.getElementById(passo_a_passo).style.visibility="hidden"; 
} 

function mostrar(nf){ 
document.getElementById(nf).style.visibility="visible"; 
} 

function ocultar(nf){ 
document.getElementById(nf).style.visibility="hidden"; 
} 
function teste(numero) { 
	alert(numero);
}

function ExibeImagemClick(campo,img, acao,texto) { 
	if (acao==1) { 
			void(document.getElementById('MostraImagem').style.display='');
			void(document.getElementById('Descricao').innerHTML = texto);
			img.src = campo; //.value;
//			alert(campo);

	} else {
			void(document.getElementById('MostraImagem').style.display='none');
	}
}


function PecaTamanho(peca) { 
//alert(peca);
	var texto = "<input type='text' name=tamanho"+peca+"  style='border: 1px solid #666666'> "+ peca + "<br>";
	void(document.getElementById('TamanhoPecas').innerHTML += texto);
//	alert(document.getElementById('tamanho'+peca).value);
	peca = '';
}


// -->
function exibecate() { 

	var linha = document.getElementById('novacategoria').style.display;
	if(linha=='') { 
	
		document.getElementById('novacategoria').style.display ='none';
	} else  { 
		document.getElementById('novacategoria').style.display = '';
	} 
	


} 
function detalheLoja(loja) { 
//alert(loja);
//	alert(document.getElementById(loja).style.display);
	if(document.getElementById(loja).style.display=='none') { 
	
		document.getElementById(loja).style.display = '';
	} 
	else { 
	
		document.getElementById(loja).style.display = 'none';
	
	} 

} 

function exibeMapa(loja) { 
//alert(loja);
//	alert(document.getElementById(loja).style.display);
	if(document.getElementById(loja).style.display=='none') { 
		document.getElementById('seta').src='images/exibe.png';
		document.getElementById(loja).style.display = '';
	} 
	else { 
		document.getElementById('seta').src='images/naoexibe.png';
		document.getElementById(loja).style.display = 'none';
	
	} 

} 

function exibeLinha(Linha1,Linha2) { 

	var vLinha1 = document.getElementById(Linha1).style.display;
	var vLinha2 = document.getElementById(Linha2).style.display;
	if(vLinha1=='none') { 
		document.getElementById(Linha1).style.display = '';
		document.getElementById(Linha2).style.display = 'none';
	} 
	else { 
		document.getElementById(Linha1).style.display = 'none';
		document.getElementById(Linha2).style.display = '';
	} 
													  

} 

function FiltraLista(SubCamp,Camp,NomeCamp) { 
	if(SubCamp!='') { 
		
		location.href='ListaPecas.asp?id='+Camp+'&Camp='+NomeCamp+'&subcamp='+SubCamp;
		
	} 

} 
function criaMascara(_RefObjeto, _Modelo){

var valorAtual = _RefObjeto.value;
var valorNumerico = '';
var nIndexModelo = 0;
var nIndexString = 0;
var valorFinal = '';
var adicionarValor = true;
 

// limpa a string valor atual para verificar
// se todos os caracteres são números
for (i=0;i<_Modelo.length;i++){
  if (_Modelo.substr(i,1) != '#'){
    valorAtual = valorAtual.replace(_Modelo.substr(i,1),'');
}}
 
// verifica se todos os caracteres são números
for (i=0;i<valorAtual.length;i++){
  if (!isNaN(parseFloat(valorAtual.substr(i,1)))){
    valorNumerico = valorNumerico + valorAtual.substr(i,1);
}}
 
// aplica a máscara ao campo informado usando
// o modelo de máscara informado no script
for (i=0;i<_Modelo.length;i++){
 
  if (_Modelo.substr(i,1) == '#'){
    if (valorNumerico.substr(nIndexModelo,1) != ''){
      valorFinal = valorFinal + valorNumerico.substr(nIndexModelo,1);
      nIndexModelo++;nIndexString++;
    }
      else {
        adicionarValor = false;
  }}
 
    else {
      if (adicionarValor && valorNumerico.substr(nIndexModelo,1) != ''){
      valorFinal = valorFinal + _Modelo.substr(nIndexString,1)
      nIndexString++;
    }}
}
 
_RefObjeto.value = valorFinal
 
}

function Numero(e){
		navegador = /msie/i.test(navigator.userAgent);
		if (navegador)
			var tecla = event.keyCode;
		else
			var tecla = e.which;
		
		if(tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else{
			if (tecla != 8) // backspace
				return false;
			else
				return true;
		}
	}

function assinaGrupoLiberty(valor){
	if(valor == 'Grupo Liberty'){
		document.all["nome"].value = '';
		document.all["nome"].disabled=true;
		
		document.all["filial"].value = '';
		document.all["filial"].disabled=true;
	} else if(valor == 'Assinatura') {
		alert("Selecione uma assinatura");
		document.all["gerente"].focus();
		document.all["nome"].disabled=false;
		document.all["filial"].disabled=false;
	} else{
		document.all["nome"].disabled=false;
		document.all["filial"].disabled=false;
	}

	return true;
}

function exibeGer(escolha,destino) { 
	if(escolha==1) { 
	
		document.getElementById(destino).style.display = 'block';
		document.getElementById('filial').style.display = 'block';
		document.getElementById('Assinatura2').style.display = 'none';
		document.getElementById('nome').value = '';
		document.getElementById('nome').readOnly= false;

	
	} else if(escolha==2) { 
	
		document.getElementById(destino).style.display = 'none';
		document.getElementById('filial').style.display = 'none';
		document.getElementById(destino).value = '';
		document.getElementById('filial').value = '';
		document.getElementById('nome').value = 'Grupo Liberty';
		document.getElementById('nome').readOnly= true;
	} 

} 


function exibeConf(valor) { 

	if(valor==1) { 
	
		document.getElementById('confirmanome').style.display = 'block';
		document.getElementById('confirmatel').style.display = 'block';
		document.getElementById('confirma').value = '';
	} else { 
	
		document.getElementById('confirmanome').style.display = 'none';
		document.getElementById('confirmatel').style.display = 'none';
		document.getElementById('confirma').value = '';
		document.getElementById('confirmanome').value = '';
		document.getElementById('confirmatel').value = '';

	
	} 

} 

function Comentarios(Nota, idFornecedor) { 


	document.getElementById('Comentarios').style.display = '';
	document.frmQuali.Nota.value = Nota;
	
	
	if(Nota=='A') { 
	
		document.getElementById('Comentarios').bgColor = '#FFFFFF';
	
	} else { 
	
		document.getElementById('Comentarios').bgColor = '#ffd2d2';


	} 

} 
function marca(campo, valor) { 
	for (i=0; i<valor; i++){
		 	campo[i].checked = true ; 
			if (i==valor-1){
				campo[i].checked = false ; 	
			}
	}

} 
		 
		 
function desmarca(campo, valor) { 
	for (i=0; i<valor-1; i++){ 
			campo[i].checked = false;
			if (i==valor-1){
				campo[i].checked = true; 	
			}
	}		
 } 
function deleta(id,tabela) { 

	var decisao = confirm('Tem certeza que deseja excluir?');
		
		if(decisao) { 
			
			location.href='Deleta.asp?id='+id+'&tb='+tabela;
		} 

}

