function CriaConexaoAjax()
{
    try
    {
    	var request_o;
    	if(navigator.appName == "Microsoft Internet Explorer")
    		request_o = new ActiveXObject("Microsoft.XMLHTTP");
    	else
    		request_o = new XMLHttpRequest();
    	return request_o;
    }
    catch(err)
    {
        var txt="";
        txt="Ocorreu um erro na página:\n\n";
        txt+="Descrição: " + err.description;
        alert(txt);
    } 
}
function Trim(str)
{
	return str.replace(/^\s+|\s+$/g,"");
}
function LimparControleIn(elemento)
{ 
   var element = elemento;
   element.style.backgroundColor = "#00ccff";
   if (element.value == 'Digite aqui')
   {
   		element.value = '';
   }
} 
function LimparControleOut(elemento)
{ 
	var element = elemento
    element.style.backgroundColor = "#F0F8FF";
	   if (element.value == '')
   {
   		element.value = 'Digite aqui';
		element.style.backgroundColor = "#F3F3F3";
   }
	
}
function RecuperaListaLojas(codRede,nomeLoja,origem,codPromotor,diaDesejado,mesDesejado,anoDesejado)
{
	document.getElementById("resultListaLojas").innerHTML = "Aguarde carregando lista de lojas<br><img src='imagens/carregando.gif'>"
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=RecuperaListaLojas";
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&nomeLoja=" + nomeLoja;
	strEnvio += "&origem=" + origem;
	strEnvio += "&codPromotor=" + codPromotor;
	strEnvio += "&diaDesejado=" + diaDesejado;
	strEnvio += "&mesDesejado=" + mesDesejado;
	strEnvio += "&anoDesejado=" + anoDesejado;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaListaLojas = new CriaConexaoAjax();
	RecuperaListaLojas.open('get', strEnvio);
	RecuperaListaLojas.onreadystatechange = function RespostaListaLojas()
										{
											if(RecuperaListaLojas.readyState == 4)
											{
												document.getElementById("resultListaLojas").innerHTML = RecuperaListaLojas.responseText;
											}
										}

	RecuperaListaLojas.send(null);
}
function OcultaExibeObj(objeto)
{
	var elemento = objeto
	if(elemento.style.visibility == "hidden")
	{
			elemento.style.visibility = "visible";
	}
	else
	{
			elemento.style.visibility = "hidden";
	}
}
function RedirDocumento(documento)
{
	document.location = documento;
}
function openModal(pUrl, pWidth, pHeight) {
	if(VerificaRelatorio())
	{
		window.open(pUrl, "wndModal", "width=" + pWidth + ",height=" + pHeight + ",resizable=no,scrollbars=yes");
	}
}
function openModalLive(pUrl, pWidth, pHeight) {
		window.open(pUrl, "wndModal", "width=" + pWidth + ",height=" + pHeight + ",resizable=no,scrollbars=yes");
}
function openModalLiveNoUnique(pUrl, pWidth, pHeight, pName) {
		window.open(pUrl, pName, "width=" + pWidth + ",height=" + pHeight + ",resizable=yes,scrollbars=yes");
}
function JanelaAlerta(textoApresentado, pWidth, pHeight)
{
		if (window.showModalDialog)
		{
			return window.showModalDialog("JanelaAlerta.asp?mensagem="+textoApresentado, 'window1',"dialogWidth:" + pWidth + "px;dialogHeight:" + pHeight + "px");
		}
		else
		{
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
				window.open("JanelaAlerta.asp?mensagem="+textoApresentado, "wndModal", "width=" + pWidth + ",height=" + pHeight + ",resizable=no,modal=yes");
				return true;
			}
			catch (e) {
				alert("Script n�o confi�vel, n�o � poss�vel abrir janela modal.");
				return false;
			}
		}
}
function TrocarClasse(nomeObjeto,classeTroca1,classeTroca2)
{
	elemento = document.getElementById(nomeObjeto);
	if(elemento.className == classeTroca1)
	{
		elemento.className = classeTroca2;		
	}
	else
	{
		elemento.className = classeTroca1;	
	}	
}
function IniciarRelatorio()
{
	//var horarioVisitaEntrada = document.getElementById("horarioVisitaEntrada").value;
	//var horarioVisitaSaida = document.getElementById("horarioVisitaSaida").value;
	var dataRelatorio = document.getElementById("dataRelatorio").value;
	var codPromotor = document.getElementById("promotor").value;
	//var codExecutivo = document.getElementById("executivo").value;
	var codCoordenador = document.getElementById("coordenador").value;
	var idRelatorio = document.getElementById("idRelatorio").value;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=IniciaRelatorio";
	//strEnvio += "&horarioVisitaEntrada=" + horarioVisitaEntrada;
	//strEnvio += "&horarioVisitaSaida=" + horarioVisitaSaida;
	strEnvio += "&dataRelatorio=" + dataRelatorio;
	strEnvio += "&codPromotor=" + codPromotor;
	//strEnvio += "&codExecutivo=" + codExecutivo;
	strEnvio += "&codCoordenador=" + codCoordenador;
	strEnvio += "&idRelatorio=" + idRelatorio
	strEnvio += "&tms=" + new Date().getTime();
	var IniciaNovoRelatorio = new CriaConexaoAjax();
	IniciaNovoRelatorio.open('get', strEnvio);
	IniciaNovoRelatorio.onreadystatechange = function RespostaNovoRelatorio()
										{
											if(IniciaNovoRelatorio.readyState == 4)
											{
												var retorno = IniciaNovoRelatorio.responseText;
												document.getElementById("codRelatorio").value = Trim(retorno);
											}
										}
	IniciaNovoRelatorio.send(null);
	JanelaAlerta('1',250,250);
	document.getElementById("iniciarRelatorio").style.visibility = "hidden";
	document.getElementById("descartarRelatorio").style.visibility = "visible";
}
function DescartarRelatorio()
{
	JanelaAlerta('3',250,250);
	document.getElementById("iniciarRelatorio").style.visibility = "visible";
	document.getElementById("descartarRelatorio").style.visibility = "hidden";
	document.getElementById("codRelatorio").value = "";
	document.getElementById("numeroRelatorio").innerHTML = "";
}
function VerificaRelatorio()
{
	if(document.getElementById("codRelatorio").value == "")
	{
		JanelaAlerta('2',250,250);
		return false;
	}
	else
	{
		return true;
	}
	
}
function EscolheLoja(indice)
{
		opener.document.getElementById("codLoja").value = document.getElementById("hcodLoja"+indice).value;
		opener.document.getElementById("nomeLoja").value = document.getElementById("hnomeLoja"+indice).value;
		opener.document.getElementById("enderecoLoja").value = document.getElementById("hendereco"+indice).value;
		opener.document.getElementById("cidade").value = document.getElementById("hcidade"+indice).value;
		opener.document.getElementById("responsavelLoja").value = document.getElementById("hcontato"+indice).value;
		opener.document.getElementById("estado").value = document.getElementById("hbairro"+indice).value;
		opener.document.getElementById("telefoneLoja").value = document.getElementById("htelefone1"+indice).value;
		opener.document.getElementById("emailResponsavel").value = document.getElementById("hemail"+indice).value;
		UpdateRelatorioLoja(document.getElementById("hcodLoja"+indice).value,opener.document.getElementById("codRelatorio").value);
		self.close();
		window.parent.close();
}
function EscolheLojaRoteiro(indice,codPromotor,diaDesejado,mesDesejado,anoDesejado)
{
		UpdateLojaRoteiro(document.getElementById("hcodLoja"+indice).value,codPromotor,diaDesejado,mesDesejado,anoDesejado);
		ListaLojasRoteiroOpener(codPromotor,diaDesejado,mesDesejado,anoDesejado,"conteinerDia"+ diaDesejado);
		//self.close();
		//window.parent.close();
}
function UpdateRelatorioLoja(codLoja,codRelatorio)
{	
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=UpdateRelatorioLoja";
		strEnvio += "&codLoja=" + codLoja;
		strEnvio += "&codRelatorio=" + codRelatorio;
		strEnvio += "&tms=" + new Date().getTime();
		var AtualizaRelatorio = new CriaConexaoAjax();
		AtualizaRelatorio.open('get', strEnvio);
		AtualizaRelatorio.onreadystatechange = function RespostaNovoAtualizacao()
											{
												if(AtualizaRelatorio.readyState == 4)
												{
													var retorno = AtualizaRelatorio.responseText;
												}
											}
		AtualizaRelatorio.send(null);
}
function UpdateLojaRoteiro(codLoja,codPromotor,diaDesejado,mesDesejado,anoDesejado)
{	
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=UpdateLojaRoteiro";
		strEnvio += "&codLoja=" + codLoja;
		strEnvio += "&codPromotor=" + codPromotor;
		strEnvio += "&diaDesejado=" + diaDesejado;
		strEnvio += "&mesDesejado=" + mesDesejado;
		strEnvio += "&anoDesejado=" + anoDesejado;
		strEnvio += "&tms=" + new Date().getTime();
		var AtualizaLojaRoteiro = new CriaConexaoAjax();
		AtualizaLojaRoteiro.open('get', strEnvio);
		AtualizaLojaRoteiro.onreadystatechange = function RespostaNovoAtualizacao(){
													if(AtualizaLojaRoteiro.readyState == 4){
														var retorno = AtualizaLojaRoteiro.responseText;
													}
												 }
		AtualizaLojaRoteiro.send(null);
}
function InsereBalconista(codControle)
{	
		if(VerificaRelatorio())
		{
			var codRelatorio = document.getElementById("codRelatorio").value;
			var nomeBalconista = document.getElementById("balconista"+codControle).value;
			var emailBalconista = document.getElementById("emailBalconista"+codControle).value;
			var telefoneBalconista = document.getElementById("telBalconista"+codControle).value;
			if(nomeBalconista != "")
			{
				strEnvio  = "componentes/ajax.asp";
				strEnvio += "?parametro=InsereBalconista";
				strEnvio += "&codRelatorio=" + codRelatorio;
				strEnvio += "&nomeBalconista=" + nomeBalconista;
				strEnvio += "&emailBalconista=" + emailBalconista;
				strEnvio += "&telefoneBalconista=" + telefoneBalconista;	
				strEnvio += "&tms=" + new Date().getTime();

				var InsereNovoBalconista = new CriaConexaoAjax();
				InsereNovoBalconista.open('get', strEnvio);
				InsereNovoBalconista.onreadystatechange = function RespostaNovoBalconista()
													{
														if(InsereNovoBalconista.readyState == 4)
														{
															var retorno = InsereNovoBalconista.responseText;
															if(Trim(retorno) == 'ok')
															{
																document.getElementById('ok'+ codControle).value = 'Cadastrado';
																document.getElementById('ok'+ codControle).disabled = true;
															}
														}
													}
				InsereNovoBalconista.send(null);
			}
			else
			{
				JanelaAlerta("4",250,250);	
			}
		}
}
function InsereProdutoEmpresa(codControle)
{
	if(VerificaRelatorio())
	{
		var codRelatorio = document.getElementById("codRelatorio").value;
		var codProduto = document.getElementById("hcodProduto"+ codControle).value;
		var valorPreco = document.getElementById("valorPreco"+ codControle).value;
		var valorEstoque = document.getElementById("valorEstoque"+ codControle).value;
		var valorEstoqueLoja = document.getElementById("valorEstoqueLoja"+ codControle).value;
		var valorEstoqueArmazem = document.getElementById("valorEstoqueArmazem"+ codControle).value;
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=InsereProdutoEmpresa";
		strEnvio += "&codProduto="+ codProduto ;
		strEnvio += "&codRelatorio="+ codRelatorio ;
		strEnvio += "&valorPreco="+ valorPreco;
		strEnvio += "&valorEstoque="+ valorEstoque;
		strEnvio += "&valorEstoqueLoja="+ valorEstoqueLoja;
		strEnvio += "&valorEstoqueArmazem="+ valorEstoqueArmazem;
		strEnvio += "&tms=" + new Date().getTime();
		var ListaProdutosEmpresa = new CriaConexaoAjax();
		ListaProdutosEmpresa.open('get', strEnvio);
		ListaProdutosEmpresa.onreadystatechange = function RespostaListaProdutosEmpresa()
											{
												if(ListaProdutosEmpresa.readyState == 4)
												{
													var retorno = ListaProdutosEmpresa.responseText;
													if(Trim(retorno) == "ok")
													{
														document.getElementById("produto"+ codControle).className = "classeOn";
														document.getElementById("produto"+ codControle).onclick = "";
													}
												}
											}
		ListaProdutosEmpresa.send(null);
	}
}
function ListaProdutosEmpresa(divRecebeDados,tipoLista)
{
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=ListaProdutosEmpresa";
		strEnvio += "&tipoLista=" + tipoLista;
		strEnvio += "&tms=" + new Date().getTime();
		
		var ListaProdutosEmpresa = new CriaConexaoAjax();
		ListaProdutosEmpresa.open('get', strEnvio);
		ListaProdutosEmpresa.onreadystatechange = function RespostaListaProdutosEmpresa()
											{
												if(ListaProdutosEmpresa.readyState == 4)
												{
													var retorno = ListaProdutosEmpresa.responseText;
													document.getElementById(divRecebeDados).innerHTML = Trim(retorno);											
												}
											}
		ListaProdutosEmpresa.send(null);
}
function InsereProdutoConcorrentes(codControle)
{
	if(VerificaRelatorio())
	{
		var codRelatorio = document.getElementById("codRelatorio").value;
		var codProdutoC = document.getElementById("hcodProdutoC"+ codControle).value;
		var valorPrecoC = document.getElementById("valorPrecoC"+ codControle).value;
		var valorEstoqueC = document.getElementById("valorEstoqueC"+ codControle).value;	
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=InsereProdutoConcorrentes";
		strEnvio += "&codProdutoC="+ codProdutoC ;
		strEnvio += "&codRelatorio="+ codRelatorio ;
		strEnvio += "&valorPrecoC="+ valorPrecoC;
		strEnvio += "&valorEstoqueC="+ valorEstoqueC;
		strEnvio += "&tms=" + new Date().getTime();
		var InsereProdutosConcorrentes = new CriaConexaoAjax();
		InsereProdutosConcorrentes.open('get', strEnvio);
		InsereProdutosConcorrentes.onreadystatechange = function RespostaListaProdutosEmpresa()
											{
												if(InsereProdutosConcorrentes.readyState == 4)
												{
													var retorno = InsereProdutosConcorrentes.responseText;
													if(Trim(retorno) == "ok")
													{
														document.getElementById("produtoC"+ codControle).className = "classeOn";
														document.getElementById("produtoC"+ codControle).onclick = "";
													}
												}
											}
		InsereProdutosConcorrentes.send(null);
	}
}
function ListaProdutosConcorrentes()
{
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=ListaProdutosConcorrentes";
		var ListaProdutoConcorrentes = new CriaConexaoAjax();
		ListaProdutoConcorrentes.open('get', strEnvio);
		ListaProdutoConcorrentes.onreadystatechange = function RespostaListaProdutosConcorrentes()
											{
												if(ListaProdutoConcorrentes.readyState == 4)
												{
													var retorno = ListaProdutoConcorrentes.responseText;
													document.getElementById("produtosConcorrente").innerHTML = Trim(retorno);											
												}
											}
		ListaProdutoConcorrentes.send(null);
}
function InserePDVs(codControle)
{
	if(VerificaRelatorio())
	{
		var codRelatorio = document.getElementById("codRelatorio").value;
		var codPDV = document.getElementById("hcodPDV"+ codControle).value;
		var valorPDV = document.getElementById("valorPDV"+ codControle).value;	
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=InsereDPV";
		strEnvio += "&codPDV="+ codPDV;
		strEnvio += "&codRelatorio="+ codRelatorio;
		strEnvio += "&valorPDV="+ valorPDV;
		strEnvio += "&tms=" + new Date().getTime();
		var InserePDV = new CriaConexaoAjax();
		InserePDV.open('get', strEnvio);
		InserePDV.onreadystatechange = function RespostaPDV()
											{
												if(InserePDV.readyState == 4)
												{
													var retorno = InserePDV.responseText;
													if(Trim(retorno) == "ok")
													{
														document.getElementById("PDV"+ codControle).className = "classeOn";
														document.getElementById("PDV"+ codControle).onclick = "";
													}
												}
											}
		InserePDV.send(null);
	}
}
function ListaPDVs()
{
	
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=ListaPDV";
	var ListaMaterialPDV = new CriaConexaoAjax();
	ListaMaterialPDV.open('get', strEnvio);
	ListaMaterialPDV.onreadystatechange = function RespostaListaPDV()
										{
											if(ListaMaterialPDV.readyState == 4)
											{
												var retorno = ListaMaterialPDV.responseText;
												document.getElementById("produtosPDV").innerHTML = Trim(retorno);											
											}
										}
	ListaMaterialPDV.send(null);
}
function InsereInfPDVs()
{
	if(VerificaRelatorio())
	{
		var codRelatorio = document.getElementById("codRelatorio").value;
		var descricaoProdutoPromocao = document.getElementById("descricaoProdutoPromocao").value;
		var acoesConcorrencia = document.getElementById("acoesConcorrencia").value;
		var quantidadeAbordagens = document.getElementById("quantidadeAbordagens").value;
		var quantidadeVendida = document.getElementById("quantidadeVendida").value;	
		if((descricaoProdutoPromocao != "") && (acoesConcorrencia != ""))
		{
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=InsereInfDPV";
			strEnvio += "&codRelatorio="+ codRelatorio;
			strEnvio += "&descricaoProdutoPromocao="+ descricaoProdutoPromocao;
			strEnvio += "&acoesConcorrencia="+ acoesConcorrencia;
			strEnvio += "&quantidadeAbordagens="+ quantidadeAbordagens;
			strEnvio += "&quantidadeVendida="+ quantidadeVendida;	
			strEnvio += "&tms=" + new Date().getTime();
			var InsereInfPDV = new CriaConexaoAjax();
			InsereInfPDV.open('get', strEnvio);
			InsereInfPDV.onreadystatechange = function RespostaInfPDV()
												{
													if(InsereInfPDV.readyState == 4)
													{
														var retorno = InsereInfPDV.responseText;
														if(Trim(retorno) == "ok")
														{
															document.getElementById('atualizaInformacoes').value = 'Cadastrado';
															document.getElementById('atualizaInformacoes').disabled = true;
														}
													}
												}
			InsereInfPDV.send(null);
		}
		else
		{
			JanelaAlerta('5',250,250);
		}
	}
}
function ApagaZero(campo)
{
	campo.value = "";
}
function ColocaZero(campo)
{
	if (campo.value == "")
	{
	    campo.value = 0;
	}
}
function ConsisteNumero(codigo)
{
	var flag = false;
	if (((codigo >= 48) && (codigo <= 58)) || (codigo >= 96) && (codigo <= 105))
	{
		flag = true;
	}
	if ((codigo==8) || (codigo==9) || (codigo==16) || (codigo==17) || (codigo==18) || (codigo==37) || (codigo==38) || (codigo==39) || (codigo==40) || (codigo==46) || (codigo==35) || (codigo==36) || (codigo==190))
	{
		flag = true;
	}
	if (window.event.ctrlKey && codigo== 86)
	{
		flag = true;
	}
	//campo.value = campo.value.replace(/,/gi, ".");
	return flag;
}
function ValidaEmail(email)
{
    if(email.indexOf("@") == -1)
    {
        return false;
    }
    if(email.indexOf(" ") >= 0)
    {
        return false;
    }
    if(email.indexOf("@") != mail.lastIndexOf("@"))
    {
        return false;
    }
    if(email.indexOf("@") == 0)
    {
        return false;
    }
    var varSplit = email.split("@");
    if(varSplit.length  < 2)
    {
        return false;
    }
    if(varSplit[1].indexOf(".") <= 0)
    {
        return false;
    }
    var varIndexPonto = varSplit[1].indexOf(".");
    if(varSplit[1].length-1 <= varIndexPonto)
    {
        return false;
    }
     return true;
}
function PesquisaCompletaRelatorio()
{
	document.body.style.cursor = 'wait';
	document.getElementById("LojasEncontradas").bgColor = "#DBEDFF";
	document.getElementById("LojasEncontradas").align = "center";
	document.getElementById("LojasEncontradas").innerHTML = "<img src='imagens/carregando.gif'>";
	var rede = document.getElementById("rede").value;
	var loja = document.getElementById("loja").value;
	var dataInicial = document.getElementById("dataInicial").value;
	var dataFinal = document.getElementById("dataFinal").value;
	var promotor = document.getElementById("promotor").value;	
	var executivo = document.getElementById("executivo").value;	
	var ordenacao = document.getElementById("ordenacao").value;	
	var metodoOrdenacao = document.getElementById("metodoOrdenacao").value;	
	var canal = document.getElementById("canal").value;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=PesquisaCompletaRelatorio";
	strEnvio += "&rede=" + rede;
	strEnvio += "&loja=" + loja;
	strEnvio += "&dataInicial=" + dataInicial;
	strEnvio += "&dataFinal=" + dataFinal;
	strEnvio += "&promotor=" + promotor;
	strEnvio += "&executivo=" + executivo;
	strEnvio += "&ordenacao=" + ordenacao;
	strEnvio += "&metodoOrdenacao=" + metodoOrdenacao;
	strEnvio += "&canal=" + canal;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaRelatorio = new CriaConexaoAjax();
	RecuperaRelatorio.open('get', strEnvio);
	RecuperaRelatorio.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaRelatorio.readyState == 4)
											{
												document.getElementById("LojasEncontradas").innerHTML = "";
												document.getElementById("LojasEncontradas").innerHTML = RecuperaRelatorio.responseText;
												document.getElementById("LojasEncontradas").bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaRelatorio.send(null);
}
function PesquisaCompletaRelatorioRuptura()
{
	document.body.style.cursor = 'wait';
	document.getElementById("LojasEncontradas").bgColor = "#DBEDFF";
	document.getElementById("LojasEncontradas").align = "center";
	document.getElementById("LojasEncontradas").innerHTML = "<img src='imagens/carregando.gif'>";
	var rede = document.getElementById("redes").value;
	var loja = document.getElementById("lojas").value;
	var estado = document.getElementById("estados").value;
	//var dataInicial = document.getElementById("dataInicial").value;
	//var dataFinal = document.getElementById("dataFinal").value;
	//var promotor = document.getElementById("promotor").value;
	//var executivo = document.getElementById("executivo").value;
	//var ordenacao = document.getElementById("ordenacao").value;
	//var metodoOrdenacao = document.getElementById("metodoOrdenacao").value;
	//var canal = document.getElementById("canal").value;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=PesquisaCompletaRelatorioRuptura";
	strEnvio += "&rede=" + rede;
	strEnvio += "&loja=" + loja;
	strEnvio += "&estado=" + estado;
	//strEnvio += "&dataInicial=" + dataInicial;
	//strEnvio += "&dataFinal=" + dataFinal;
	//strEnvio += "&promotor=" + promotor;
	//strEnvio += "&executivo=" + executivo;
	//strEnvio += "&ordenacao=" + ordenacao;
	//strEnvio += "&metodoOrdenacao=" + metodoOrdenacao;
	//strEnvio += "&canal=" + canal;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaRelatorio = new CriaConexaoAjax();
	RecuperaRelatorio.open('get', strEnvio);
	RecuperaRelatorio.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaRelatorio.readyState == 4)
											{
												document.getElementById("LojasEncontradas").innerHTML = "";
												document.getElementById("LojasEncontradas").innerHTML = RecuperaRelatorio.responseText;
												document.getElementById("LojasEncontradas").bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaRelatorio.send(null);
}
function ExcluiRelatorio(codRelatorio)
{
	if(codRelatorio != "")
	{
		if(confirm("Deseja realmente excluir o relat�rio N� "+ codRelatorio))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiRelatorio";
			strEnvio += "&codRelatorio=" + codRelatorio;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiRelatorio = new CriaConexaoAjax();
			ExcluiRelatorio.open('get', strEnvio);
			ExcluiRelatorio.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiRelatorio.readyState == 4)
													{
														var resposta = Trim(ExcluiRelatorio.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codRelatorio).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Relat�rio exclu�do com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiRelatorio.send(null);	
		}
				  
	}
}
function ExcluiProduto(codRelatorio)
{
	if(codRelatorio != "")
	{
		if(confirm("Deseja realmente excluir o Produto N� "+ codRelatorio))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiProduto";
			strEnvio += "&codRelatorio=" + codRelatorio;
			strEnvio += "&tms=" + new Date().getTime();		
			var ExcluiRelatorio = new CriaConexaoAjax();
			ExcluiRelatorio.open('get', strEnvio);
			ExcluiRelatorio.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiRelatorio.readyState == 4)
													{
														var resposta = Trim(ExcluiRelatorio.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codRelatorio).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Produto exclu�do com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiRelatorio.send(null);	
		}
				  
	}
}
function ExcluiCanal(codCanal)
{
	if(codCanal != "")
	{
		if(confirm("Deseja realmente excluir o Canal N� "+ codCanal))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiCanal";
			strEnvio += "&codCanal=" + codCanal;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCanal = new CriaConexaoAjax();
			ExcluiCanal.open('get', strEnvio);
			ExcluiCanal.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCanal.readyState == 4)
													{
														var resposta = Trim(ExcluiCanal.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codCanal).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Canal exclu�do com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCanal.send(null);	
		}
				  
	}
}
function ExcluiRegiao(codCanal)
{
	if(codCanal != "")
	{
		if(confirm("Deseja realmente excluir a Regi�o N� "+ codCanal))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiRegiao";
			strEnvio += "&codRegiao=" + codCanal;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCanal = new CriaConexaoAjax();
			ExcluiCanal.open('get', strEnvio);
			ExcluiCanal.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCanal.readyState == 4)
													{
														var resposta = Trim(ExcluiCanal.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codCanal).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Regi�o exclu�da com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCanal.send(null);	
		}
				  
	}
}
function ExcluiRede(codCanal)
{
	if(codCanal != "")
	{
		if(confirm("Deseja realmente excluir a Rede N� "+ codCanal))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiRede";
			strEnvio += "&codRede=" + codCanal;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCanal = new CriaConexaoAjax();
			ExcluiCanal.open('get', strEnvio);
			ExcluiCanal.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCanal.readyState == 4)
													{
														var resposta = Trim(ExcluiCanal.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codCanal).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Rede exclu�da com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCanal.send(null);	
		}
				  
	}
}
function ExcluiFabricante(codCanal)
{
	if(codCanal != "")
	{
		if(confirm("Deseja realmente excluir o Fabricante N° "+ codCanal))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiFabricante";
			strEnvio += "&codFabricante=" + codCanal;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCanal = new CriaConexaoAjax();
			ExcluiCanal.open('get', strEnvio);
			ExcluiCanal.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCanal.readyState == 4)
													{
														var resposta = Trim(ExcluiCanal.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codCanal).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Excluído com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCanal.send(null);	
		}
				  
	}
}
function ExcluiSituacao(codCanal)
{
	if(codCanal != "")
	{
		if(confirm("Deseja realmente excluir a Situa��o N� "+ codCanal))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiSituacao";
			strEnvio += "&codSituacao=" + codCanal;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCanal = new CriaConexaoAjax();
			ExcluiCanal.open('get', strEnvio);
			ExcluiCanal.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCanal.readyState == 4)
													{
														var resposta = Trim(ExcluiCanal.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codCanal).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Situa��o exclu�da com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCanal.send(null);	
		}
				  
	}
}

