<!--
function RetiraAcentos( Campo )
{
	/*var Acentos = "áàãââÁÀÃÂéêÉÊíÍóõôÓÔÕúüÚÜçÇabcdefghijklmnopqrstuvxwyz";
	var Traducao ="AAAAAAAAAEEEEIIOOOOOOUUUUCCABCDEFGHIJKLMNOPQRSTUVXWYZ";
	var Posic, Carac;
	var TempLog = "";
	for (var i=0; i < Campo.length; i++)
	{
		Carac = Campo.charAt (i);
		Posic  = Acentos.indexOf (Carac);
		if (Posic > -1)
			TempLog += Traducao.charAt (Posic);
		else
			TempLog += Campo.charAt (i);
	}
	return (TempLog);
	*/
	return Campo
}
function impressao(urlStr)
{
	window.open(urlStr,'Popup_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=500,height=500');
}
function trocaTipo( valor, formulario )
{
	if(valor=='1')
	{
		formulario.Ano1.disabled = false;
		formulario.Ano2.disabled = false;
	}
	else
	{
		formulario.Ano1.disabled = true;
		formulario.Ano2.disabled = true;
	}
}
function novoAjax( Valor, CampoSelect, CampoDestino, caminho, VlPendencia )
{
	if ( Valor == '#' )
	{
		valor_novo = ''
		if ( CampoSelect == 'IdMarca' )
		{
			valor_novo = prompt("Digite o nome da nova Marca!","")
		}
		if ( CampoSelect == 'IdModelo' )
		{
			valor_novo = prompt("Digite o nome do novo Modelo!","")
		}
		if ( CampoSelect == 'IdCidade' )
		{
			valor_novo = prompt("Digite o nome da nova Cidade!","")
		}
		if ( CampoSelect == 'IdBairro' )
		{
			valor_novo = prompt("Digite o nome do novo Bairro!","")
		}
		if ( CampoSelect == 'IdVersao' )
		{
			valor_novo = prompt("Digite o nome da nova Versão!","")
		}
		if ( valor_novo != '' )
		{
			if ( valor_novo  != null )
			{
				valor_novo = RetiraAcentos(valor_novo)
				var httpRequest;
				if (window.XMLHttpRequest)
				{
					httpRequest = new XMLHttpRequest();
				}
				else
					if (window.ActiveXObject)
					{
						httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
					}
				url = caminho + 'cadastra_valor.asp?campo='+CampoSelect+'&valor='+valor_novo+'&IdPendencia='+VlPendencia
				httpRequest.open('GET', url , true);
				httpRequest.onreadystatechange = function (evt)
				{
					if (httpRequest.readyState == 4)
					{
						resultado = httpRequest.responseText
						if ( resultado == 'OK' )
						{
							self.location.reload();
						}
						else
						{
							alert(resultado)
						}
					}
				};
				httpRequest.send(null);
			}
		}
	}
}
function carregaAjax( Valor , CampoDestino , CampoSelect , IdSelect, DcrSelect , TabelaSelect, PrimeiraDescricao , Selecionado , caminho, VlPendencia )
{
	url = caminho + 'carrega_dados.asp?CampoSelect='+CampoSelect+'&IdSelect='+IdSelect+'&DcrSelect='+DcrSelect+'&TabelaSelect='+TabelaSelect+'&Valor='+Valor
	//url = 'carrega_dados.asp?CampoSelect='+CampoSelect+'&IdSelect='+IdSelect+'&DcrSelect='+DcrSelect+'&TabelaSelect='+TabelaSelect
	
	if ( Valor == '#' )
	{
		valor_novo = ''
		if ( CampoSelect == 'IdMarca' )
		{
			valor_novo = prompt("Digite o nome da nova Marca!","")
		}
		if ( CampoSelect == 'IdModelo' )
		{
			valor_novo = prompt("Digite o nome do novo Modelo!","")
		}
		if ( CampoSelect == 'IdCidade' )
		{
			valor_novo = prompt("Digite o nome da nova Cidade!","")
		}
		if ( CampoSelect == 'IdBairro' )
		{
			valor_novo = prompt("Digite o nome do novo Bairro!","")
		}
		if ( valor_novo != '' )
		{
			if ( valor_novo  != null )
			{
				valor_novo = RetiraAcentos(valor_novo)
				var httpRequest;
				if (window.XMLHttpRequest)
				{
					httpRequest = new XMLHttpRequest();
				}
				else
					if (window.ActiveXObject)
					{
						httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
					}
				url = caminho + 'cadastra_valor.asp?campo='+CampoSelect+'&valor='+valor_novo+'&IdPendencia='+VlPendencia
				httpRequest.open('GET', url , true);
				httpRequest.onreadystatechange = function (evt)
				{
					if (httpRequest.readyState == 4)
					{
						resultado = httpRequest.responseText
						if ( resultado == 'OK' )
						{
							self.location.reload();
						}
						else
						{
							alert(resultado)
						}
					}
				};
				httpRequest.send(null);
			}
		}
	}
	else
	{
		var httpRequest;
		if (window.XMLHttpRequest)
		{
			httpRequest = new XMLHttpRequest();
		}
		else
			if (window.ActiveXObject)
			{
				httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
			}
		httpRequest.open('GET', url, true);
		httpRequest.onreadystatechange = function (evt)
		{
			if (httpRequest.readyState == 4)
			{
				resultado = httpRequest.responseText

				//Limpando o campo
				qtd = CampoDestino.length
				for ( i=0 ; i < qtd ; i++ )
				{
					qtde = qtd - i;
					CampoDestino.options[qtde] = null
				}

				//adiciona a primeira opcao
				CampoDestino.options[0] = new Option(PrimeiraDescricao, '', 1, 0);
	
				vet1 = resultado.split("|")
				//adiciona as opcoes
				for( i=0 ; i< vet1.length ; i++ )
				{
					vet2 = vet1[i].split("}")
					if( Selecionado == vet2[0])
					{
						CampoDestino.options[i+1] = new Option(vet2[1], vet2[0], 1, 1);
					}
					else
					{
						CampoDestino.options[i+1] = new Option(vet2[1], vet2[0], 1, 0);
					}
				}

				if ( CampoSelect == 'IdMarca' || CampoSelect == 'IdModelo' || CampoSelect == 'IdUF' || CampoSelect == 'IdCidade' )
				{
					CampoDestino.options[vet1.length+1] = new Option('Outros', '#', 1, 0);
				}
			}
		};
		httpRequest.send(null);
		//httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	}
	
}
function popup_up(pagina,targ,largura,altura)
{
	esquerda = (screen.width - largura - 10)/2;
	topo = screen.height - 59;
	topo = (topo - altura)/2;
	param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	window.open(pagina,targ,param);
}
function popup(pagina,targ,largura,altura,esquerda,topo,scrollbars)
{
	if (scrollbars == null || scrollbars == '')
	{
		scrollbars = '0';
	}
	if (esquerda == null || esquerda == '')
	{
		esquerda = (screen.width - largura - 10)/2;
	}
	if (topo == null || topo == '')
	{
		topo = (screen.height - altura - 57)/2;
	}
	param = "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scrollbars + ",resizable=0,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	win = window.open(pagina,targ,param);
	return win;
}
function Money_2_Java(num)
{
	novo_num = num;
	for(z=0;novo_num.lastIndexOf(".")>-1;z++)
	{
		ult_ponto = novo_num.lastIndexOf(".");
		novo_num = novo_num.substring(0,ult_ponto) + novo_num.substring(ult_ponto+1,novo_num.length);
	}
	ult_virg = novo_num.lastIndexOf(",");
	if (ult_virg > -1)
	{
		novo_num = novo_num.substring(0,ult_virg) + "." + novo_num.substring(ult_virg+1,novo_num.length);
	}
	return novo_num
}
function NumJava_2_Money(num)
{
	virg = false;
	novo_num = "";
	num = "" + num
	if (num.lastIndexOf(".") == -1)
	{
		virg = true;
		ponto = 0
	}
	for(i=0;i<num.length;i++)
	{
		if(num.substring(num.length-i-1,num.length-i) == ".")
		{
			if (!virg)
			{
				virg = true;
				ponto = 0;
				novo_num = "," + novo_num;
			}
		}
		else
		{
			if(virg)
			{
				if (ponto == 3 && num.substring(num.length-i-1,num.length-i) != "-")
				{
					ponto = 0
					novo_num = "." + novo_num
				}
				ponto = ponto + 1
			}
			novo_num = num.substring(num.length-i-1,num.length-i) + novo_num;
		}
	}
	if (novo_num.lastIndexOf(",") == -1)
	{
		novo_num = novo_num + ",00";
	}
	else if(novo_num.lastIndexOf(",") == novo_num.length - 2)
	{
		novo_num = novo_num + "0";
	}
	return novo_num
}
function mascaradata(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=8)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
		}
	}
    campo.value = temp;
}
function mascaradatahora(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=14)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +" "+ S.charAt(3) + S.charAt(4) + ":" + S.charAt(5) + S.charAt(6) + ":" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +" "+ S.charAt(4) + S.charAt(5) + ":" + S.charAt(6) + S.charAt(7) + ":" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "/" + S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4) + " " + S.charAt(5) + S.charAt(6) + ":" + S.charAt(7) + S.charAt(8) + ":" + S.charAt(9)+ S.charAt(10)}}
			if (numero == 12 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "/" + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) + " " + S.charAt(6) + S.charAt(7) + ":" + S.charAt(8) + S.charAt(9) + ":" + S.charAt(10)+ S.charAt(11)}}
			if (numero == 13 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "/" + S.charAt(1) + S.charAt(2) + "/" + S.charAt(3) + S.charAt(4) + S.charAt(5) + S.charAt(6) + " " + S.charAt(7) + S.charAt(8) + ":" + S.charAt(9) + S.charAt(10) + ":" + S.charAt(11)+ S.charAt(12)}}
			if (numero == 14 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "/" + S.charAt(2) + S.charAt(3) + "/" + S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7) + " "+ S.charAt(8) + S.charAt(9) + ":" + S.charAt(10) + S.charAt(11) + ":" + S.charAt(12)+ S.charAt(13)}}
		}
	}
    campo.value = temp;
}
function mascarahora(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=5)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + ":" + S.charAt(1)+ S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + ":" + S.charAt(2)+ S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + ":" + S.charAt(1) + S.charAt(2) + ":" + S.charAt(3)+ S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + ":" + S.charAt(2) + S.charAt(3) + ":" + S.charAt(4)+ S.charAt(5)}}
		}
	}
    campo.value = temp;
}
function mascaracep(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=6)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "-" + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." + S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}
function mascarafone(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=10)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"-"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"-"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +"-"+ S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) +"-"+ S.charAt(5) + S.charAt(6) + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) +"-"+ S.charAt(6) + S.charAt(7) + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) +"-"+ S.charAt(6) + S.charAt(7) + S.charAt(8)+ S.charAt(9)+ S.charAt(10)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}
function mascaranumero(S,campo)
{
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++)
	{
		if (ini_z == true || S.charAt(i) != "0")
		{
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}
	if (S.length == 1)
	{
		temp = "0.0" + S
		temp = NumJava_2_Money(temp);
	}
	else if (S.length == 2)
	{
		temp = "0." + S
		temp = NumJava_2_Money(temp);
	}
	else if (S.length > 2)
	{
		temp = a_virg + "." + S.charAt(S.length-2) + S.charAt(S.length-1);
		temp = NumJava_2_Money(temp);
	}
	else
	{
		temp = S;
	}
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
	if(temp=="")
	{temp = "0,00"}
    campo.value = temp;
}
function mascaranumero2(S,campo)
{
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++)
	{
		if (ini_z == true || S.charAt(i) != "0")
		{
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){a_virg = a_virg + digito}
	}
	temp = S;
	if (eval(Money_2_Java(temp)) == 0){temp = "";}
    campo.value = temp;
}
function mascaracpfcnpj(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=13)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) + "-" + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) + "-" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7) + "-" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8) + "-" + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9) + "-" + S.charAt(10) + S.charAt(11)}}
			if (numero == 13){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10) +"-"+ S.charAt(11) + S.charAt(12)}}
			if (numero == 14){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11) +"-"+ S.charAt(12) + S.charAt(13)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}
