// aqui eu passo um paramentro para o usuario
function cotaut()
{
    if(confirm('Deseja Enviar Outro E-mail?'))
	   {
	    document.location.href='automacao.asp';
	   }
	   else
	   {
	    document.location.href='principal.asp';
	   }   
}
// aqui eu passo um paramentro para o usuario
function cotper()
{
    if(confirm('Deseja Enviar Outro E-mail?'))
	   {
	    document.location.href='cotacaoperifericos.asp';
	   }
	   else
	   {
	    document.location.href='principal.asp';
	   }   
}
// aqui eu passo um paramentro para o usuario
function cotimp()
{
    if(confirm('Deseja Enviar Outro E-mail?'))
	   {
	    document.location.href='cotacaoimpressora.asp';
	   }
	   else
	   {
	    document.location.href='principal.asp';
	   }   
}
// aqui eu passo um paramentro para o usuario
function cotcomp()
{
    if(confirm('Deseja Enviar Outro E-mail?'))
	   {
	    document.location.href='cotacaomicrocomputador.asp';
	   }
	   else
	   {
	    document.location.href='principal.asp';
	   }   
}
// aqui eu passo um paramentro para o usuario
function verif()
{
    if(confirm('Deseja Enviar Outro E-mail?'))
	   {
	    document.location.href='contato.asp';
	   }
	   else
	   {
	    document.location.href='principal.asp';
	   }   
}
//para travar o movimento do mouse, usado em cadservicocarro
function travarmouse2(x)
{ //alert(x.name);
  fui(x);
  return false;
}

//para travar o movimento do mouse, usado em cadservicocarro
function travarmouse()
{
  alert("Não use o mouse e sim o TAB!");
  return false;
}

//F1 e F2 => criadas em 03/10/07 por Márcio e são exclusívas até essa data de: liberarservicocarro e naoliberadoservicocarro
function F1()
{
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,3) == 'chf' && thiselm.checked == 1) 
         { 
		   car1 = elements[i + 1]; //alert(car1.name);
		   fornec1 = elements[i + 3]; //alert(fornec1.name);
           for(a=0;a < elements.length;a++)
	       {  
              thiselm = elements[a]; 
		      if(thiselm.name.substring(0,3) == 'chk') 
              { 
		        car2 = elements[a + 1]; //alert(car2.name);
		        fornec2 = elements[a + 2]; //alert(fornec2.name);
				if(car1.value == car2.value && fornec1.value == fornec2.value)
				{ thiselm.checked = true; }
			  }
		   }
		 }
      }
   }
}

function F2()
{
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,3) == 'chf' && thiselm.checked == 0) 
         { 
		   car1 = elements[i + 1]; //alert(car1.name);
		   fornec1 = elements[i + 3]; //alert(fornec1.name);
           for(a=0;a < elements.length;a++)
	       {  
              thiselm = elements[a]; 
		      if(thiselm.name.substring(0,3) == 'chk') 
              { 
		        car2 = elements[a + 1]; //alert(car2.name);
		        fornec2 = elements[a + 2]; //alert(fornec2.name);
				if(car1.value == car2.value && fornec1.value == fornec2.value)
				{ thiselm.checked = false; }
			  }
		   }
		 }
      }
   }
}

//função que transforma string em vetor e retorna o valor conforme o parâmetro, usado em altpedidoestoque
function vetorbasico(string,opcao,posicao)
{  
   vbasico = string.split(opcao);
   return vbasico[posicao];
}

function vetorbasico2(string,opcao,posicao)
{  
   vetorbasico = string.split (opcao);
   return vetorbasico[posicao];
}
//pegando o primeiro valor do vetor acima
//dia = vetorbasico(0); 

function imprimirgeral()
{ window.print(); }

function troca(x)//aqui troca ponto por virgula, em altcontracheque
{ 
  x = new String(x)
  return trocado = x.replace(".", ","); 
}

function troca2(x) //aqui troca virgula por ponto, em altcontracheque
{ 
  x = new String(x)
  return trocado2 = x.replace(",", "."); 
}

//aqui verifica o cpf ou o cgc da pessoa, usado em cadcliente,alterarfornecedor
function verificando(v,x)
{
  if(x == 'F')
  { verificarCPF(v); }
  else
  {
    if(x == 'J')
	{ cgc(v); }
  }
}