function ExcluiCategoria(id)
{
	if(id != "")
	{
		if(confirm("Deseja realmente excluir a Categoria N° "+ id))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiCategoria";
			strEnvio += "&codCategoria=" + id;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCanal = new CriaConexaoAjax();
			ExcluiCanal.open('get', strEnvio);
			ExcluiCanal.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCanal.readyState == 4)
													{
														var resposta = Trim(ExcluiCanal.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ id).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Categoria excluída com sucesso.");
														}
													}
												}
		
			ExcluiCanal.send(null);	
		}
				  
	}
}
function ExcluiLinha(id)
{
	if(id != "")
	{
		if(confirm("Deseja realmente excluir a Linha N° "+ id))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiLinha";
			strEnvio += "&codLinha=" + id;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiLinha = new CriaConexaoAjax();
			ExcluiLinha.open('get', strEnvio);
			ExcluiLinha.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiLinha.readyState == 4)
													{
														var resposta = Trim(ExcluiLinha.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ id).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Linha excluída com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiLinha.send(null);	
		}
				  
	}
}
function ExcluiCliente(codCanal)
{
	if(codCanal != "")
	{
		if(confirm("Deseja realmente excluir o Cliente N° "+ codCanal))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiCliente";
			strEnvio += "&codCliente=" + codCanal;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCanal = new CriaConexaoAjax();
			ExcluiCanal.open('get', strEnvio);
			ExcluiCanal.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCanal.readyState == 4)
													{
														var resposta = Trim(ExcluiCanal.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codCanal).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Cliente exclu�do com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCanal.send(null);	
		}
				  
	}
}

