var xmlHttp;
var xmlHttp2;
var xmlHttp3;
var xmlHttp4;
var xmlHttp5;
var xmlHttp6;
var spReferencia;
var bpCarregar;
var apArgs;
var ipArgs;

var ipID;

var vLocal;
var vLocal2;
var vLocal3;
var vLocal4;
var vLocal5;

//CNPJ Cadastrado
function chamarCNPJCadsatrado()
{
  apArgs = chamarCNPJCadsatrado.arguments;	
  chamarCNPJCadsatradoF2(apArgs[0]);
}

function chamarCNPJCadsatradoF2(jsCNPJ)
{ 

  vLocal = "tdCNPJCadastrado"
  
  document.getElementById("tdCNPJCadastrado").innerHTML = '<center><img src="images/ajax-bar-loader.gif"></center>';	
  	
  var url = "cnpj_cadastrado.asp?ID_Oper="+Math.random().toString()+"&aspcnpj=" + jsCNPJ;	

  xmlHttp = GetXmlHttpObject(stateChanged);
  xmlHttp.close;  
  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);
  
} 

//CNPJ Cadastrado Exibir Dados
function chamarDadosCNPJCadsatrado()
{
  apArgs = chamarDadosCNPJCadsatrado.arguments;	
  chamarDadosCNPJCadsatradoF2(apArgs[0]);
}

function chamarDadosCNPJCadsatradoF2(jsCNPJ)
{ 
  vLocal = "td_hidden"
 
  var url = "dados_cnpj_cadastrado.asp?ID_Oper="+Math.random().toString()+"&aspcnpj=" + jsCNPJ;	

  xmlHttp = GetXmlHttpObject(stateChanged);
  xmlHttp.close;  
  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);
  
} 


//Pacotes
function chamarPacotes()
{
	var jsQtde = document.getElementById("txtQtde").value;
	
	chamarPacoteBasico(jsQtde);
	chamarPacoteBronze(jsQtde);
	chamarPacotePrata(jsQtde);
	chamarPacoteOuro(jsQtde);
	chamarPacoteDiamante(jsQtde);
}

function validarPacotes()
{
	var jsRdBasico   = document.getElementById("rdBasico");
	var jsRdBronze   = document.getElementById("rdBronze");
	var jsRdPrata    = document.getElementById("rdPrata");
	var jsRdOuro     = document.getElementById("rdOuro");
	var jsRdDiamante = document.getElementById("rdDiamante");
	
	if(jsRdBasico.checked == true)
	{
		preecherPacoteBasico();
	};

	if(jsRdBronze.checked == true)
	{
		preecherPacoteBronze();
	};

	if(jsRdPrata.checked == true)
	{
		preecherPacotePrata();
	};

	if(jsRdOuro.checked == true)
	{
		preecherPacoteOuro();
	};

	if(jsRdDiamante.checked == true)
	{
		preecherPacoteDiamante();
	};
}

//Basico
function chamarPacoteBasico()
{
  apArgs = chamarPacoteBasico.arguments;	
  chamarPacoteBasicoF2(apArgs[0]);
}

function chamarPacoteBasicoF2(jsqtde)
{ 

  vLocal = "tdBasico"
  
  //document.getElementById("tdBasico").innerHTML = '<center><img src="img/ajax-loader.gif"></center>';	
  	
  var url = "calc_pacote_basico.asp?ID_Oper="+Math.random().toString()+"&aspqtde=" + jsqtde;	

  xmlHttp = GetXmlHttpObject(stateChanged);
  xmlHttp.close;  
  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);
  
} 

function preecherPacoteBasico()
{
	document.getElementById("txtContratoValor").value = document.getElementById("txtBasicoValorContrato").value;
	document.getElementById("txtTipoPacote").value    = document.getElementById("txtBasicoTipoPacote").value;	
}

//Bronze
function chamarPacoteBronze()
{
  apArgs = chamarPacoteBronze.arguments;	
  chamarPacoteBronzeF2(apArgs[0]);
}

function chamarPacoteBronzeF2(jsqtde)
{ 

  vLocal2 = "tdBronze"
  
  //document.getElementById("tdBasico").innerHTML = '<center><img src="img/ajax-loader.gif"></center>';	
  	
  var url = "calc_pacote_bronze.asp?ID_Oper="+Math.random().toString()+"&aspqtde=" + jsqtde;	

  xmlHttp2 = GetXmlHttpObject(stateChanged2);
  xmlHttp2.close;  
  xmlHttp2.open("GET", url, true);
  xmlHttp2.send(null);
  
} 