//converte string para caixa alta, em cadestoqueitem
function caixalta(obj)
{ obj.value = obj.value.toUpperCase(); }

//aqui volta para a página anterior "navegação", em convertepecas 
function voltafrente(x)
{ history.go(x) }

//http://info.abril.com.br/forum/forum.php?topico=62152 em 25/10/07
//onClick='document.getElementById("iframe").refresh();' 

//http://forum.ievolutionweb.com/lofiversion/index.php/t10516.html em 25/10/07
//iframe = document.getElementById("nome do iframe").contentWindow;
//iframe.update();
//adaptada da sequencia acima na mesma data, para executar uma função dentro do iframe, em nfiscalservico 
//na página chame assim funciframe('aqui1').vfim2() "funciframe('nome do iframe').nome da função()"
function funciframe(i)
{ 
  funci = document.getElementById(i).contentWindow;
  return funci; 
}

//esquema para pegar valor dentro do iframe, em 25/10/07 não usada até o momento, mas foi testada e aprovada.
function obter()
{
  var obj = window.frames['aqui1'];
  var viframe = obj.document.form1.vlfina2.value;
  return viframe;
//  alert(viframe);
} 

//aqui dou o refresh em um determinado iframe da página pai, usado em altentpecaslaboratorio
function f5frame()
{ opener.parent.aqui1.history.go(); }

//aqui dou o refresh em um determinado iframe da página pai, usado em cadestoque
function f5frame1()
{ opener.parent.aqui11.history.go(); }

//aqui dou o refresh no iframe da página pai, usado em menu
function f5menu()
{ opener.parent.aqui.history.go(); }

//aqui pinta um determinado input, conforme a cor passada, usado em cadequipacontrato
function pintar(x,c)
{ 
  pintar = x.style.backgroundColor = c;
}

//função para validação dos campos nas páginas
function fvalidar(x)
{ 
  if(x.value == '' || x.value == 0)
  { x.style.backgroundColor = 'yellow'; }
  else
  { x.style.backgroundColor = 'white'; }
}

//função para validação dos campos nas páginas com o valor vázio
function fvalidarvazio(x)
{ 
  if(x.value == '')
  { x.style.backgroundColor = 'yellow'; }
  else
  { x.style.backgroundColor = 'white'; }
}

//função para validação dos combos nas páginas, onde tem zero é um "sim/não"
function fvalidarcombo(x)
{ 
  if(x.value == '' || x.value == 0)
  { x.style.backgroundColor = 'yellow'; }
  else
  { x.style.backgroundColor = 'white'; }
}

//função para validação dos campos nas páginas, com figuras...
function fvalidar2(x,id)
{ 
//  if(x == '' || x == 0)
  if(x == '')
  { document.getElementById(id).innerHTML = '<img src="images/exclamation.gif" width="16" height="16">'; }
  else
  { document.getElementById(id).innerHTML = '<img src="images/accept.gif" width="16" height="16">'; } 
}

//aqui para dá o refresh na página, usado em duplicata
function f5()
{ location.reload(); }

//faz a troca do desenho conforme o valor de x, usado em cadservicocarro
function trocarfig(x,i)
{ 
  if(x != '')
  {document.getElementById(i).innerHTML = x; } 
}

//faz a troca do desenho conforme o valor de x, usado em altrat
function qualseveridade(x)
{ //alert(x);
  if(x == 1)
  {document.getElementById('figu').innerHTML = "<img src='images/verde.gif' width='12' height='12'>";} 
  else
  {
    if(x == 2)
    {document.getElementById('figu').innerHTML = "<img src='images/preto.gif' width='12' height='12'>";} 
    else
	{
	  if(x == 3)
      {document.getElementById('figu').innerHTML = "<img src='images/amarelo.gif' width='12' height='12'>";} 
      else
      {
	    if(x == 4)
	    {document.getElementById('figu').innerHTML = "<img src='images/vermelho.gif' width='12' height='12'>";} 
      }
	}
  }
}