function ExcluiLoja(codLoja)
{
	if(codLoja != "")
	{
		if(confirm("Deseja realmente excluir a Loja N. "+ codLoja))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiLoja";
			strEnvio += "&codLoja=" + codLoja;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiLoja = new CriaConexaoAjax();
			ExcluiLoja.open('get', strEnvio);
			ExcluiLoja.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiLoja.readyState == 4)
													{
														var resposta = Trim(ExcluiLoja.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codLoja).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Canal exclu�do com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiLoja.send(null);	
		}
				  
	}
}
function ExcluiUsuario(codUsuario)
{
	if(codUsuario != "")
	{
		if(confirm("Deseja realmente excluir o Usu�rio N. "+ codUsuario))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiUsuario";
			strEnvio += "&codUsuario=" + codUsuario;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiLoja = new CriaConexaoAjax();
			ExcluiLoja.open('get', strEnvio);
			ExcluiLoja.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiLoja.readyState == 4)
													{
														var resposta = Trim(ExcluiLoja.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codUsuario).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Usu�rio exclu�do com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiLoja.send(null);	
		}
				  
	}
}
function ExcluiArquivo(codLogImportacao)
{
	if(codLogImportacao != "")
	{
		if(confirm("Deseja realmente excluir o Arquivo Importado N. "+ codLogImportacao))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiArquivo";
			strEnvio += "&codLogImportacao=" + codLogImportacao;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiArquivo = new CriaConexaoAjax();
			ExcluiArquivo.open('get', strEnvio);
			ExcluiArquivo.onreadystatechange = function RespostaRelatorio()	{
											    if(ExcluiArquivo.readyState == 4)
											    {
												var resposta = Trim(ExcluiArquivo.responseText);
												if(resposta == "ok")
												{
												    document.getElementById("linha"+ codLogImportacao).style.visibility = "hidden";
												    document.body.style.cursor = 'default';
												    alert("Arquivo excluído com sucesso.");
												    //window.history.go(0);
												}
											    }
											}

			ExcluiArquivo.send(null);
		}

	}
}
function ExibeRelatorio(codControle,codRelatorio)
{
	var pWidth = 900;
	var pHeight = 600;
	var pUrl = "VisualizaRelatorio.asp?codControle=" + codControle + "&codRelatorio="+ codRelatorio;
	window.open(pUrl, "wndModal", "width=" + pWidth + ",height=" + pHeight + ",resizable=no,scrollbars=yes");
}
function PreencheDadosPrincipais(codControle,codRelatorio)
{	

		//document.getElementById("horarioVisitaEntrada").value =  window.opener.document.getElementById("hhorarioVisitaEntrada"+ codControle).value;
		//document.getElementById("horarioVisitaSaida").value =  window.opener.document.getElementById("hhorarioVisitaSaida"+ codControle).value;
		document.getElementById("dataRelatorio").value =  window.opener.document.getElementById("hdataVisita"+ codControle).value;
		document.getElementById("quantidadeAbordagens").value =  window.opener.document.getElementById("hqtdAbordagens"+ codControle).value;
		document.getElementById("quantidadeVendida").value =  window.opener.document.getElementById("hqtdVendida"+ codControle).value;
		document.getElementById("acoesConcorrencia").value =  window.opener.document.getElementById("hacoesConcorrencia"+ codControle).value;
		document.getElementById("descricaoProdutoPromocao").value =  window.opener.document.getElementById("hprodutosEmPromocao"+ codControle).value;
		document.getElementById("nomePromotor").value =  window.opener.document.getElementById("hnomePromotor"+ codControle).value;
		document.getElementById("nomeExecutivo").value =  window.opener.document.getElementById("hnomeExecutivo"+ codControle).value;
		document.getElementById("codLoja").value =  opener.document.getElementById("hcodLoja"+ codControle).value;
		document.getElementById("nomeLoja").value =  opener.document.getElementById("hnomeLoja"+ codControle).value;
		document.getElementById("nomeRede").value =  opener.document.getElementById("hnomeRede"+ codControle).value;
		document.getElementById("enderecoLoja").value =  opener.document.getElementById("hendereco"+ codControle).value + ", " +opener.document.getElementById("hnumero"+ codControle).value;
		document.getElementById("cidade").value =  opener.document.getElementById("hmunicipio"+ codControle).value;
		document.getElementById("estado").value =  opener.document.getElementById("huf"+ codControle).value;
		document.getElementById("responsavelLoja").value =  opener.document.getElementById("hcontato"+ codControle).value;
		document.getElementById("telefoneLoja").value =  opener.document.getElementById("hddd1"+ codControle).value +", "+ opener.document.getElementById("htelefone1"+ codControle).value;
		document.getElementById("emailResponsavel").value =  opener.document.getElementById("hemail"+ codControle).value;
		
}	
function PesquisaShoppingEstoque(codRelatorio)
{
	if(codRelatorio != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById("produtosEmpresa").bgColor = "#DBEDFF";
		document.getElementById("produtosEmpresa").align = "center";
		document.getElementById("produtosEmpresa").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=PesquisaShoppingEstoque";
		strEnvio += "&codRelatorio=" + codRelatorio;
		strEnvio += "&tms=" + new Date().getTime();
		var RecuperaShoppingEstoque = new CriaConexaoAjax();
		RecuperaShoppingEstoque.open('get', strEnvio);
		RecuperaShoppingEstoque.onreadystatechange = function RespostaPesquisa()
											{
												if(RecuperaShoppingEstoque.readyState == 4)
												{
													document.getElementById("produtosEmpresa").innerHTML = "";
													document.getElementById("produtosEmpresa").innerHTML = RecuperaShoppingEstoque.responseText;
													document.getElementById("produtosEmpresa").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
	
		RecuperaShoppingEstoque.send(null);
			
	}
}
function PesquisaShoppingEstoqueConcorrentes(codRelatorio)
{
	if(codRelatorio != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById("produtosConcorrente").bgColor = "#DBEDFF";
		document.getElementById("produtosConcorrente").align = "center";
		document.getElementById("produtosConcorrente").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=PesquisaShoppingEstoqueConcorrente";
		strEnvio += "&codRelatorio=" + codRelatorio;
		strEnvio += "&tms=" + new Date().getTime();
		var RecuperaShoppingEstoqueConcorrentes = new CriaConexaoAjax();
		RecuperaShoppingEstoqueConcorrentes.open('get', strEnvio);
		RecuperaShoppingEstoqueConcorrentes.onreadystatechange = function RespostaPesquisa()
											{
												if(RecuperaShoppingEstoqueConcorrentes.readyState == 4)
												{
													document.getElementById("produtosConcorrente").innerHTML = "";
													document.getElementById("produtosConcorrente").innerHTML = RecuperaShoppingEstoqueConcorrentes.responseText;
													document.getElementById("produtosConcorrente").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
	
		RecuperaShoppingEstoqueConcorrentes.send(null);			
	}
}
function PesquisaPDV(codRelatorio)
{
	if(codRelatorio != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById("produtosPDV").bgColor = "#DBEDFF";
		document.getElementById("produtosPDV").align = "center";
		document.getElementById("produtosPDV").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=PesquisaProdutosPdv";
		strEnvio += "&codRelatorio=" + codRelatorio;
		strEnvio += "&tms=" + new Date().getTime();
		var RecuperaProdutosPdv = new CriaConexaoAjax();
		RecuperaProdutosPdv.open('get', strEnvio);
		RecuperaProdutosPdv.onreadystatechange = function RespostaPesquisa()
											{
												if(RecuperaProdutosPdv.readyState == 4)
												{
													document.getElementById("produtosPDV").innerHTML = "";
													document.getElementById("produtosPDV").innerHTML = RecuperaProdutosPdv.responseText;
													document.getElementById("produtosPDV").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
	
		RecuperaProdutosPdv.send(null);			
	}

}
function PesquisaBalconistas(codRelatorio)
{
	if(codRelatorio != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById("listaBalconistas").bgColor = "#DBEDFF";
		document.getElementById("listaBalconistas").align = "center";
		document.getElementById("listaBalconistas").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=PesquisaBalconistas";
		strEnvio += "&codRelatorio=" + codRelatorio;
		strEnvio += "&tms=" + new Date().getTime();
		var RecuperaBalconistas = new CriaConexaoAjax();
		RecuperaBalconistas.open('get', strEnvio);
		RecuperaBalconistas.onreadystatechange = function RespostaPesquisa()
											{
												if(RecuperaBalconistas.readyState == 4)
												{
													document.getElementById("listaBalconistas").innerHTML = "";
													document.getElementById("listaBalconistas").innerHTML = RecuperaBalconistas.responseText;
													document.getElementById("listaBalconistas").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
	
		RecuperaBalconistas.send(null);			
	}

}
function ValidaCampoNotNull(nomeCampo)
{
	campo = document.getElementById(nomeCampo)
	if(campo)
	{
		if(campo.value == "")
		{
			alert("Preencha o campo: "+ campo.name)
			return false;
		}
	}
}
function ValidaCadUsuarios()
{
	if(!ValidaCampoNotNull('nome'))
	{
		return false;
	}
	if(!ValidaCampoNotNull('login'))
	{
		return false;
	}
	if(!ValidaCampoNotNull('senha'))
	{
		return false;
	}
}
function PesquisaCompletaRelatorioGraficos()
{
	document.body.style.cursor = 'wait';
	document.getElementById("RetornoGraficos").bgColor = "#DBEDFF";
	document.getElementById("RetornoGraficos").align = "center";
	document.getElementById("RetornoGraficos").innerHTML = "<img src='imagens/carregando.gif'>";
	var rede = document.getElementById("rede").value;
	var loja = document.getElementById("loja").value;
	var dataInicial = document.getElementById("dataInicial").value;
	var dataFinal = document.getElementById("dataFinal").value;
	var promotor = document.getElementById("promotor").value;	
	var executivo = document.getElementById("executivo").value;	
	var ordenacao = document.getElementById("ordenacao").value;	
	var metodoOrdenacao = document.getElementById("metodoOrdenacao").value;	
	var canal = document.getElementById("canal").value;
	var tipoGrafico = document.getElementById("tipoGrafico").value;
	var categoriaGrafico = document.getElementById("categoriaGrafico").value;
	var listaProdutos = document.getElementById("listaProdutos").value;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=PesquisaCompletaRelatorioGraficos";
	strEnvio += "&rede=" + rede;
	strEnvio += "&loja=" + loja;
	strEnvio += "&dataInicial=" + dataInicial;
	strEnvio += "&dataFinal=" + dataFinal;
	strEnvio += "&promotor=" + promotor;
	strEnvio += "&executivo=" + executivo;
	strEnvio += "&ordenacao=" + ordenacao;
	strEnvio += "&metodoOrdenacao=" + metodoOrdenacao;
	strEnvio += "&canal=" + canal;
	strEnvio += "&tipoGrafico=" + tipoGrafico;
	strEnvio += "&categoriaGrafico=" + categoriaGrafico;
	strEnvio += "&listaProdutos=" + listaProdutos;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaRelatorioGrafico = new CriaConexaoAjax();
	RecuperaRelatorioGrafico.open('get', strEnvio);
	RecuperaRelatorioGrafico.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaRelatorioGrafico.readyState == 4)
											{
												document.getElementById("RetornoGraficos").innerHTML = "";
												document.getElementById("RetornoGraficos").innerHTML = RecuperaRelatorioGrafico.responseText;
												document.getElementById("RetornoGraficos").bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaRelatorioGrafico.send(null);
}
function ExibeListaEscolhida(controle,alvo,objeto)
{
	if(document.getElementById(controle).selectedIndex == alvo)
	{
		TrocarClasse(objeto,"classeExibir","classeOcultar");
	}
	else
	{
		document.getElementById(objeto).className = "classeOcultar";
	}
}
function AcumulaCodChkbox(campo,campoRetorno)
{
	var chk = document.getElementsByName(campo);
	var cRetonro = document.getElementById(campoRetorno);
	retorno = "";
	if(chk)
	{
		limite = chk.length-1;
		for(i=0;i<=limite;i++)
		{
			if(chk[i].checked == true)
			{
				retorno +=  "," + chk[i].value;				 
			}
		}
		cRetonro.value = retorno;
	}
	
}
function htmlEncode(source, display, tabs)
{
	function special(source)
	{
		var result = '';
		for (var i = 0; i < source.length; i++)
		{
			var c = source.charAt(i);
			if (c < ' ' || c > '~')
			{
				c = '&#' + c.charCodeAt() + ';';
			}
			result += c;
		}
		return result;
	}
	
	function format(source)
	{
		// Use only integer part of tabs, and default to 4
		tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
		
		// split along line breaks
		var lines = source.split(/\r\n|\r|\n/);
		
		// expand tabs
		for (var i = 0; i < lines.length; i++)
		{
			var line = lines[i];
			var newLine = '';
			for (var p = 0; p < line.length; p++)
			{
				var c = line.charAt(p);
				if (c === '\t')
				{
					var spaces = tabs - (newLine.length % tabs);
					for (var s = 0; s < spaces; s++)
					{
						newLine += ' ';
					}
				}
				else
				{
					newLine += c;
				}
			}
			// If a line starts or ends with a space, it evaporates in html
			// unless it's an nbsp.
			newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
			lines[i] = newLine;
		}
		
		// re-join lines
		var result = lines.join('<br />');
		
		// break up contiguous blocks of spaces with non-breaking spaces
		result = result.replace(/  /g, ' &nbsp;');
		
		// tada!
		return result;
	}

	var result = source;
	
	// ampersands (&)
	result = result.replace(/\&/g,'&amp;');

	// less-thans (<)
	result = result.replace(/\</g,'&lt;');

	// greater-thans (>)
	result = result.replace(/\>/g,'&gt;');
	
	if (display)
	{
		// format for display
		result = format(result);
	}
	else
	{
		// Replace quotes if it isn't for display,
		// since it's probably going in an html attribute.
		result = result.replace(new RegExp('"','g'), '&quot;');
	}

	// special characters
	result = special(result);
	
	// tada!
	return result;
}
function GeraCalendarioRoteiro(codPromotor,mesDesejado,anoDesejado)
{
	if(codPromotor != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById("containerCalendario").bgColor = "#DBEDFF";
		document.getElementById("containerCalendario").align = "center";
		document.getElementById("containerCalendario").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=GeraCalendarioRoteiro";
		strEnvio += "&codPromotor=" + codPromotor;
		strEnvio += "&mesDesejado=" + mesDesejado;
		strEnvio += "&anoDesejado=" + anoDesejado;
		strEnvio += "&tms=" + new Date().getTime();
		var GeraCalendarioRoteiro = new CriaConexaoAjax();
		GeraCalendarioRoteiro.open('get', strEnvio);
		GeraCalendarioRoteiro.onreadystatechange = function RespostaPesquisa()
											{
												if(GeraCalendarioRoteiro.readyState == 4)
												{
													document.getElementById("containerCalendario").innerHTML = "";
													document.getElementById("containerCalendario").innerHTML = GeraCalendarioRoteiro.responseText;
													document.getElementById("containerCalendario").bgColor = "";
													var scripts = document.getElementById("containerCalendario").getElementsByTagName("script");
													eval(scripts[0].innerHTML);
													document.body.style.cursor = 'default';
												}
											}
	
		GeraCalendarioRoteiro.send(null);			
	}

}
function ListaLojasRoteiro(codPromotor,diaDesejado,mesDesejado,anoDesejado,divAlteracao)
{
	if(codPromotor != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById(divAlteracao).bgColor = "#DBEDFF";
		document.getElementById(divAlteracao).align = "center";
		document.getElementById(divAlteracao).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=ListaLojasRoteiro";
		strEnvio += "&codPromotor=" + codPromotor;
		strEnvio += "&diaDesejado=" + diaDesejado;
		strEnvio += "&mesDesejado=" + mesDesejado;
		strEnvio += "&anoDesejado=" + anoDesejado;
		strEnvio += "&tms=" + new Date().getTime();
		var ListaLojasRoteiro = new CriaConexaoAjax();
		ListaLojasRoteiro.open('get', strEnvio);
		ListaLojasRoteiro.onreadystatechange = function RespostaPesquisa()
											{
												if(ListaLojasRoteiro.readyState == 4)
												{
													document.getElementById(divAlteracao).innerHTML = "";
													document.getElementById(divAlteracao).innerHTML = ListaLojasRoteiro.responseText;
													document.getElementById(divAlteracao).bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
	
		ListaLojasRoteiro.send(null);			
	}
}
function ListaLojasRoteiroOpener(codPromotor,diaDesejado,mesDesejado,anoDesejado,divAlteracao)
{
	if(codPromotor != "")
	{
		opener.document.body.style.cursor = 'wait';
		opener.document.getElementById(divAlteracao).bgColor = "#DBEDFF";
		opener.document.getElementById(divAlteracao).align = "center";
		opener.document.getElementById(divAlteracao).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		var resposta = "";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=ListaLojasRoteiro";
		strEnvio += "&codPromotor=" + codPromotor;
		strEnvio += "&diaDesejado=" + diaDesejado;
		strEnvio += "&mesDesejado=" + mesDesejado;
		strEnvio += "&anoDesejado=" + anoDesejado;
		strEnvio += "&tms=" + new Date().getTime();
		var ListaLojasRoteiroOpener = new CriaConexaoAjax();
		ListaLojasRoteiroOpener.open('get', strEnvio);
		//alert("strEnvio");
		ListaLojasRoteiroOpener.onreadystatechange = function RespostaPesquisa()
											{
												if(ListaLojasRoteiroOpener.readyState == 4)
												{
													//alert(Trim(ListaLojasRoteiroOpener.responseText));
													resposta = ListaLojasRoteiroOpener.responseText;
												}
											}
		ListaLojasRoteiroOpener.send(null);
		alert("Loja adicionada");
		if(resposta != ""){
			//alert("Loja adicionada");
			opener.document.getElementById(divAlteracao).innerHTML = "";
			opener.document.getElementById(divAlteracao).innerHTML = resposta;
			opener.document.getElementById(divAlteracao).bgColor = "";
			opener.document.body.style.cursor = 'default';
		}
	
	}

}
function RecuperaListaPromotores(codCoordenador)
{
	if(codCoordenador != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById('divListaPromotores').bgColor = "#DBEDFF";
		document.getElementById('divListaPromotores').align = "center";
		document.getElementById('divListaPromotores').innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=RecuperaListaPromotores";
		strEnvio += "&codCoordenador=" + codCoordenador;
		strEnvio += "&tms=" + new Date().getTime();
		var ListaLojasRoteiro = new CriaConexaoAjax();
		ListaLojasRoteiro.open('get', strEnvio);
		ListaLojasRoteiro.onreadystatechange = function RespostaPesquisa()
											{
												if(ListaLojasRoteiro.readyState == 4)
												{
													document.getElementById('divListaPromotores').innerHTML = "";
													document.getElementById('divListaPromotores').innerHTML = ListaLojasRoteiro.responseText;
													document.getElementById('divListaPromotores').bgColor = "";
													document.body.style.cursor = 'default';
													document.getElementById('pesquisar').disabled = false;
												}
											}
	
		ListaLojasRoteiro.send(null);			
	}

}
function ExcluiLojaRoteiro(codPromotor,diaDesejado,mesDesejado,anoDesejado,codLoja)
{
	if(codPromotor != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById('conteinerDia'+diaDesejado).bgColor = "#DBEDFF";
		document.getElementById('conteinerDia'+diaDesejado).align = "center";
		document.getElementById('conteinerDia'+diaDesejado).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=ExcluiLojaRoteiro";
		strEnvio += "&codPromotor=" + codPromotor;
		strEnvio += "&diaDesejado=" + diaDesejado;
		strEnvio += "&mesDesejado=" + mesDesejado;
		strEnvio += "&anoDesejado=" + anoDesejado;
		strEnvio += "&codLoja=" + codLoja;
		strEnvio += "&tms=" + new Date().getTime();
		var ExcluiLojasRoteiro = new CriaConexaoAjax();
		ExcluiLojasRoteiro.open('get', strEnvio);
		ExcluiLojasRoteiro.onreadystatechange = function RespostaPesquisa()
											{
												if(ExcluiLojasRoteiro.readyState == 4)
												{
													document.getElementById('conteinerDia'+diaDesejado).innerHTML = "";
													document.getElementById('conteinerDia'+diaDesejado).innerHTML = ExcluiLojasRoteiro.responseText;
													document.getElementById('conteinerDia'+diaDesejado).bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
	
		ExcluiLojasRoteiro.send(null);
		ListaLojasRoteiro(codPromotor,diaDesejado,mesDesejado,anoDesejado,'conteinerDia'+diaDesejado);
	}

}
function TotalizaRoteiros(codCliente, mesAtual)
{
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("quadroPessoas").bgColor = "#DBEDFF";
		document.getElementById("quadroPessoas").align = "left";
		document.getElementById("quadroPessoas").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=TotalizaRoteiros";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&tms=" + new Date().getTime();
		var TotalizaRoteirosCliente = new CriaConexaoAjax();
		TotalizaRoteirosCliente.open('get', strEnvio);
		TotalizaRoteirosCliente.onreadystatechange = function RespostaPesquisa()
											{
												if(TotalizaRoteirosCliente.readyState == 4)
												{
													document.getElementById("quadroPessoas").innerHTML = "";
													document.getElementById("quadroPessoas").innerHTML = TotalizaRoteirosCliente.responseText;
													//document.getElementById("quadroPessoas").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}

		TotalizaRoteirosCliente.send(null);
	}
}
function TotalizaRede(codCliente, mesAtual)
{
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("promoRede").bgColor = "#DBEDFF";
		document.getElementById("promoRede").align = "center";
		document.getElementById("promoRede").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=TotalizaRede";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&tms=" + new Date().getTime();
		var TotalizaRoteirosCliente = new CriaConexaoAjax();
		TotalizaRoteirosCliente.open('get', strEnvio);
		TotalizaRoteirosCliente.onreadystatechange = function RespostaPesquisa()
											{
												if(TotalizaRoteirosCliente.readyState == 4)
												{
													document.getElementById("promoRede").innerHTML = "";
													document.getElementById("promoRede").innerHTML = TotalizaRoteirosCliente.responseText;
													//document.getElementById("promoRede").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}

		TotalizaRoteirosCliente.send(null);
	}
}
function GeraTxtMapao(codCliente, mesAtual)
{
	if(codCliente != "")
	{
		//document.body.style.cursor = 'wait';
		//document.getElementById("mapao").bgColor = "#DBEDFF";
		//document.getElementById("mapao").align = "center";
		//document.getElementById("mapao").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=GeraTxtMapao";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&tms=" + new Date().getTime();
		var TotalizaRoteirosCliente = new CriaConexaoAjax();
		TotalizaRoteirosCliente.open('get', strEnvio);
		TotalizaRoteirosCliente.onreadystatechange = function RespostaPesquisa()
											{
												if(TotalizaRoteirosCliente.readyState == 4)
												{
													//document.getElementById("mapao").innerHTML = "";
													//document.getElementById("mapao").innerHTML = TotalizaRoteirosCliente.responseText;
													//document.getElementById("mapao").bgColor = "";
													//document.body.style.cursor = 'default';
												}
											}

		TotalizaRoteirosCliente.send(null);
	}
}
function BuscaObservacao(codCliente, mesAtual)
{
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("observacao").bgColor = "#DBEDFF";
		document.getElementById("observacao").align = "center";
		document.getElementById("observacao").innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando2.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=BuscaObservacao";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&tms=" + new Date().getTime();
		var TotalizaRoteirosCliente = new CriaConexaoAjax();
		TotalizaRoteirosCliente.open('get', strEnvio);
		TotalizaRoteirosCliente.onreadystatechange = function RespostaPesquisa()
											{
												if(TotalizaRoteirosCliente.readyState == 4)
												{
													document.getElementById("observacao").innerHTML = "";
													document.getElementById("observacao").innerHTML = TotalizaRoteirosCliente.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}

		TotalizaRoteirosCliente.send(null);
	}
}
function AtualizaRelatorioRoteiros(mesEscolhido,codCliente){
    TotalizaRoteiros(codCliente,mesEscolhido);
    TotalizaRede(codCliente,mesEscolhido);
    GeraTxtMapao(codCliente,mesEscolhido);
    BuscaObservacao(codCliente,mesEscolhido);
}
function AtualizaRelatorioEvolucaoVendas(mesAtual,codCliente,codRede){
    //Aba 1 Evolução de Vendas
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("observacao").bgColor = "#DBEDFF";
		//document.getElementById("observacao").align = "center";
		document.getElementById("conteudoaba1rede"+codRede).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=EvolucaoVendas";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&tms=" + new Date().getTime();
		var EvolucaoVendas = new CriaConexaoAjax();
		EvolucaoVendas.open('get', strEnvio);
		EvolucaoVendas.onreadystatechange = function RespostaPesquisa()
											{
												if(EvolucaoVendas.readyState == 4)
												{
													document.getElementById("conteudoaba1rede"+codRede).innerHTML = "";
													document.getElementById("conteudoaba1rede"+codRede).innerHTML = EvolucaoVendas.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}

		EvolucaoVendas.send(null);
	}
	//Aba 2 Filtros de Categorias
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("observacao").bgColor = "#DBEDFF";
		//document.getElementById("observacao").align = "center";
		document.getElementById("conteudoaba2rede"+codRede).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=EvolucaoVendasPesquisa";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&tms=" + new Date().getTime();
		var EvolucaoVendasAnual = new CriaConexaoAjax();
		EvolucaoVendasAnual.open('get', strEnvio);
		EvolucaoVendasAnual.onreadystatechange = function RespostaPesquisa()
											{
												if(EvolucaoVendasAnual.readyState == 4)
												{
													document.getElementById("conteudoaba2rede"+codRede).innerHTML = "";
													document.getElementById("conteudoaba2rede"+codRede).innerHTML = EvolucaoVendasAnual.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
		EvolucaoVendasAnual.send(null);
	}
	//Aba 3 Dados Gerais
	/*if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById("conteudoaba3rede"+codRede).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=PesquisaCompletaEvolucaoVendasListagem";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&tms=" + new Date().getTime();
		var EvolucaoVendasAnual1 = new CriaConexaoAjax();
		EvolucaoVendasAnual1.open('get', strEnvio);
		EvolucaoVendasAnual1.onreadystatechange = function RespostaPesquisa()
											{
												if(EvolucaoVendasAnual1.readyState == 4)
												{
													document.getElementById("conteudoaba3rede"+codRede).innerHTML = "";
													document.getElementById("conteudoaba3rede"+codRede).innerHTML = EvolucaoVendasAnual1.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
		EvolucaoVendasAnual1.send(null);
	}*/
}
function AtualizaRelatorioTabulacaoFrentes(mesAtual,codCliente,codRede){
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("observacao").bgColor = "#DBEDFF";
		//document.getElementById("observacao").align = "center";
		document.getElementById("conteudoaba1rede"+codRede).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=TabulacaoFrentes";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&tms=" + new Date().getTime();
		var EvolucaoVendas = new CriaConexaoAjax();
		EvolucaoVendas.open('get', strEnvio);
		EvolucaoVendas.onreadystatechange = function RespostaPesquisa()
											{
												if(EvolucaoVendas.readyState == 4)
												{
													document.getElementById("conteudoaba1rede"+codRede).innerHTML = "";
													document.getElementById("conteudoaba1rede"+codRede).innerHTML = EvolucaoVendas.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}

		EvolucaoVendas.send(null);
	}
}
function AtualizaRelatorioRupturaProdutos(mesAtual,codCliente,codRede){
    //Aba 1 Evolução de Vendas
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("observacao").bgColor = "#DBEDFF";
		//document.getElementById("observacao").align = "center";
		document.getElementById("conteudoaba1rede"+codRede).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=RupturaProdutos";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&tms=" + new Date().getTime();
		var RupturaProdutos = new CriaConexaoAjax();
		RupturaProdutos.open('get', strEnvio);
		RupturaProdutos.onreadystatechange = function RespostaPesquisa()
											{
												if(RupturaProdutos.readyState == 4)
												{
													document.getElementById("conteudoaba1rede"+codRede).innerHTML = "";
													document.getElementById("conteudoaba1rede"+codRede).innerHTML = RupturaProdutos.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}

		RupturaProdutos.send(null);
	}
/*	//Aba 2 Filtros de Categorias
	if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		//document.getElementById("observacao").bgColor = "#DBEDFF";
		//document.getElementById("observacao").align = "center";
		document.getElementById("conteudoaba2rede"+codRede).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=EvolucaoVendasPesquisa";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&tms=" + new Date().getTime();
		var EvolucaoVendasAnual = new CriaConexaoAjax();
		EvolucaoVendasAnual.open('get', strEnvio);
		EvolucaoVendasAnual.onreadystatechange = function RespostaPesquisa()
											{
												if(EvolucaoVendasAnual.readyState == 4)
												{
													document.getElementById("conteudoaba2rede"+codRede).innerHTML = "";
													document.getElementById("conteudoaba2rede"+codRede).innerHTML = EvolucaoVendasAnual.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
		EvolucaoVendasAnual.send(null);
	}
	//Aba 3 Dados Gerais
	/*if(codCliente != "")
	{
		document.body.style.cursor = 'wait';
		document.getElementById("conteudoaba3rede"+codRede).innerHTML = "<br /><br /><br /><br /><br /><img src='imagens/carregando.gif'>";
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=PesquisaCompletaEvolucaoVendasListagem";
		strEnvio += "&codCliente=" + codCliente;
		strEnvio += "&mesAtual=" + mesAtual;
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&tms=" + new Date().getTime();
		var EvolucaoVendasAnual1 = new CriaConexaoAjax();
		EvolucaoVendasAnual1.open('get', strEnvio);
		EvolucaoVendasAnual1.onreadystatechange = function RespostaPesquisa()
											{
												if(EvolucaoVendasAnual1.readyState == 4)
												{
													document.getElementById("conteudoaba3rede"+codRede).innerHTML = "";
													document.getElementById("conteudoaba3rede"+codRede).innerHTML = EvolucaoVendasAnual1.responseText;
													//document.getElementById("mapao").bgColor = "";
													document.body.style.cursor = 'default';
												}
											}
		EvolucaoVendasAnual1.send(null);
	}*/
}
function AtivaBotao(nomeElemento,divDados,limite){
    e = document.getElementById(nomeElemento);
    d = document.getElementById(divDados);
    //ativa dados da rede
    for(i = 1; i < limite+1; i++){
		if("dadosRede"+i != divDados){
			if(document.getElementById("dadosRede"+i)){
			document.getElementById("dadosRede"+i).style.display = "none";
			}
		}
		else{
			d.style.display = "block";
		}
		if("rede"+i != nomeElemento){
			if(document.getElementById("rede"+i)){
				f = document.getElementById("rede"+i);
				f.className = "botaoNormal";
				f.setAttribute("onmouseover", "TrocarClasse('rede"+ i +"','botaoNormal','botaoOver')");
				f.setAttribute("onmouseout", "TrocarClasse('rede"+ i +"','botaoNormal','botaoOver')");
			}
		}
		else{
			e.removeAttribute("onmouseover");
			e.removeAttribute("onmouseout");
			e.className = 'botaoAtivo';
		}
    }   
}
function AtivaAba(nomeElemento,divDados,limite,codRede){
    d = document.getElementById(divDados);
    for(i = 1;i < limite + 1; i++){
	for(j = 1;j < 4; j++){
	    if(nomeElemento != "aba"+j+"rede"+codRede){
		if(document.getElementById("aba"+j+"rede"+codRede)){
		    f = document.getElementById("aba"+j+"rede"+codRede);
		    f.className = "abasNormal";
		    f.setAttribute("onmouseover", "TrocarClasse('aba"+ j +"rede"+ codRede +"','abasNormal','abasOver')");
		    f.setAttribute("onmouseout", "TrocarClasse('aba"+ j +"rede"+ codRede +"','abasNormal','abasOver')");
		}
	    }
	    else{
		    e = document.getElementById(nomeElemento);
		    e.removeAttribute("onmouseover");
		    e.removeAttribute("onmouseout");
		    e.className = "abasAtivo";

	    }
	}
	for(j = 1;j < 4; j++){
	    if(divDados != "conteudoaba"+j+"rede"+codRede){
		if(document.getElementById("conteudoaba"+j+"rede"+codRede)){
		    f = document.getElementById("conteudoaba"+j+"rede"+codRede);
		    f.style.display = "none";
		    //f.setAttribute("onmouseover", "TrocarClasse('aba"+ j +"rede"+ codRede +"','abasNormal','abasOver')");
		    //f.setAttribute("onmouseout", "TrocarClasse('aba"+ j +"rede"+ codRede +"','abasNormal','abasOver')");
		}
	    }
	    else{
		    e = document.getElementById(divDados);
		    //e.removeAttribute("onmouseover");
		    //e.removeAttribute("onmouseout");
		    e.style.display = "block";

	    }
	}
    }
}
function PesquisaCompletaEvolucaoVendasLojas(codCliente,codRede,numControle)
{
	document.body.style.cursor = 'wait';
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).bgColor = "#DBEDFF";
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).align = "center";
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = "<img src='imagens/carregando.gif'>";
	var dataInicial = document.getElementById("dataInicial"+numControle).value;
	var dataFinal = document.getElementById("dataFinal"+numControle).value;
	var loja = document.getElementById("lojas").value;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=PesquisaCompletaEvolucaoVendasLojas";
	strEnvio += "&codCliente=" + codCliente;
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&dataInicial=" + dataInicial;
	strEnvio += "&dataFinal=" + dataFinal;
	strEnvio += "&loja=" + loja;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaPesquisaCompletaEvolucaoVendas = new CriaConexaoAjax();
	RecuperaPesquisaCompletaEvolucaoVendas.open('get', strEnvio);
	RecuperaPesquisaCompletaEvolucaoVendas.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaPesquisaCompletaEvolucaoVendas.readyState == 4)
											{
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = "";
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = RecuperaPesquisaCompletaEvolucaoVendas.responseText;
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaPesquisaCompletaEvolucaoVendas.send(null);
}
function PesquisaCompletaEvolucaoVendasCategorias(codCliente,codRede,numControle)
{
	document.body.style.cursor = 'wait';
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).bgColor = "#DBEDFF";
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).align = "center";
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = "<img src='imagens/carregando.gif'>";
	var dataInicial = document.getElementById("dataInicial"+numControle).value;
	var dataFinal = document.getElementById("dataFinal"+numControle).value;
	var categoria = document.getElementById("categorias").value;	
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=PesquisaCompletaEvolucaoVendasCategorias";
	strEnvio += "&codCliente=" + codCliente;
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&dataInicial=" + dataInicial;
	strEnvio += "&dataFinal=" + dataFinal;
	strEnvio += "&categoria=" + categoria;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaPesquisaCompletaEvolucaoVendas = new CriaConexaoAjax();
	RecuperaPesquisaCompletaEvolucaoVendas.open('get', strEnvio);
	RecuperaPesquisaCompletaEvolucaoVendas.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaPesquisaCompletaEvolucaoVendas.readyState == 4)
											{
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = "";
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = RecuperaPesquisaCompletaEvolucaoVendas.responseText;
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaPesquisaCompletaEvolucaoVendas.send(null);
}
function PesquisaCompletaEvolucaoVendasProdutos(codCliente,codRede,numControle)
{
	document.body.style.cursor = 'wait';
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).bgColor = "#DBEDFF";
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).align = "center";
	document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = "<img src='imagens/carregando.gif'>";
	var dataInicial = document.getElementById("dataInicial"+numControle).value;
	var dataFinal = document.getElementById("dataFinal"+numControle).value;
	var produto = document.getElementById("produtos").value;	
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=PesquisaCompletaEvolucaoVendasProdutos";
	strEnvio += "&codCliente=" + codCliente;
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&dataInicial=" + dataInicial;
	strEnvio += "&dataFinal=" + dataFinal;
	strEnvio += "&produto=" + produto
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaPesquisaCompletaEvolucaoVendas = new CriaConexaoAjax();
	RecuperaPesquisaCompletaEvolucaoVendas.open('get', strEnvio);
	RecuperaPesquisaCompletaEvolucaoVendas.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaPesquisaCompletaEvolucaoVendas.readyState == 4)
											{
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = "";
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).innerHTML = RecuperaPesquisaCompletaEvolucaoVendas.responseText;
												document.getElementById("ResultadoPesquisaEvolucaoVendas"+numControle).bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaPesquisaCompletaEvolucaoVendas.send(null);
}
function ListaCriterio(campo,codCliente,codRede){
	document.body.style.cursor = 'wait';
	document.getElementById("divCriterio").bgColor = "#DBEDFF";
	document.getElementById("divCriterio").align = "center";
	document.getElementById("divCriterio").innerHTML = "<img src='imagens/carregando2.gif'>";
	var dataInicial = document.getElementById("dataInicial").value;
	var dataFinal = document.getElementById("dataFinal").value;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=ListaCriterios";
	strEnvio += "&codCliente=" + codCliente;
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&dataInicial=" + dataInicial;
	strEnvio += "&dataFinal=" + dataFinal;
	strEnvio += "&campo=" + campo
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaListaCriterio = new CriaConexaoAjax();
	RecuperaListaCriterio.open('get', strEnvio);
	RecuperaListaCriterio.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaListaCriterio.readyState == 4)
											{
												document.getElementById("divCriterio").innerHTML = "";
												document.getElementById("divCriterio").innerHTML = RecuperaListaCriterio.responseText;
												document.getElementById("divCriterio").bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaListaCriterio.send(null);	
}
function AdicionaCriterio(){
	document.body.style.cursor = 'wait';
	var criterio = document.getElementById("criterios").value
	var filtro = document.getElementById("filtros").value
	var campo = document.getElementById("campos").value
	var nomeCriterio = document.getElementById("criterios").options[document.getElementById("criterios").selectedIndex].value;
	var nomeFiltro = document.getElementById("filtros").options[document.getElementById("filtros").selectedIndex].value;
	var nomeCampo = document.getElementById("campos").options[document.getElementById("campos").selectedIndex].value;
	instrucao = campo + filtro + "'" + criterio + "'";
	var filtros = nomeCampo + nomeFiltro + nomeCriterio;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=AdicionaCriterio";
	strEnvio += "&instrucao=" + instrucao;
	strEnvio += "&filtros=" + filtros;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaListaCriterio = new CriaConexaoAjax();
	RecuperaListaCriterio.open('get', strEnvio);
	RecuperaListaCriterio.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaListaCriterio.readyState == 4)
											{
												document.getElementById("divCriterios").innerHTML = RecuperaListaCriterio.responseText;
												document.getElementById("divCriterios").bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaListaCriterio.send(null);	
}
function PesquisaTabulacaoFrentes(codCliente,codRede,numControle)
{
	document.body.style.cursor = 'wait';
	document.getElementById("ResultadoTabulacaoFrentes").bgColor = "#DBEDFF";
	document.getElementById("ResultadoTabulacaoFrentes").align = "center";
	document.getElementById("ResultadoTabulacaoFrentes").innerHTML = "<img src='imagens/carregando.gif'>";
	var dataInicial = document.getElementById("dataInicial").value;
	var dataFinal = document.getElementById("dataFinal").value;
	//var categoria = document.getElementById("categorias").value;	
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=ExecutaTabulacaoFrentes";
	strEnvio += "&codCliente=" + codCliente;
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&dataInicial=" + dataInicial;
	strEnvio += "&dataFinal=" + dataFinal;
	//strEnvio += "&categoria=" + categoria;
	strEnvio += "&tms=" + new Date().getTime();
	var RecuperaPesquisaCompletaEvolucaoVendas = new CriaConexaoAjax();
	RecuperaPesquisaCompletaEvolucaoVendas.open('get', strEnvio);
	RecuperaPesquisaCompletaEvolucaoVendas.onreadystatechange = function RespostaRelatorio()
										{
											if(RecuperaPesquisaCompletaEvolucaoVendas.readyState == 4)
											{
												document.getElementById("ResultadoTabulacaoFrentes").innerHTML = "";
												document.getElementById("ResultadoTabulacaoFrentes").innerHTML = RecuperaPesquisaCompletaEvolucaoVendas.responseText;
												document.getElementById("ResultadoTabulacaoFrentes").bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	RecuperaPesquisaCompletaEvolucaoVendas.send(null);
}
function CoordenadaPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
    {
        while(1)
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            {break;}
          obj = obj.offsetParent;
        }
    }
    else
    {
        if(obj.x)
            {curleft += obj.x;}
    }
    return curleft;
}
function CoordenadaPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
    {
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            {break;}
          obj = obj.offsetParent;
        }
    }
    else
        {   if(obj.y)
            {curtop += obj.y;}
        }
    return curtop;
}
function showAjuda(e,element){
	caixa = document.getElementById(element);
	
    if(e.pageX || e.pageY)
    {
        x = e.pageX ;
        y = e.pageY ;
    }
    else
    {
        //x =  (CoordenadaPosX(caixa) + 10 ) - document.documentElement.clientLeft;
        //y =  (CoordenadaPosY(caixa) + 40 ) -  document.documentElement.clientTop;
	x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
	y = e.clientY + (document.documentElement.scrollTop ||  document.body.scrollTop) -  document.documentElement.clientTop;
    }
    caixa.style.left = (x+5)+'px';
    caixa.style.top = (y)+'px';
    caixa.style.position = 'absolute';
    caixa.style.visibility = 'visible';
}

function hideAjuda(element){
caixa = document.getElementById(element);
caixa.style.visibility = "hidden";
}
function ListaDadosEscolhidos(campo,campoDestino){
	var dadosEscolhidos = document.getElementsByName(campo);
	var destino = document.getElementById(campoDestino);
	var contador = 0;
	var lista = "";
	for (var a=0; a < dadosEscolhidos.length; a++)
	{
		if (dadosEscolhidos[a].checked)
		{
			if (lista != "")
			{
				lista += ",";
			}
			lista += "'" + dadosEscolhidos[a].value + "'";
			contador++;
		}    
	}
	destino.value = "";
	destino.value = lista;
	//alert(lista);
}
function ComboLojasRedeEstado(codRede,estados,destino){
	var estado = document.getElementById(estados).value
	document.body.style.cursor = 'wait';
	document.getElementById(destino).bgColor = "#DBEDFF";
	document.getElementById(destino).align = "center";
	document.getElementById(destino).innerHTML = "<img src='imagens/carregando2.gif'>";
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=ComboLojasRedeEstado";
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&estado=" + estado;
	strEnvio += "&tms=" + new Date().getTime();
	var ComboLojas = new CriaConexaoAjax();
	ComboLojas.open('get', strEnvio);
	ComboLojas.onreadystatechange = function RespostaRelatorio()
										{
											if(ComboLojas.readyState == 4)
											{
												document.getElementById(destino).innerHTML = "";
												document.getElementById(destino).innerHTML = ComboLojas.responseText;
												document.getElementById(destino).bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	ComboLojas.send(null);
}
function ComboLinhasLojas(codRede,estados,destino){
	var estado = document.getElementById(estados).value
	document.body.style.cursor = 'wait';
	document.getElementById(destino).bgColor = "#DBEDFF";
	document.getElementById(destino).align = "center";
	document.getElementById(destino).innerHTML = "<img src='imagens/carregando2.gif'>";
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=ComboLojasRedeEstado";
	strEnvio += "&codRede=" + codRede;
	strEnvio += "&estado=" + estado;
	strEnvio += "&tms=" + new Date().getTime();
	var ComboLojas = new CriaConexaoAjax();
	ComboLojas.open('get', strEnvio);
	ComboLojas.onreadystatechange = function RespostaRelatorio()
										{
											if(ComboLojas.readyState == 4)
											{
												document.getElementById(destino).innerHTML = "";
												document.getElementById(destino).innerHTML = ComboLojas.responseText;
												document.getElementById(destino).bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	ComboLojas.send(null);
}
function AbreSistemaExterno(link,codUser){
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=RecuperaUserPass";
	strEnvio += "&codUser=" + codUser;
	strEnvio += "&tms=" + new Date().getTime();
	var AbreSistema = new CriaConexaoAjax();
	AbreSistema.open('get', strEnvio);
	AbreSistema.onreadystatechange = function RespostaRelatorio()
										{
											if(AbreSistema.readyState == 4)
											{
												strAcesso = AbreSistema.responseText;
												pUrl = link + strAcesso;
												openModalLiveNoUnique(pUrl, '400', '500', codUser);
											}
										}

	AbreSistema.send(null);
}
function SalvaOrdemCampo(codCampo,valorOrdem){
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=SalvaOrdemCampo";
	strEnvio += "&codCampo=" + codCampo;
	strEnvio += "&valorOrdem=" + valorOrdem;
	strEnvio += "&tms=" + new Date().getTime();
	var SalvaOrdem = new CriaConexaoAjax();
	SalvaOrdem.open('get', strEnvio);
	SalvaOrdem.onreadystatechange = function RespostaRelatorio()
										{
											if(SalvaOrdem.readyState == 4)
											{
												var resposta = Trim(SalvaOrdem.responseText);
												if(resposta == "ok")
												{
													document.body.style.cursor = 'default';		
													alert("Salvo com sucesso!");
												}
											}
										}
	SalvaOrdem.send(null);
}
function AtualizaPrecoLoja(codPorRede,valorCampo){
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=AtualizaPrecoLoja";
	strEnvio += "&codPorRede=" + codPorRede;
	strEnvio += "&valorCampo=" + valorCampo.value;
	strEnvio += "&tms=" + new Date().getTime();
	var SalvaOrdem = new CriaConexaoAjax();
	SalvaOrdem.open('get', strEnvio);
	SalvaOrdem.onreadystatechange = function RespostaRelatorio()
										{
											if(SalvaOrdem.readyState == 4)
											{
												var resposta = Trim(SalvaOrdem.responseText);
												if(resposta == "ok")
												{
													document.body.style.cursor = 'default';		
													alert("Salvo com sucesso!");
												}
											}
										}
	SalvaOrdem.send(null);
}
function AddItenCampo(codCampo){
	valorIten = prompt("Informe o valor da opção.","Digite aqui.");;
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=AddItenCampo";
	strEnvio += "&codCampo=" + codCampo;
	strEnvio += "&valorIten=" + valorIten;
	strEnvio += "&tms=" + new Date().getTime();
	var AddItem = new CriaConexaoAjax();
	AddItem.open('get', strEnvio);
	AddItem.onreadystatechange = function RespostaRelatorio()
										{
											if(AddItem.readyState == 4)
											{
												var resposta = Trim(AddItem.responseText);
												if(resposta == "ok")
												{
													document.body.style.cursor = 'default';		
													alert("Adicionado com sucesso!");
												}
											}
										}
	AddItem.send(null);
}
function ComboListaCategorias(codLinha,destino,origem){
	document.body.style.cursor = 'wait';
	document.getElementById(destino).bgColor = "#DBEDFF";
	document.getElementById(destino).align = "center";
	document.getElementById(destino).innerHTML = "<img src='imagens/carregando2.gif'>";
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=ComboListaCategorias";
	strEnvio += "&codLinha=" + codLinha;
	strEnvio += "&origem=" + origem;
	strEnvio += "&tms=" + new Date().getTime();
	var ComboListaCategorias = new CriaConexaoAjax();
	ComboListaCategorias.open('get', strEnvio);
	ComboListaCategorias.onreadystatechange = function RespostaRelatorio()
										{
											if(ComboListaCategorias.readyState == 4)
											{
												document.getElementById(destino).innerHTML = "";
												document.getElementById(destino).innerHTML = ComboListaCategorias.responseText;
												document.getElementById(destino).bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	ComboListaCategorias.send(null);
}
function ListaPerfilCampos(codLinha,codCategoria,destino,origem){
	document.body.style.cursor = 'wait';
	document.getElementById(destino).bgColor = "#DBEDFF";
	document.getElementById(destino).align = "center";
	document.getElementById(destino).innerHTML = "<img src='imagens/carregando2.gif'>";
	strEnvio  = "componentes/ajax.asp";
	strEnvio += "?parametro=ListaPerfilCampos";
	strEnvio += "&codLinha=" + codLinha;
	strEnvio += "&codCategoria=" + codCategoria;
	strEnvio += "&origem=" + origem;
	strEnvio += "&tms=" + new Date().getTime();
	var ListaPerfilCampos = new CriaConexaoAjax();
	ListaPerfilCampos.open('get', strEnvio);
	ListaPerfilCampos.onreadystatechange = function RespostaRelatorio()
										{
											if(ListaPerfilCampos.readyState == 4)
											{
												document.getElementById(destino).innerHTML = "";
												document.getElementById(destino).innerHTML = ListaPerfilCampos.responseText;
												document.getElementById(destino).bgColor = "";
												document.body.style.cursor = 'default';
											}
										}

	ListaPerfilCampos.send(null);
}
function ExcluiCampoPerfil(codCampo,nomeCampo)
{
	if(codCampo != "")
	{
		if(confirm("Deseja realmente excluir o campo: "+ nomeCampo))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiCampoPerfil";
			strEnvio += "&codCampo=" + codCampo;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCampo = new CriaConexaoAjax();
			ExcluiCampo.open('get', strEnvio);
			ExcluiCampo.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCampo.readyState == 4)
													{
														var resposta = Trim(ExcluiCampo.responseText);
														if(resposta == "ok")
														{
															document.getElementById("linha"+ codCampo).style.height = "0px";
															document.getElementById("linha"+ codCampo).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Excluído com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCampo.send(null);	
		}
				  
	}
}
function ExcluiOpcaoPerfil(codCampo,nomeCampo)
{
	if(codCampo != "")
	{
		if(confirm("Deseja realmente excluir o campo: "+ nomeCampo))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiOpcaoPerfil";
			strEnvio += "&codCampo=" + codCampo;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCampo = new CriaConexaoAjax();
			ExcluiCampo.open('get', strEnvio);
			ExcluiCampo.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCampo.readyState == 4)
													{
														var resposta = Trim(ExcluiCampo.responseText);
														if(resposta == "ok")
														{
															document.getElementById("op"+ codCampo).style.height = "0px";
															document.getElementById("op"+ codCampo).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Excluído com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCampo.send(null);	
		}
				  
	}
}
function ExcluiShare(codCampo)
{
	if(codCampo != "")
	{
		if(confirm("Deseja realmente excluir o produto"))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=ExcluiShare";
			strEnvio += "&codCampo=" + codCampo;
			strEnvio += "&tms=" + new Date().getTime();
			var ExcluiCampo = new CriaConexaoAjax();
			ExcluiCampo.open('get', strEnvio);
			ExcluiCampo.onreadystatechange = function RespostaRelatorio()
												{
													if(ExcluiCampo.readyState == 4)
													{
														var resposta = Trim(ExcluiCampo.responseText);
														if(resposta == "ok")
														{
															document.getElementById("op"+ codCampo).style.height = "0px";
															document.getElementById("op"+ codCampo).style.visibility = "hidden";
															document.body.style.cursor = 'default';		
															alert("Excluído com sucesso.");
															//window.history.go(0);
														}
													}
												}
		
			ExcluiCampo.send(null);	
		}
				  
	}
}
function CopiaRoteiroProximoMes(diaEscolhido,diaAtual,codPromotor,mesAtual,anoAtual)
{
	if(codPromotor != "")
	{
		if(confirm("Deseja realmente copiar as lojas?"))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=CopiaRoteiroProximoMes";
			strEnvio += "&diaEscolhido=" + diaEscolhido;
			strEnvio += "&diaAtual=" + diaAtual;
			strEnvio += "&codPromotor=" + codPromotor;
			strEnvio += "&mesAtual=" + mesAtual;
			strEnvio += "&anoAtual=" + anoAtual;
			strEnvio += "&tms=" + new Date().getTime();
			var CopiaRoteiro = new CriaConexaoAjax();
			CopiaRoteiro.open('get', strEnvio);
			CopiaRoteiro.onreadystatechange = function RespostaRelatorio()
												{
													if(CopiaRoteiro.readyState == 4)
													{
														var resposta = Trim(CopiaRoteiro.responseText);
														if(resposta == "ok")
														{
															document.getElementById("img"+ diaAtual).src = "imagens/agt_action_success.png";
															document.getElementById("diaEscolhido"+ diaAtual).disabled = "true";
															document.body.style.cursor = 'default';		
															alert("Copiado com sucesso.");
														}
														else
														{
															document.body.style.cursor = 'default';
															alert(resposta);
														}
													}
												}
			CopiaRoteiro.send(null);	
		}
				  
	}
}
function TransporteRoteiro(codPromotor,mesAtual)
{
	if(codPromotor != "")
	{
		if(confirm("Deseja realmente copiar o roteiro para o próximo mês?"))
		{
			document.body.style.cursor = 'wait';
			strEnvio  = "componentes/ajax.asp";
			strEnvio += "?parametro=TransporteRoteiro";
			strEnvio += "&codPromotor=" + codPromotor;
			strEnvio += "&mesAtual=" + mesAtual;
			strEnvio += "&tms=" + new Date().getTime();
			var CopiaRoteiro = new CriaConexaoAjax();
			CopiaRoteiro.open('get', strEnvio);
			CopiaRoteiro.onreadystatechange = function RespostaRelatorio()
												{
													if(CopiaRoteiro.readyState == 4)
													{
														var resposta = Trim(CopiaRoteiro.responseText);
														if(resposta != "0")
														{
															//document.getElementById("img"+ diaAtual).src = "imagens/agt_action_success.png";
															//document.getElementById("diaEscolhido"+ diaAtual).disabled = "true";
															document.body.style.cursor = 'default';		
															alert("Copiado com sucesso.");
														}
														else
														{
															document.body.style.cursor = 'default';
															alert("Não foi possível copiar, só é permitido copiar com base no mês atual.");
														}
													}
												}
			CopiaRoteiro.send(null);	
		}
				  
	}
}
function AtivaRede(codRede)
{	
		statusAtual = document.getElementById('ativovalor'+ codRede).value;
		document.body.style.cursor = 'wait';
		strEnvio  = "componentes/ajax.asp";
		strEnvio += "?parametro=AtivaRede";
		strEnvio += "&codRede=" + codRede;
		strEnvio += "&statusAtual=" + statusAtual;
		strEnvio += "&tms=" + new Date().getTime();
		var AtivaRede = new CriaConexaoAjax();
		AtivaRede.open('get', strEnvio);
		AtivaRede.onreadystatechange = function RespostaRelatorio()
											{
												if(AtivaRede.readyState == 4)
												{
													var resposta = Trim(AtivaRede.responseText);
													if(resposta == "1")
													{
														document.getElementById("ativo"+ codRede).checked = true;
														document.getElementById('ativovalor'+ codRede).value = "1";
														alert("Rede Ativada.");
													}
													else
													{
														document.getElementById("ativo"+ codRede).checked = false;
														document.getElementById('ativovalor'+ codRede).value = "0";
														alert("Rede Desativada.");
													}
												}
											}
		document.body.style.cursor = 'default';
		AtivaRede.send(null);	
}