function preecherPacoteBronze()
{
	document.getElementById("txtContratoValor").value = document.getElementById("txtBronzeValorContrato").value;
	document.getElementById("txtTipoPacote").value    = document.getElementById("txtBronzeTipoPacote").value;	
}

//Prata
function chamarPacotePrata()
{
  apArgs = chamarPacotePrata.arguments;	
  chamarPacotePrataF2(apArgs[0]);
}

function chamarPacotePrataF2(jsqtde)
{ 

  vLocal3 = "tdPrata"
  
  //document.getElementById("tdBasico").innerHTML = '<center><img src="img/ajax-loader.gif"></center>';	
  	
  var url = "calc_pacote_prata.asp?ID_Oper="+Math.random().toString()+"&aspqtde=" + jsqtde;	

  xmlHttp3 = GetXmlHttpObject(stateChanged3);
  xmlHttp3.close;  
  xmlHttp3.open("GET", url, true);
  xmlHttp3.send(null);
  
} 

function preecherPacotePrata()
{
	document.getElementById("txtContratoValor").value = document.getElementById("txtPrataValorContrato").value;
	document.getElementById("txtTipoPacote").value    = document.getElementById("txtPrataTipoPacote").value;	
}

//Ouro
function chamarPacoteOuro()
{
  apArgs = chamarPacoteOuro.arguments;	
  chamarPacoteOuroF2(apArgs[0]);
}

function chamarPacoteOuroF2(jsqtde)
{ 

  vLocal4 = "tdOuro"
  
  //document.getElementById("tdBasico").innerHTML = '<center><img src="img/ajax-loader.gif"></center>';	
  	
  var url = "calc_pacote_ouro.asp?ID_Oper="+Math.random().toString()+"&aspqtde=" + jsqtde;	

  xmlHttp4 = GetXmlHttpObject(stateChanged4);
  xmlHttp4.close;  
  xmlHttp4.open("GET", url, true);
  xmlHttp4.send(null);
  
} 

function preecherPacoteOuro()
{
	document.getElementById("txtContratoValor").value = document.getElementById("txtOuroValorContrato").value;
	document.getElementById("txtTipoPacote").value    = document.getElementById("txtOuroTipoPacote").value;	
}

//Diamante
function chamarPacoteDiamante()
{
  apArgs = chamarPacoteDiamante.arguments;	
  chamarPacoteDiamanteF2(apArgs[0]);
}

function chamarPacoteDiamanteF2(jsqtde)
{ 

  vLocal5 = "tdDiamante"
  
  //document.getElementById("tdBasico").innerHTML = '<center><img src="img/ajax-loader.gif"></center>';	
  	
  var url = "calc_pacote_diamante.asp?ID_Oper="+Math.random().toString()+"&aspqtde=" + jsqtde;	

  xmlHttp5 = GetXmlHttpObject(stateChanged5);
  xmlHttp5.close;  
  xmlHttp5.open("GET", url, true);
  xmlHttp5.send(null);
  
} 

function preecherPacoteDiamante()
{
	document.getElementById("txtContratoValor").value = document.getElementById("txtDiamanteValorContrato").value;
	document.getElementById("txtTipoPacote").value    = document.getElementById("txtDiamanteTipoPacote").value;	
}

//Submit do Frmulario de Cadastro do SiscorPlus
function Trim(str)
{
	return str.replace(/^\s+|\s+$/g,"");
}