//exibindo a camada e dando o foco, usado em altrat
function mostrar2(nomeCamada,x,y)
{
 if(x == 1)
 { 
   document.getElementById(nomeCamada).style.visibility="visible"; 
   y.focus();
 }
 else
 {
   if(x == 0)
   { document.getElementById(nomeCamada).style.visibility="hidden"; }
 }
}

//exibindo a camada, usado em altrat
function mostrar(nomeCamada,x)
{
 if(x == 1)
 { document.getElementById(nomeCamada).style.visibility="visible"; }
 else
 {
   if(x == 0)
   { document.getElementById(nomeCamada).style.visibility="hidden"; }
 }
}

//aqui verifica se a data é um sábado ou domingo, e altera conforme abaixo, usado em receberfaturado
function dtfds(r) 
{  
   dd = r.value;
   d = dd.substring(0,2)
   m = dd.substring(3,5)
   y = dd.substring(6,10)
   dts = d + '/' + m + '/' + y;
   x = y + '/' + m + '/' + d;
   data = new Date(x);
   dia = data.getDay()
   if(dia == 0)
   {
   	    alert('Essa data é Domingo!\nVou alterar para Segunda-feira!');
	    r.value = somadias(dts,1);
   }
   else
   { 
      if(dia == 6)
	  {
	     alert('Essa data é Sábado!\nVou alterar para Segunda-feira!');
	     r.value = somadias(dts,2);
	  }
   }
}
function FormataCNPJCPF(campo,opcao)
{  
	var tecla = event.keyCode;
	tipo = form1.tipocliente.value;
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length + 1; 
	if (tecla != 9 && tecla != 8)
	{
		   if (tipo == "J" && opcao == 0)
		   { 
  		    if ( tam > 2 && tam < 6) //faz o cgc do cliente
				campo.value = (vr.substr(0,2)+'.'+vr.substr(2,3));
			if ( tam >= 6 && tam <10)
				campo.value = (vr.substr(0,2)+'.'+vr.substr(2,3)+'.'+vr.substr(6,3));
			if ( tam >= 10 && tam <14)
				campo.value = (vr.substr(0,2)+'.'+vr.substr(2,3)+'.'+vr.substr(6,3)+'/'+vr.substr(10,4));
			if ( tam >= 14)
				campo.value = (vr.substr(0,2)+'.'+vr.substr(2,3)+'.'+vr.substr(6,3)+'/'+vr.substr(10,4)+'-'+vr.substr(14,2));  
		   }	
           else
		   {
		      if (tipo == "F" && opcao == 0)
		      {
		         if ( tam > 3 && tam < 7) //faz o cpf do cliente
				 campo.value = (vr.substr(0,3)+'.'+vr.substr(3,3));
			     if ( tam >= 7 && tam <11)
				 campo.value = (vr.substr(0,3)+'.'+vr.substr(3,3)+'.'+vr.substr(7,3));
			     if ( tam >= 11)
				 campo.value = (vr.substr(0,3)+'.'+vr.substr(3,3)+'.'+vr.substr(7,3)+'-'+vr.substr(10,2));			
		      }
		  }
	}
}

//aqui carregar uma combobox conforme o que for passado, usado em receberfaturado
function carregarcombo(x,ListDestino,y)
{ 
  var r = y
  vb = x + "/" //aqui é para ler toda a string
  var Op = document.createElement("OPTION"); //aqui coloca uma linha em branco na combobox
  Op.text = r;
  Op.value = r;
  ListDestino.options.add(Op);
  r = '';
  for (i = 0; i <= vb.length ; i++) //vai ler todos os digítos da string
  {  
     v = vb.charAt(i);
	 if(v != "/") //aqui monta a linha da combobox
	 {r = r + v;}
	 else
	 { //aqui preenche a linha da combobox
	   var Op = document.createElement("OPTION");
	   Op.text = r;
	   Op.value = r;
	   ListDestino.options.add(Op);
	   r = '';
	 }
  }
}

//aqui faz o submit da página, usado em cadservicocarro
function submetergeral()
{  //alert('comandos');
   form1.submit();
   return;		   
}

//aqui abre a rat de uma combobox, usado em exibirsolicitacaoaut
function vai(combo,v)
{
   var x = combo.selectedIndex;
   var rat = combo.options[x].value;
   if (rat != "")
   {  document.location.href='altrat.asp?cod=' + rat + '&voltar=' + v;  }
}