function mascaracnpjcol(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=11)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 8){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}
function limpa_string(S)
{
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++)
	{
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp
}
function limpa_string_virg(S)
{
	// Deixa so' os digitos no numero
	var Digitos = "0123456789,.";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++)
	{
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp
}
function valida_CPF(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
   return true;
}
function valida_CGC(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}
	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
	return true;
}
function ltrim(string)
{
	inicio = false;
	nova_string = "";
	for (x=0;x<string.length;x++)
	{
		if (string.charAt(x) != " ")
		{
			inicio = true;
			nova_string = nova_string + string.charAt(x);
		}
		else if(inicio)
		{
			nova_string = nova_string + string.charAt(x);
		}
	}
	return nova_string
}
function rtrim(string)
{
	inicio = false;
	nova_string = "";
	for (x = string.length - 1;x>=0;x--)
	{
		if (string.charAt(x) != " ")
		{
			inicio = true;
			nova_string = string.charAt(x) + nova_string;
		}
		else if(inicio)
		{
			nova_string = string.charAt(x) + nova_string;
		}
	}
	return nova_string
}
function trim(string)
{
	return ltrim(rtrim(string))
}
function logout()
{
	if(confirm('Deseja sair e fazer logout do HelpDesk Online?'))
	{
		popup_up('logout.asp?x=unload','logout',50,10)
	}
}
function checa(nform)
{
	if (nform.email.value == "")
	{
		alert("Informe seu e-mail.");
		nform.email.focus();
		nform.email.select();
		return false;
	}
	else
	{
		prim = nform.email.value.indexOf("@")
		if(prim < 2)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("@",prim + 1) != -1)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".") < 1)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(" ") != -1)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("zipmeil.com") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("hotmeil.com") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".@") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("@.") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".com.br.") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("/") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("[") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("]") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("(") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(")") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("..") > 0)
		{
			alert("Favor verificar se o email foi digitado corretamente.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
	}
	return true;
}