function valid_form()
{
	
	var Aceite = document.getElementById("optAceite");
	var tdAceite = document.getElementById("td_aceite");
	
	var frm 		  	  = document.frmCadastro;
	var jsSenha       	  = document.getElementById("txtSenha");
	var jsSenhaconfir 	  = document.getElementById("txtConfirmar");	
	var jsRazao		  	  = document.getElementById("txtRazao");
	var jsCNPJ		  	  = document.getElementById("txtCNPJ");
	var jsEndereco	  	  = document.getElementById("txtEndereco");
	var jsNumero	  	  = document.getElementById("txtNum");	
	var jsComplemento 	  = document.getElementById("txtComplemento");
	var jsBairro	  	  = document.getElementById("txtBairro");
	var jsCEP	      	  = document.getElementById("txtCEP");
	var jsCidade	  	  = document.getElementById("txtCidade");
	var jsTelefone	  	  = document.getElementById("txtTelefone");
	var jsNome	      	  = document.getElementById("txtNome");
	var jsCargo	  	  	  = document.getElementById("txtCargo");
	var jsRG	  	  	  = document.getElementById("txtRG");
	var jsCPF	  	  	  = document.getElementById("txtCPF");
	var jsTelefoneContato = document.getElementById("txtTelefoneContato");
	var jsCelular	  	  = document.getElementById("tctCelular");
	var jsEmail	  		  = document.getElementById("txtEmail");
	
	
	var jsChave = false;

	jsRazao.className       	= "campo_cadastro";
	jsCNPJ.className        	= "campo_cadastro";
	jsEndereco.className    	= "campo_cadastro";
	jsNumero.className      	= "campo_cadastro";	
	jsComplemento.className 	= "campo_cadastro";
	jsBairro.className      	= "campo_cadastro";
	jsCEP.className         	= "campo_cadastro";
	jsCidade.className      	= "campo_cadastro";
	jsTelefone.className    	= "campo_cadastro";
	jsNome.className        	= "campo_cadastro";
	jsCargo.className   		= "campo_cadastro";
	jsRG.className   			= "campo_cadastro";
	jsCPF.className   			= "campo_cadastro";
	jsTelefoneContato.className = "campo_cadastro";
	jsCelular.className   		= "campo_cadastro";
	jsEmail.className   		= "campo_cadastro";
	jsSenha.className   		= "campo_cadastro";
	jsSenhaconfir.className   	= "campo_cadastro";
	tdAceite.className   	    = "aceite";
	
	//Aceite
	if(Aceite.checked == false)
	{
		tdAceite.className = "aceite_verm";
		Aceite.focus();
		jsChave = true;
		return false;
	}
	
	//Razão Social
	if(Trim(jsRazao.value) == "")
	{
		jsRazao.className = "campo_cadastro_red";
		jsChave = true;
	}
	
	//CNPJ
	if(Trim(jsCNPJ.value) == "")
	{
		jsCNPJ.className = "campo_cadastro_red";
		jsChave = true;
	}
	
	//Endereco
	if(Trim(jsEndereco.value) == "")
	{
		jsEndereco.className = "campo_cadastro_red";
		jsEndereco.focus();
		jsChave = true;
	}
	
	//Numero
	if(Trim(jsNumero.value) == "")
	{
		jsNumero.className = "campo_cadastro_red";
		jsNumero.focus();
		jsChave = true;
	}	
	
	//Bairro
	if(Trim(jsBairro.value) == "")
	{
		jsBairro.className = "campo_cadastro_red";
		jsBairro.focus();
		jsChave = true;
	}
	
	//CEP
	if(Trim(jsCEP.value) == "")
	{
		jsCEP.className = "campo_cadastro_red";
		jsCEP.focus();
		jsChave = true;
	}
	
	//Cidade
	if(Trim(jsCidade.value) == "")
	{
		jsCidade.className = "campo_cadastro_red";
		jsCidade.focus();
		jsChave = true;
	}
	
	//Telefone
	if(Trim(jsTelefone.value) == "")
	{
		jsTelefone.className = "campo_cadastro_red";
		jsTelefone.focus();
		jsChave = true;
	}
	
	//Nome do Contato
	if(Trim(jsNome.value) == "")
	{
		jsNome.className = "campo_cadastro_red";
		jsNome.focus();
		jsChave = true;
	}
	
	//Cargo
	if(Trim(jsCargo.value) == "")
	{
		jsCargo.className = "campo_cadastro_red";
		jsCargo.focus();
		jsChave = true;
	}
	
	//RG
	if(Trim(jsRG.value) == "")
	{
		jsRG.className = "campo_cadastro_red";
		jsRG.focus();
		jsChave = true;
	}
	
	//CPF
	if(Trim(jsCPF.value) == "")
	{
		jsCPF.className = "campo_cadastro_red";
		jsChave = true;
	}
	
	//Telefone do Contato
	if(Trim(jsTelefoneContato.value) == "")
	{
		jsTelefoneContato.className = "campo_cadastro_red";
		jsTelefoneContato.focus();
		jsChave = true;
	}
	
	//Celular do Contato
	if(Trim(jsCelular.value) == "")
	{
		jsCelular.className = "campo_cadastro_red";
		jsCelular.focus();
		jsChave = true;
	}
	
	//E-mail
	if(Trim(jsEmail.value) == "")
	{
		jsEmail.className = "campo_cadastro_red";
		jsEmail.focus();
		jsChave = true;
	}
	
	//Mensagem
	if (jsChave == true)
	{
		alert('Os campos em destaque são de preenchimento obrigatório!');
		return false;
	}
	
	//Senha
	
	jsSenha.value = jsSenha.value.replace("'",'');
	jsSenha.value = jsSenha.value.replace('=','');
	jsSenha.value = jsSenha.value.replace('`','');
	jsSenha.value = jsSenha.value.replace('´','');
	jsSenha.value = jsSenha.value.replace('-','');
	
	var qtdeCaractSenha = Trim(jsSenha.value);
	
	if (qtdeCaractSenha.length < 6)
	{
		alert('O campo Senha deve ter no mínimo 6 caracteres!');
		jsSenha.className = "campo_cadastro_red";
		return false;
	}
	
	if (isSenha(jsSenha.value) == false)
	{
		alert('A sua Senha não atende os requisitos!\n\nA Senha deve conter:\n- Caracteres Alfanuméricos\n- Caracteres Numéricos\n- Caracteres Especiais (Simbolos)');
		jsSenha.className = "campo_cadastro_red"
		jsSenha.focus();
		
		return false;
	}
	
	if(Trim(jsSenha.value) != Trim(jsSenhaconfir.value))
	{
		alert('As Senhas não coincidem!');
		
		jsSenha.className = "campo_cadastro_red"
		jsSenhaconfir.className = "campo_cadastro_red"
		
		jsSenha.value = "";
		jsSenhaconfir.value = "";
		
		jsSenha.focus();
		
		return false;
	}
	
	frm.action = "cad_cliente_siscorplus.asp"
	frm.submit();
	
}