//função para calcular x e y, com o valor máximo de 99.999,99 ***** usado em orcamentoservicos
function calcgeral(x,y,w)
{ 
   var a,b;
   v = y;
   tam = 0;
   tam = y.length; //alert('calc ' + x + ' ' + y + ' ' + w); 
   tamx = x.length; //alert('calc ' + x + ' ' + y + ' ' + w); 
   if(tamx >= 8) 
   { 
      a = x.toString().replace('.', ''); //alert('aqui 1 ' + b)
      a = a.toString().replace(',', '.');  //alert('aqui 11 ' + c)
   }
   else
   { a = x.toString().replace(',', '.'); }

   if(tam >= 8) 
   { 
      b = v.toString().replace('.', ''); //alert('aqui 1 ' + b)
      c = b.toString().replace(',', '.');  //alert('aqui 11 ' + c)
   }
   else
   { c = v.toString().replace(',', '.'); } //alert(a + ' ' + c)

   var result = eval(a + w + c);
   val = result;
   s = FormataValor(val,2);
//   alert(s);
   return s;
}

//função para calcular porcentagem, usado em nfiscalservico
function calcporcem(x,y,w)
{ 
   var a,v;
/*   v = y;
   tam = 0;
   tam = y.length; //alert('calc ' + x + ' ' + y + ' ' + w); 
   a = x.toString().replace(',', '.');
   if(tam >= 8) 
   { 
      b = v.toString().replace('.', ''); //alert('aqui 1 ' + b)
      c = b.toString().replace(',', '.');  //alert('aqui 11 ' + c)
   }
   else
   { c = v.toString().replace(',', '.');} alert(a + ' ' + c) */
   a = convertevalor(x); 
   v = convertevalor(y); //alert(a + ' ' + v);
   var result = eval((a + w + v) + '/' + 100);
   val = result;
   s = FormataValor(val,2);
//   alert(s);
   return s;
}

//para forçar no campo
function fui(y) 
{ y.focus(); }

//função para impressão da nf, mas somente após feito o check list, usado: nfiscalgarantia,nfiscalconsignacao,altnfiscalrepexterno
function impnf()
{   
  if(form1.opchecklist.value == 1)
  { alert('aqui vai chamar a página com o espelho da nf!'); return false; }
  else
  { alert('Favor providenciar a inspeção antes de tentar imprimir!'); return false }
}

//aqui pega um valor no formato string ex: 10,55 e converte para 10.55, usado para comparar valores, usado altentpecaslaboratorio
function convertevalor(x)
{  
   if(x.length <= 6)
   { vl = Math.abs(x.toString().replace(',', '.')); }
   else
   { 
      x = x.toString().replace(',', '.');
      vl = x.toString().replace('.', ''); 
   }
   return vl;
}

//aqui para não deixar escolher um pedido já aberto no momento da abertura de um novo
function esco()
{
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  { 
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,4) == 'item')
         {  
		    thiselm.disabled = true;
			thiselm.value = 0; 
		 }
      }
   }
}

//aqui verifica o status da combobox do pedido e a data de previsão
function verpedido()
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; //item
		 if(thiselm.name.substring(0,3) == 'chs' && thiselm.checked == 1) 
         {  
   			vlr = elements[i += 1]; 		 
		    vdtp = elements[i += 6];
			if(vlr.name.substring(0,4) == 'item' && (vlr.value == 0 || vdtp.value == ''))
			{ 
			   thiselm.checked = 0; 
			   vdtp.style.backgroundColor = 'yellow';
			   vdtp.value = 'OBRIGATÓRIO';
			   return false;
			}
		 }
      }
   }
}

//aqui verifica a existência de pelo menos um check marcado
function checkvazio()
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,3) == 'chk' && thiselm.checked == 1) 
         { return true; break; }
      }
   }
}

//aqui verifica a existência de pelo menos um check marcado, usado em liberarservicocarro, liberarcontafornec
function checkvazio2(x)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,3) == x && thiselm.checked == 1) 
         { return true; break; }
      }
   }
}