function replaceVar(texto, letra, substituicao )
{
	if(texto=="" || (letra=="" && substituicao=="") ){
		return texto	;
	}
	
	var Posic, Carac;
	var TempLog = "";
	for (var i=0; i < texto.length; i++)
	{
		Carac = texto.charAt (i);

		if (Carac == letra)
			TempLog += substituicao;
		else
			TempLog += Carac;
	}
	return (TempLog);
}

function validaRadio(campo, nform) {
	//validacao de radio buttons sem saber quantos sao
	if(document[nform][campo].length!=undefined){
		total=document[nform][campo].length;
		//
		for (i=0; i<total; i++) {
			if (document[nform][campo][i].checked) {
				return 0;
			}
		}
	}else{
		if(document[nform][campo].checked) {
			return 0;
		}
	}
		
	
	return 1;
}

function valueRadio(campo, nform) {
	//validacao de radio buttons sem saber quantos sao
	if(document[nform][campo].length!=undefined){
		total=document[nform][campo].length
	
		for (i=0; i<document[nform][campo].length; i++) {
			if (document[nform][campo][i].checked) {
				return document[nform][campo][i].value;
			}
		}
	}else{
		if (document[nform][campo].checked) {
			return document[nform][campo].value;
		}
	}
	
	return "";
}

