    var fontSize = 10;
function aumentar()
    {
        fontSize += 2;
        document.getElementById("col_nota").style.fontSize = fontSize + "px";
    }
    
function diminuir()
    {
        fontSize -= 2;
        document.getElementById("col_nota").style.fontSize = fontSize + "px";
    }

function Chama(form) {
u = window.location;
document.procurado1.Link.value = u;
}

function validaCPF() {
                 cpf = document.procurado.cpfID.value;
                 erro = new String;
                 if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificaçao do CPF! "; 
                 var nonNumbers = /\D/;
                 if (nonNumbers.test(cpf)) erro += "A verificaçao de CPF suporta apenas numeros! "; 
                 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
                         erro += "Número de CPF invalido!"
               }
               var a = [];
               var b = new Number;
               var c = 11;
               for (i=0; i<11; i++){
                       a[i] = cpf.charAt(i);
                       if (i < 9) b += (a[i] * --c);
               }
               if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
               b = 0;
               c = 11;
               for (y=0; y<10; y++) b += (a[y] * c--); 
               if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
               if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
                       erro +="Digito verificador com problema!";
               }
               if (erro.length > 0){
                       alert(erro);
					   document.procurado.cpfID.focus(); 
                       return false;
             }
               return true;
      }


function isNUMB(c) 
 { 
 if((cx=c.indexOf(","))!=-1) 
  { 
  c = c.substring(0,cx)+"."+c.substring(cx+1); 
  } 
 if((parseFloat(c) / c != 1)) 
  { 
  if(parseFloat(c) * c == 0) 
   { 
   return(1); 
   } 
  else 
   { 
   return(0); 
   } 
  } 
 else 
  { 
  return(1); 
  } 
 } 

function LIMP(c) 
 { 
 while((cx=c.indexOf("-"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("/"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(","))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("."))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf("("))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(")"))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 while((cx=c.indexOf(" "))!=-1) 
  { 
  c = c.substring(0,cx)+c.substring(cx+1); 
  } 
 return(c); 
 } 

function Verifycnpj(cnpj) 
 {
 cnpj = LIMP(cnpj); 
 if(isNUMB(cnpj) != 1) 
  { 
  return(0); 
  } 
 else 
  { 
  if(cnpj == 0) 
   { 
   return(0); 
   } 
  else 
   { 
   g=cnpj.length-2; 
   if(RealTestacnpj(cnpj,g) == 1) 
    { 
    g=cnpj.length-1; 
    if(RealTestacnpj(cnpj,g) == 1) 
     { 
     return(1); 
     } 
    else 
     { 
     return(0); 
     } 
    } 
   else 
    { 
    return(0); 
    } 
   } 
  } 
 } 