//aqui verifica a existência de pelo menos um check marcado, usado em exibirsolicitacaoaut
function checkvazioduplo(x,y)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if((thiselm.name.substring(0,3) == x || thiselm.name.substring(0,3) == y) && thiselm.checked == 1) 
         { return true; break; }
      }
   }
}

//retirada da internet em 01/08/06, para marcar os checks
function selcheck(x)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,3) == x) 
         { thiselm.checked = 1; }
      }
   }
}

//retirada da internet em 01/08/06, para desmarcar os checks
function naoselcheck(x)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x) 
           { thiselm.checked = 0; }
      }
   }
}

//aqui para desmarcar os dois checks, em nfiscalservico
function naoselcheck2(x,y)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x || thiselm.name.substring(0,3) == y) 
		 { thiselm.checked = 0; }
      }
   }
}

function selcheckduplo(x,y)
{
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x || thiselm.name.substring(0,3) == y && thiselm.disabled != true) 
           {
			   thiselm.checked = !thiselm.checked;
		   }
      }
   }
}

//aqui verifico se existe um determinado campo e o valor, em nfiscalservico
function selcampo(q,v)
{ 
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,q) == v && thiselm.value != '') 
         { return false; break; }
      }
   }
}

//aqui verifico se existe um determinado campo e o valor, sem ser zero ou vázio, em subnfiscalservico
function selcamponvazio(q,v)
{ 
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,q) == v && thiselm.value != '' && thiselm.value != '0,00') 
         { return false; break; }
      }
   }
}

//aqui verifico se foi lançada a data de previsão
function seldata()
{ 
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,10) == 'dtprevisao' && thiselm.value == '') 
         { return false; break; }
      }
   }
}

//aqui verifico se foi lançada a nf de devolução, usado em nfiscalgarantia
function selnf()
{ 
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i]; 
		 if(thiselm.name.substring(0,6) == 'nfdevs' && thiselm.value == 0) 
         { return false; break; }
      }
   }
}

//aqui desabilito os checks
function seldesa(x)
{  
   with(document.form1)
   {  chf.disabled = true;
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x) 
         { thiselm.disabled = true; }
      }
   }
}

//aqui para desabilitar, usado em devolucaopecas.asp
function seldesabilita(x,y)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x || thiselm.name.substring(0,3) == y) 
           { thiselm.disabled = true; }
      }
   }
}

//aqui para desabilitar, usado em nfiscalpeca.asp
function seldesabilita2(x,y)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x || thiselm.name.substring(0,3) == y) 
         { 
		   if(thiselm.name.substring(0,3) == x)
		   { thiselm.checked = !thiselm.checked; }
		   thiselm.disabled = true; 
		 }
      }
   }
}

//aqui habilito os checks
function selabili(x)
{  
   with(document.form1)
   {  
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x) 
         { thiselm.disabled = false; }
      }
   }
}

//aqui para desabilitar, usado em devolucaopecas.asp
function abilita2(x,y)
{  
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == x || thiselm.name.substring(0,3) == y) 
           { thiselm.disabled = false; }
      }
   }
}

//aqui desabilito os checks e os radiobuttons, usado no altpedidogarantia
function seldesa2()
{ 
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == 'chk' && rb.name.substring(0,2) == 'rb') 
         { 
		    thiselm.disabled = true; 
		    rb = elements[i += 1]; 
			rb.disabled = true; 
	     }
      }
   }
}

//retirada da internet em 01/08/06, usado em receberfaturado
function sel4()
{
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == 'chk' && thiselm.checked == true)
		 { return true; }
      }
   }
}

//aqui verifica se todos os checks estão marcados
function sel5()
{
   with(document.form1)
   { 
      for(i=0;i < elements.length;i++)
	  {  
         thiselm = elements[i];
		 if(thiselm.name.substring(0,3) == 'chk' && thiselm.checked == false)
		 { return false; break; }
      }
   }
}

//acrescentar dias ao campo data, desenvolvida por Márcio SC em 05/05/06
function dt()
{ 
   dd = form1.opdata.value; 
   ddt = dd.split('/'); 
   d = parseInt(ddt[0]);
   m = parseInt(ddt[1]);
   a = parseInt(ddt[2]);
   x = m + "/" + d + "/" + a;  
   data = new Date(x); 
   dia = data.getDay(); 
   if(dia >= 1 && dia <= 4)
   {form1.opdtvencto.value = somadias(x,1); } //alert(form1.opdtvencto.value); }
   else
   { 
      if(dia == 5)
      { form1.opdtvencto.value = somadias(x,3); } // alert(form1.opdtvencto.value); }
   }
}