function ResetRadio(campo, nform) {
	//limpando o radio buttons sem saber quantos sao
	if(document[nform][campo].length!=undefined){
		total=document[nform][campo].length;
		for (i=0; i<total; i++) {
				document[nform][campo][i].checked=false;
		}
	}else{
		document[nform][campo].checked=false;
	}
}


function SelectRadio(campo, nform, valor) {
	//limpando o radio buttons sem saber quantos sao
	if(document[nform][campo].length!=undefined){
		total=document[nform][campo].length;
		for (i=0; i<total; i++) {
				if(document[nform][campo][i].value==valor){
						document[nform][campo][i].checked=true;
				}else{
					document[nform][campo][i].checked=false;
				}
		}
	}else{
		document[nform][campo].checked=false;
	}
}

function formatar(src, mask) 
{
	var i = src.value.length;
	var saida = mask.substring(0,1);
	var texto = mask.substring(i)
	if (texto.substring(0,1) != saida) 
	  {
		src.value += texto.substring(0,1);
	  }
}

/* 
Exemplos:
CEP
OnKeyPress="formatar(this, '#####-###')"
CPF
OnKeyPress="formatar(this, '###.###.###-##')"
DATA
OnKeyPress="formatar(this, '##/##/####')"
*/

function ApenasNumericos(caracter, campo, formato, formatarSN) {
	if(document.all) { // Internet Explorer
		var tecla = event.keyCode;
	}
	else 
	{
		if(document.layers) { // Nestcape
			var tecla = caracter.which;
		}
	}
	
	if(tecla > 47 && tecla < 58) { // numeros de 0 a 9
		if(formatarSN){
			formatar(campo, formato);
		}
		return true;
	}
	else 
	{
		if (tecla != 8) { // backspace
			return false;
		}
		else 
		{	
			if(formatarSN){
				formatar(campo, formato);
				return true;
			}
		}
	}
}
//onKeyPress="return apenasnumericos(event, this, '##.###.###-#');"