function RealTestacnpj(cnpj,g) 
 { 
 var Vercnpj=0; 
 var ind=2; 
 var tam; 
 for(f=g;f>0;f--) 
  { 
  Vercnpj+=parseInt(cnpj.charAt(f-1))*ind; 
  if(ind>8) 
   { 
   ind=2; 
   } 
  else 
   { 
   ind++; 
   } 
  } 
  Vercnpj%=11; 
  if(Vercnpj==0 || Vercnpj==1) 
   { 
   Vercnpj=0; 
   } 
  else 
   { 
   Vercnpj=11-Vercnpj; 
   } 
 if(Vercnpj!=parseInt(cnpj.charAt(g))) 
  { 
  return(0); 
  } 
 else 
  { 
  return(1); 
  } 
 } 
  

  function FormataCGC(Formulario, Campo, TeclaPres) 
  { 
	var tecla = TeclaPres.keyCode; 
    var strCampo; 
    var vr; 
    var tam; 
    var TamanhoMaximo = 14; 
  
    eval("strCampo = document.procurado.cnpj"); 
  
    vr = strCampo.value; 
    vr = vr.replace("/", ""); 
    vr = vr.replace("/", ""); 
    vr = vr.replace("/", ""); 
    vr = vr.replace(",", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace(".", ""); 
    vr = vr.replace("-", ""); 
    vr = vr.replace("-", ""); 
    vr = vr.replace("-", ""); 
    vr = vr.replace("-", ""); 
    vr = vr.replace("-", ""); 
    tam = vr.length; 

    if (tam < TamanhoMaximo && tecla != 8) 
    { 
      tam = vr.length + 1; 
    } 

    if (tecla == 8) 
    { 
      tam = tam - 1; 
    } 

    if (tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105) 
    { 
      if (tam <= 2) 
      { 
        strCampo.value = vr; 
      } 
       if ((tam > 2) && (tam <= 6)) 
       { 
         strCampo.value = vr.substr(0, tam - 2) + '-' + vr.substr(tam - 2, tam); 
       } 
       if ((tam >= 7) && (tam <= 9)) 
       { 
         strCampo.value = vr.substr(0, tam - 6) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 
      } 
       if ((tam >= 10) && (tam <= 12)) 
       { 
         strCampo.value = vr.substr(0, tam - 9) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 
      } 
       if ((tam >= 13) && (tam <= 14)) 
       { 
         strCampo.value = vr.substr(0, tam - 12) + '.' + vr.substr(tam - 12, 3) + '.' + vr.substr(tam - 9, 3) + '/' + vr.substr(tam - 6, 4) + '-' + vr.substr(tam - 2, tam); 
      } 
       if ((tam >= 15) && (tam <= 17)) 
       { 
         strCampo.value = vr.substr(0, tam - 14) + '.' + vr.substr(tam - 14, 3) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + '-' + vr.substr(tam - 2, tam); 
      } 
    } 
  } 

function TESTA() 
 { 
 if(Verifycnpj(document.procurado.cnpj.value) == 1) 
  { 
  cnpjOk = "ok!";
	document.procurado.cnpjOk1.value = cnpjOk;
  } 
 else 
  { 
  alert("cnpj nao e valido!"); 
  } 
 document.procurado.cnpj.focus(); 
 return; 
 } 
 

function ContaTexto(CampoMsg,CampoContador, TamMax)
		// Funçao que conta a quantidade de Caracteres
		// que o usuario preencheu no campo mensagem
		// Bloqueia quando a quantidade chegar em TamMax
		{
			if (CampoMsg.value.length > TamMax)
				CampoMsg.value = CampoMsg.value.substring(0, TamMax);
			else
				CampoContador.value = TamMax - CampoMsg.value.length;
		}


function digitos1(dado)
{
   NumDig = dado.value;
   TamDig = NumDig.length;
   TamDig--;
   Contador = 0;
   if ((TamDig >= 0) && (event.keyCode == 8))
    { numer = "";
      for (i = TamDig; (i >= 0); i--){
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
            {
             Contador++;
			 /*alert(NumDig.substr(i, 1) + " Contador " + Contador+ " numer "+ numer+ " TamDig " +TamDig + " i " + i );*/
             if ((Contador == 4) && ((TamDig -i) < 5))
              {numer = ","+numer;
               Contador = 0;
               }
             else if ((Contador == 3) && ((numer.length) > 4))  
              {numer = "."+numer;
               Contador = 0;
              }
			  
             numer = NumDig.substr(i, 1)+numer;
			
            }
			}
			if (numer == "001") 
			    numer="";		
			if ((numer.length) == 3 )
			    numer= "0," + numer;

		dado.value = numer;
      };
}


function digitos2(ConteudoCampo)
{
if (((event.keyCode) > 47) && ((event.keyCode) < 58))
{
   NumDig = ConteudoCampo.value;
   TamDig = NumDig.length;
   Contador = 0;
   if (TamDig > 1)
      {numer = "";
      for (i = TamDig; (i >= 0); i--){
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
            {
             Contador++;
             if ((Contador == 2) && ((TamDig -i) < 4))
              {numer = ","+numer;
               Contador = 0;
               }
             else if (Contador == 3)
              {numer = "."+numer;
               Contador = 0;
              }
             numer = NumDig.substr(i, 1)+numer;
            }
           }
      ConteudoCampo.value = numer;
      };
   return(true)}
   else return(false)
}


function digitos3(dado)
{
   NumDig = dado.value;
   TamDig = NumDig.length;
   TamDig--;
   Contador = 0;
   if ((TamDig >= 0) && (event.keyCode == 8))
    { numer = "";
      for (i = TamDig; (i >= 0); i--){
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
            {
             Contador++;
			 /*alert(NumDig.substr(i, 1) + " Contador " + Contador+ " numer "+ numer+ " TamDig " +TamDig + " i " + i );*/
             if ((Contador == 4) && ((TamDig -i) < 5))
              {numer = ""+numer;
               Contador = 0;
               }
             else if ((Contador == 3) && ((numer.length) > 4))  
              {numer = ""+numer;
               Contador = 0;
              }
			  
             numer = NumDig.substr(i, 1)+numer;
			
            }
			}
			if (numer == "") 
			    numer="";		
			if ((numer.length) == 3 )
			    numer= "" + numer;

		dado.value = numer;
      };
}


function digitos4(ConteudoCampo)
{
if (((event.keyCode) > 47) && ((event.keyCode) < 58))
{
   NumDig = ConteudoCampo.value;
   TamDig = NumDig.length;
   Contador = 0;
   if (TamDig > 1)
      {numer = "";
      for (i = TamDig; (i >= 0); i--){
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
            {
             Contador++;
             if ((Contador == 2) && ((TamDig -i) < 4))
              {numer = ""+numer;
               Contador = 0;
               }
             else if (Contador == 3)
              {numer = ""+numer;
               Contador = 0;
              }
             numer = NumDig.substr(i, 1)+numer;
            }
           }
      ConteudoCampo.value = numer;
      };
   return(true)}
   else return(false)
}

function data1(dado)
{
   NumDig = dado.value;
   TamDig = NumDig.length;
   TamDig--;
   Contador = 0;
   if ((TamDig >= 0) && (event.keyCode == 8))
    { numer = "";
      for (i = TamDig; (i >= 0); i--){
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
            {
             Contador++;
   if (numer.length == 9) break;
			 /*alert(NumDig.substr(i, 1) + " Contador " + Contador+ " numer "+ numer+ " TamDig " +TamDig + " i " + i );*/
             if ((Contador == 4) && ((TamDig -i) < 5))
              {numer = "x"+numer;
               Contador = 0;
               }
             else if ((Contador == 3) && ((numer.length) > 4))  
              {numer = "x"+numer;
               Contador = 0;
              }
			  
             numer = NumDig.substr(i, 1)+numer;
			
            }
			}
			if (numer == "001") 
			    numer="";		
			if ((numer.length) == 3 )
			    numer= "" + numer;

		dado.value = numer;
      };
}

function data2(ConteudoCampo)
{
if (((event.keyCode) > 47) && ((event.keyCode) < 58))
{
   NumDig = ConteudoCampo.value;
   TamDig = NumDig.length;
   Contador = 0;
   if (TamDig > 1)
      {numer = "";
      for (i = TamDig; (i >= 0); i--){
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
            {
             Contador++;
   if (numer.length == 9) break; //alert (Contador + ' ' + (TamDig -i));
             if ((Contador == 4) && ((numer.length) > 2))
              {numer = "-"+numer;
                              }
             else if ((Contador == 2) && ((TamDig -i) < 4))
              {numer = "-"+numer;
                             }
             numer = NumDig.substr(i, 1)+numer;
            }
           }
      ConteudoCampo.value = numer;
      };
   return(true)}
   else return(false)
}

function fazConta(form) {

uA = document.procurado.datainicio.value;
uB = document.procurado.duracao.value;

var today=new Date()

dia = (uA.substring(8,10));
mes = (uA.substring(5,7));
ano = (uA.substring(0,4));

if (((mes =="04") || (mes =="06") || (mes =="09") || (mes =="11")) && (dia >= "31")) {
alert ("O mês escolhido tem 30 dias, favor redigitar a data.");
document.procurado.datainicio.value = "";
document.procurado.datainicio.focus();
}
else if (((mes =="01") || (mes =="03") || (mes =="05") || (mes =="07") || (mes =="08") || (mes =="10") || (mes =="12")) && (dia > "31")) {
alert ("O mês escolhido tem 31 dias, favor redigitar a data.");
document.procurado.datainicio.value = "";
document.procurado.datainicio.focus();
}
else if ((mes =="02") && (dia >= "30")) {
alert ("O mês escolhido tem 29 dias, favor redigitar a data.");
document.procurado.datainicio.value = "";
document.procurado.datainicio.focus();
}
else {
date1 = new Date(ano, mes, dia);
    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;
date1_1 = (date1.getTime());
date2 = (uB * ONE_DAY);		

date4 = date1_1+date2;
date5 = new Date(date4)

var month = date5.getMonth()
var year = date5.getFullYear()
if (month==0) {
	year = ano
	month =mes
}
if ((month==1) || (month==2) || (month==3) || (month==4) || (month==5) || (month==6) || (month==7) || (month==8) || (month==9)){month = "0"+month}
var day = date5.getDate()
if ((day==1) || (day==2) || (day==3) || (day==4) || (day==5) || (day==6) || (day==7) || (day==8) || (day==9)){day = "0"+day}

var s = "-"
if (!uB){document.procurado.previsaoTermino.value = "";}
else {
document.procurado.previsaoTermino.value = (year + s + month + s + day);
			} // fecha else
} // fecha else dos meses
} // fecha function

function cFt(form) {
var Rat = document.procurado.cliente.checked;
var Ret = document.procurado.fornecedor.checked;
var Rit = document.procurado.terminal.checked;
var RitA = document.procurado.clienteFinal.checked;

if (Rat == true) {Rat = "C";}
if (Ret == true) {Ret = "F";}
if (Rit == true) {Rit = "T";}
if (RitA == true) {RitA = "Z";}

if (Rat == false) {Rat = "";}
if (Ret == false) {Ret = "";}
if (Rit == false) {Rit = "";}
if (RitA == false) {RitA = "";}

Rot = (Rat + Ret + Rit + RitA);

document.procurado.tipo.value = Rot;

} //fecha function

function testBoxs(form) {
	
	var Ctrl=new Array();
	var y=0;
	email = document.procurado.email.value;
	i=0;
	
	
	
	if (!document.procurado.Empresa.value) {Ctrl[i++]  = "Empresa\n";y=1;}
	if (!document.procurado.Responsavel.value) {Ctrl[i++]  = "Responsavel\n";y=1;}
	if (!document.procurado.fone.value) {Ctrl[i++]  = "Fone\n";y=1;}
	if (!email || email.indexOf ('@', 0) == -1) {Ctrl[i++]  = "Email\n";y=1;}
	if (!document.procurado.cnpjOk1) {Ctrl[i++]  = "CNPJ\n";y=1;}
	if (!document.procurado.cpfID.value) {Ctrl[i++]  = "CPF\n";y=1;}
	if (!document.procurado.site.value) {Ctrl[i++]  = "Site\n";y=1;}
	
	if (y==1) {
		validatePrompt (Ctrl.join(""))
		return (false);
		y=0;
	}
else return (true);
	
}

function runSubmit (form)  {
	if (!testBoxs(form)) return;
	document.procurado.submit();
	return;
}

function validatePrompt (PromptStr) {
	var aparece ='';
	if (PromptStr) aparece = "Os campos abaixo sao obrigatorios:\n\n";
	alert (aparece+PromptStr+"\n______________________________\n\n");
	return;
}