function valid_form_trail()
{
	
	var Aceite = document.getElementById("optAceite");
	var tdAceite = document.getElementById("td_aceite");
	
	var frm 		  	  = document.frmCadastro;
	var jsRazao		  	  = document.getElementById("txtRazao");
	var jsNome	      	  = document.getElementById("txtNome");
	var jsTelefoneContato = document.getElementById("txtTelefoneContato");
	var jsEmail	  		  = document.getElementById("txtEmail");
	
	var jsChave = false;

	jsRazao.className       	= "campo_cadastro";
	jsNome.className        	= "campo_cadastro";
	jsTelefoneContato.className = "campo_cadastro";
	jsEmail.className   		= "campo_cadastro";
	
	//Razão Social
	if(Trim(jsRazao.value) == "")
	{
		jsRazao.className = "campo_cadastro_red";
		jsChave = true;
	}
	
	//Nome do Contato
	if(Trim(jsNome.value) == "")
	{
		jsNome.className = "campo_cadastro_red";
		jsNome.focus();
		jsChave = true;
	}
	
	//Telefone do Contato
	if(Trim(jsTelefoneContato.value) == "")
	{
		jsTelefoneContato.className = "campo_cadastro_red";
		jsTelefoneContato.focus();
		jsChave = true;
	}
		
	//E-mail
	if(Trim(jsEmail.value) == "")
	{
		jsEmail.className = "campo_cadastro_red";
		jsEmail.focus();
		jsChave = true;
	}
	
	//Mensagem
	if (jsChave == true)
	{
		alert('Os campos em destaque são de preenchimento obrigatório!');
		return false;
	}
	
	frm.action = "cad_trail.asp"
	frm.submit();
	
}

function valid_form_p2()
{
	
	var frm 		 = document.frmContratoPacotes;
	
	var jsRdBasico   = document.getElementById("rdBasico");
	var jsRdBronze   = document.getElementById("rdBronze");
	var jsRdPrata    = document.getElementById("rdPrata");
	var jsRdOuro     = document.getElementById("rdOuro");
	var jsRdDiamante = document.getElementById("rdDiamante");
	
	if(jsRdBasico.checked == false && jsRdBronze.checked == false && jsRdPrata.checked == false && jsRdOuro.checked == false && jsRdDiamante.checked == false)
	{
		alert("Selecione o Pacote que deseja Contratar.");
		return false;
	}
	
	frm.action = "cad_cliente_siscorplus_p2.asp"
	frm.submit();
	
}

function valid_form_p3()
{	
	window.location.href = "cad_cliente_siscorplus_p3.asp";	
}

function Voltar()
{
	window.location.href = "cadastro_siscorplus_p2.asp";	
}