//calculos usado em orcamentoservicos
function calc(v,fr,vu)
{  
   var b,jfrete,vl;
   vl = v.value;
   jfrete = fr.value; 
   if(vl != '' && jfrete != '')
   {  
      jfrete = fr.value.toString().replace(',', '.'); 
      b = vl.toString().replace(',', '.'); //aqui valor do custo unit.
      var result = eval(b + '+' + jfrete); 
      val = result;
      a = FormataValor(val,2);
	  vu.value = FormataValor(val,2);
   }
}

//calculos usado em orcamentopecas
function calcp(v,q,t,fr,vu)  //calc(vlcusto<%=i%>,qtde<%=i%>,vtotal<%=i%>,cfrete<%=i%>,vunit<%=i%>);
{ 
   vl = v.value;
   a = q.value.toString().replace(',', '.');
   jfrete = fr.value; 
   if(vl != '' && jfrete != '')
   {  
      jfretes = fr.value.toString().replace(',', '.'); 
      jmargem = form1.margem.value.toString().replace(',', '.');
      b = vl.toString().replace(',', '.') 
      var result = eval(((b + '*' + jmargem) + '*' + a) + '+' + jfretes); 
      var result2 = eval(b + '*' + jmargem); 
      va2 = result2.toString().replace('.', ',');
      t.value = FormataValor(result,2);
      vu.value = FormataValor(result2,2);
   } 
}

//aqui verifico o valor do ipi e faço a soma, usado em nfiscalconsignacao e nfiscalgarantia
function selipi()
{  
   totalipi = '0,00';
   ttipi = 0;
   with(document.form1)
   {  
	  for(i=0;i < elements.length;i++)
	  {
		 thiselm = elements[i];  
		 if(thiselm.name.substring(0,3) == 'ipi') 
         {   
			 if(thiselm.value != 'null')
             { 
			   tvtotal = elements[i - 2]; 
			   ttipi = calcporcem(thiselm.value,tvtotal.value,'*'); 
			   totalipi = calcgeral(totalipi,ttipi,'+'); 
			 }
		 }
      }
	  if(totalipi != '' && totalipi != '0,00')		 
	  { 
	    form1.vlipi.value = totalipi; 
        form1.totalnf.value = calcgeral(form1.totalnf.value,totalipi,'+'); 
	  }
   }
}

//usado em cadestoque e cadestoquetroca
function verest()
{
  if(form1.coditem.value != '' && form1.codtipoitem.value != '')
  { mp = mpadraosf('arqgeralzu.asp?cod=' + form1.coditem.value + '&variavel=' + form1.codtipoitem.value + '&op=3','ret'); }
}
//usado em cadestoque e cadestoquetroca
function confest()
{
  if(form1.opretorno.value == 1)
  {
    alert('Já existe cadastrado no estoque!');
    form1.coditem.value = ''; 
    form1.codtipoitem.value = '';
	fui(form1.coditem);
    fvalidar(form1.coditem);
    fvalidar(form1.codtipoitem);
   	form1.opretorno.value = 0;
	return false;
  } 
}

function Verificar()
{ 
  var tecla=window.event.keyCode;
  if(tecla==116)
  { event.keyCode=0;event.returnValue=false; }
} 

//era do validar em 11/09/07
//essa diminui
function contartexto(field, countfield, maxlimit)
{
   if (field.value.length > maxlimit)
   {  field.value = field.value.substring(0, maxlimit);  }
   else 
   {  countfield.value = maxlimit - field.value.length;  }
}

//essa soma
function contartexto2(field, countfield, maxlimit)
{
   if (field.value.length > maxlimit)
      countfield.value = maxlimit + field.value.length;
}

//função só permite numeros
function sonumero(e)
{
if (document.all) // Internet Explorer
	var teclas = event.keyCode;
else if(document.layers) // Nestcape
	var teclas = e.which;
if (teclas > 47 && teclas < 58) // numeros de 0 a 9
	return true;
else
{
	if (teclas != 8) // backspace
		{
		  event.keyCode = 0;
 	      alert('Este campo só aceita número!');
		  return false;
		}
	else
		return true;
	}
}