function agravoVG(premio, cocomissao) {
/*
	if(cocomissao<=0.15) {
	    valorCalculado=premio //premio ja calculado. taxa x capital
		valorCalculado=valorCalculado*0.85
		valorCalculado=valorCalculado / (1-cocomissao)
	}else{

		switch ((cocomissao*100)) {
			case 16:{
				valorCalculado=premio / (1 - 0.02) ; break }
			case 17:{
				valorCalculado=premio / (1 - 0.04) ; break }
			case 18:{
				valorCalculado=premio / (1 - 0.06) ; break }
			case 19:{
				valorCalculado=premio / (1 - 0.08) ; break }
			case 20:{
				valorCalculado=premio / (1 - 0.10) ; break }
			case 21:{
				valorCalculado=premio / (1 - 0.12) ; break }
			case 22:{
				valorCalculado=premio / (1 - 0.14) ; break }
			case 23:{
				valorCalculado=premio / (1 - 0.16) ; break }
			case 24:{
				valorCalculado=premio / (1 - 0.18) ; break }
			case 25:{
				valorCalculado=premio / (1 - 0.20) ; break }
			case 26:{
				valorCalculado=premio / (1 - 0.22) ; break }
			case 27:{
				valorCalculado=premio / (1 - 0.24) ; break }
			case 28:{
				valorCalculado=premio / (1 - 0.26) ; break }
			case 29:{
				valorCalculado=premio / (1 - 0.28) ; break }
			case 30:{
				valorCalculado=premio / (1 - 0.30) ; break }
			default: { 
				valorCalculado=premio ; break }
		}
	}
*/		//alert(" Comissao=" + cocomissao + "\n Valor=" + ((cocomissao*100)));
		
		switch (parseInt(cocomissao*100)) {
			case 1:{
				valorCalculado=premio * 0.748502994011976; break }
			case 2:{
				valorCalculado=premio * 0.762195121951219; break }
			case 3:{
				valorCalculado=premio * 0.77639751552795; break }
			case 4:{
				valorCalculado=premio * 0.791139240506329; break }
			case 5:{
				valorCalculado=premio * 0.806451612903226; break }
			case 6:{
				valorCalculado=premio * 0.822368421052632; break }
			case 7:{
				valorCalculado=premio * 0.838926174496644; break }
			case 8:{
				valorCalculado=premio * 0.856164383561644; break }
			case 9:{
				valorCalculado=premio * 0.874125874125874; break }
			case 10:{
				valorCalculado=premio * 0.892857142857143; break }
			case 11 :{
				valorCalculado=premio * 0.912408759124087; break }
			case 12:{
				valorCalculado=premio * 0.932835820895522; break }
			case 13:{
				valorCalculado=premio * 0.954198473282443; break }
			case 14:{
				valorCalculado=premio * 0.9765625; break }
			case 15:{
				valorCalculado=premio; break }
			case 16:{
				valorCalculado=premio * 1.02459016393443; break }
			case 17:{
				valorCalculado=premio * 1.05042016806723; break }
			case 18:{
				valorCalculado=premio * 1.07758620689655; break }
			case 19:{
				valorCalculado=premio * 1.10619469026549; break }
			case 20:{
				valorCalculado=premio * 1.13636363636364; break }
			case 21:{
				valorCalculado=premio * 1.16822429906542; break }
			case 22:{
				valorCalculado=premio * 1.20192307692308; break }
			case 23:{
				valorCalculado=premio * 1.23762376237624; break }
			case 24:{
				valorCalculado=premio * 1.27551020408163; break }
			case 25:{
				valorCalculado=premio * 1.31578947368421; break }
			case 26:{
				valorCalculado=premio * 1.35869565217391; break }
			case 27:{
				valorCalculado=premio * 1.40449438202247; break }
			case 28:{
				valorCalculado=premio * 1.45348837209302; break }
			case 29:{
				valorCalculado=premio * 1.50602409638554; break }
			case 30:{
				valorCalculado=premio * 1.5625; break }
			case 31 :{
				valorCalculado=premio * 1.62337662337662; break }
			case 32:{
				valorCalculado=premio * 1.68918918918919; break }
			case 33:{
				valorCalculado=premio * 1.76056338028169; break }
			case 34:{
				valorCalculado=premio * 1.83823529411765; break }
			case 35:{
				valorCalculado=premio * 1.92307692307692; break }
			case 36:{
				valorCalculado=premio * 2.01612903225807; break }
			case 37:{
				valorCalculado=premio * 2.11864406779661; break }
			case 38:{
				valorCalculado=premio * 2.23214285714286; break }
			case 39:{
				valorCalculado=premio * 2.35849056603774; break }
			case 40:{
				valorCalculado=premio * 2.5; break }
			default:{
				valorCalculado=premio; break }
	   }

return valorCalculado
}

function dateDifference(strDate1,strDate2){
     datDate1= Date.parse(strDate1);
     datDate2= Date.parse(strDate2);
     alert((datDate2-datDate1)/(24*60*60*1000))
     //Devolve o numero em dias
}

-->