//Outros
function MM_preloadImages() 
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) 
{ //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

//Mascaras
function mascara(o,f)
{
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara()
{
    v_obj.value=v_fun(v_obj.value)
}

function leech(v)
{
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

function soNumeros(v)
{
	return v.replace(/\D/g,"")
}

function qtdeEstacoes(v)
{
	if (v == 0 || v == '')
	{
		return 1
	}else{	
		return v.replace(/\D/g,"")
	}
}

function telefone(v)
{
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cpf(v)
{
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

function cep(v)
{
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}

function cnpj(v)
{
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}

function rg(v)
{
    //v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1-$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    return v
}

function data(v)
{
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1/$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\/(\d{2})(\d)/,"$1/$2/$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\/(\d{4})(\d)/,"/$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    return v
}

function romanos(v)
{
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}

function site(v)
{
    //Esse sem comentarios para que você entenda sozinho ;-)
    v=v.replace(/^http:\/\/?/,"")
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
        caminho=v.replace(/[^\/]*/,"")
    dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
    caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
    caminho=caminho.replace(/([\?&])=/,"$1")
    if(caminho!="")dominio=dominio.replace(/\.+$/,"")
    v="http://"+dominio+caminho
    return v
}

function noenter() 
{
  return !(window.event && window.event.keyCode == 13); 
}

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 = 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;
}

//Validações
function isSenha(jsVal)
{
	var reTipoN = /[0-9]/;                      // expressão regular para números
	var reTipoL = /[A-Za-z]/;                   // expressão regular para alfanuméricos
	var reTipoS = /[@_£¢¬§!#$%&.*+\/?{|}-]/;    // expressão regular para símbolos
	var vTest1 = jsVal.search(reTipoN);
	var vTest2 = jsVal.search(reTipoL);
	var vTest3 = jsVal.search(reTipoS);
	
	if((vTest1 < 0) || (vTest2 < 0) || (vTest3 < 0)){
		return false;
	}else{
		return true;
	}
}

function validarCPF(jsNome)
{
   //var cpf = document.getElementById(jsNome).value;
   var cpf = jsNome;
   var filtro = /^\d{3}.\d{3}.\d{3}-\d{2}$/i;

   if(!filtro.test(cpf))
   {
	 //window.alert("CPF inválido. Tente novamente.");
	 jsCPFAlert = 1;
	 return false;
   }

   cpf = cpf.replace(".","")
   cpf = cpf.replace(".","")
   cpf = cpf.replace("-","")

   if(cpf.length != 11     || cpf == "00000000000" || cpf == "11111111111" ||
	  cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
	  cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
	  cpf == "88888888888" || cpf == "99999999999")
   {	   
	  //window.alert("CPF inválido. Tente novamente.");
	  jsCPFAlert = 1;
	  return false;
   }
   
   soma = 0;
   
   for(i = 0; i < 9; i++)
	   soma += parseInt(cpf.charAt(i)) * (10 - i);
	 
   resto = 11 - (soma % 11);
   
   if(resto == 10 || resto == 11)
	  resto = 0;
	 
   if(resto != parseInt(cpf.charAt(9)))
   {
	 //window.alert("CPF inválido. Tente novamente.");
	 jsCPFAlert = 1;
	 return false;
   }
   
   soma = 0;
   
   for(i = 0; i < 10; i ++)
	 soma += parseInt(cpf.charAt(i)) * (11 - i);
	 
   resto = 11 - (soma % 11);
   
   if(resto == 10 || resto == 11)
	  resto = 0;
	 
   if(resto != parseInt(cpf.charAt(10)))
   {
	 //window.alert("CPF inválido. Tente novamente.");
	 jsCPFAlert = 1;
	 return false;
   }
   
   jsCPFAlert = 0;
   return true;
   
}

function ValidaCNPJ(cnpj) 
{
	
	var i = 0;  
	var l = 0;  
	var strNum = "";  
	var strMul = "6543298765432";  
	var character = "";  
	var iValido = 1;  
	var iSoma = 0;  
	var strNum_base = "";  
	var iLenNum_base = 0;  
	var iLenMul = 0;  
	var iSoma = 0;  
	var strNum_base = 0;  
	var iLenNum_base = 0;  
	
	if (cnpj == "")        
		return (true);  
		
	l = cnpj.length;  
	
	for (i = 0; i < l; i++) {        
		caracter = cnpj.substring(i,i+1)        
		if ((caracter >= '0') && (caracter <= '9'))           
			strNum = strNum + caracter;  
	};
	
	if(strNum.length != 14)        
	{
		return (false);  
	}
		
	strNum_base = strNum.substring(0,12);  
	iLenNum_base = strNum_base.length - 1;  
	iLenMul = strMul.length - 1;  
	
	for(i = 0;i < 12; i++)        
		iSoma = iSoma + parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) * parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10);  
		
	iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);  
	
	if(iSoma == 11 || iSoma == 10)
		iSoma = 0;  
		
	strNum_base = strNum_base + iSoma;  iSoma = 0;  
	iLenNum_base = strNum_base.length - 1  
	
	for(i = 0; i < 13; i++)        
		iSoma = iSoma + parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) * parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10);
		
	iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);  
	
	if(iSoma == 11 || iSoma == 10)        
		iSoma = 0;  
		
	strNum_base = strNum_base + iSoma;  
	
	if(strNum != strNum_base)        
		return (false);  
		
	return (true);

}