//função só permite numeros
function sonumero2(e)
{
if (document.all) // Internet Explorer
	var teclas = event.keyCode;
else if(document.layers) // Nestcape
	var teclas = e.which;
if (teclas > 46 && teclas < 58) // numeros de 0 a 9
	return true;
else
{
	if (teclas != 8) // backspace
		{
		  event.keyCode = 0;
 	      alert('Este campo só aceita número,\ne use " / " para separar!');
	      return false;
		}
	else
		return true;
	}
}

//função só permite numeros e o enter, usado em altrat
function sonumero3(e)
{
if (document.all) // Internet Explorer
	var teclas = event.keyCode;
else if(document.layers) // Nestcape
	var teclas = e.which;
if (teclas > 47 && teclas < 58 || teclas == 13) // numeros de 0 a 9
	return true;
else
{
	if (teclas != 8) // backspace
	{
	  event.keyCode = 0;
 	  alert('Este campo só aceita número!')
	}
	else
		return true;
	}
}

function fechar(x)
{
   if(x != 1)
   { self.close(); }
   else
   {
      if(x == 1)
	  {
	     self.close(); 
		 opener.location.reload();
	  }
   }
}

//função para grid
function zebra(tableId, corSim,corNao)
{
   var tabela = document.getElementById(tableId);
   var linhas = tabela.rows;
   var i;
   for(i = 0;i < linhas.length;i++)
   {
      var linha = linhas.item(i); 
      linha.style.backgroundColor= (i%2==0)?corSim:corNao;
   }
}

//função para grid
function zebra2(tableId, corSim,corNao)
{ 
   var tabela = document.getElementById(tableId);
   var linhas = tabela.rows;
   var i;
   for(i = 0;i < linhas.length;i++)
   {
      var linha = linhas.item(i); 
      linha.style.backgroundColor= (i%2==0)?corSim:corNao;
   }
}

//função para abri popup
function popup(larg,alt)
{
   //adptada por Márcio SC em 30/09/2005
   {
      var popup_largura = parseInt(larg);
      var popup_altura = parseInt(alt);
      window.resizeTo(popup_largura, popup_altura);

      var altura = window.screen.availHeight;
      var largura = window.screen.availWidth;

      var ponto_x = parseInt(largura / 2) - parseInt(popup_largura / 2);

      var ponto_y = parseInt(altura / 2) - parseInt(popup_altura / 2);

      window.moveTo(ponto_x, ponto_y);
   }
}

//função para calcular qtde x valor, com o valor máximo de 99.999,99 *****
function calcqv(qtde,vunit)
{  
   var a,b;
   v = vunit;
   tam = 0;
   tam = vunit.length; 
   a = Math.abs(qtde.toString().replace(',', '.'));
   if(tam >= 8) //*****
   { 
      b = Math.abs(v.toString().replace('.', ''));
      c = Math.abs(b.toString().replace(',', '.'));
   }
   else
   {  c = Math.abs(v.toString().replace(',', '.')); }
   var result = eval(c + '*' + a);
   val = result;
   s = FormataValor(val,2);
   return s;
}

<!-- Begin
//função para travar o f5 da pagina, colocar assim -->  <body onKeyDown="javascript:Verificar()"> 
function Verificar()
{ 
  var tecla=window.event.keyCode;
  if(tecla==116)
  { event.keyCode=0;event.returnValue=false; }
} 

function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
return false;
}
return true;
}
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
// End -->

function t1() // aqui é para dar um tempo e deixar o asp processar antes de finalizar
{  
  var a,i;
  for (i = 1; i <= 100; i++)
  { a = a + i;}
  a = 0; 
}

function tecla()
{
   if(event.keyCode == 13)
   {
     alert('Utilize o TAB no lugar do ENTER para navegar, Obrigado!');
	 return false;
   }
}

<!-- 
//http://scripts.supertrafego.com/aparece.asp
function qpag()
{
var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
var url = location.href.substring(dir.length,location.href.length+1);
//document.write("<center>" + url + "</center>");
alert(url);
//  -->
}
