// JavaScript Document
			function troca (id, valor, titulo) {
				if (valor == titulo || valor == '') {
					document.getElementById(id).value = '';
				}
			}
			
			function volta (id, valor, titulo) {
				if (valor == '') {
					document.getElementById(id).value = titulo;
				}
			}		
			
			
				function retorna 	() 		{
					document.getElementById('campoNews').style.display = '';
					document.getElementById('texto').style.display = '';
					document.getElementById('apa2').style.display = 'none';
				}
				
			function valida 	(form) 	{
				var email  		= document.getElementById('emailnews').value;
				
				if (email == "e-mail" || email == "") {
					document.getElementById('campoNews').style.display = 'none';
					document.getElementById('texto').style.display = 'none';
					document.getElementById('apa2').style.display = '';
					setTimeout("retorna()", 5000);								
				} else {
					document.getElementById(form).submit();
				}

			}

			
			function retorna2 	() 		{
				document.getElementById('formulario').style.display = '';
				document.getElementById('apa1').style.display = 'none';
			}
				
			function valida2 	(form) 	{
				var nome  		= document.getElementById('nome').value;
				var email  		= document.getElementById('emailcontato').value;
				var endereco  		= document.getElementById('endereco').value;
				var bairro  		= document.getElementById('bairro').value;
				var cep  		= document.getElementById('cep').value;
				var telefone  		= document.getElementById('telefone').value;
				var celular  		= document.getElementById('celular').value;
				
				if (email == "e-mail" || nome == "nome" || endereco == "endereço" || bairro == "bairro" || cep == "cep" || telefone == "telefone" || celular == "celular") {
					document.getElementById('formulario').style.display = 'none';
					document.getElementById('apa1').style.display = '';
					setTimeout("retorna2()", 5000);								
				} else {
					document.getElementById(form).submit();
				}

			}

		function trocaVal (local, valor) {
			zerar();
			document.getElementById("tipo").value = valor;
			if (valor ==2) {
				document.getElementById("clientes").className = "linkEsp";				
				document.getElementById("representantes").className = "linkEsp";				
				document.getElementById("assist").className = "linkEspSel";
				document.getElementById("tabela").value = "assitentes";
				ajaxEstados();				
				
				
			} else if (valor ==1)  {
				document.getElementById("assist").className = "linkEsp";				
				document.getElementById("clientes").className = "linkEsp";				
				document.getElementById("representantes").className = "linkEspSel";	
				document.getElementById("tabela").value = "representantes";
				ajaxEstados();				
			} else {
				document.getElementById("assist").className = "linkEsp";				
				document.getElementById("representantes").className = "linkEsp";				
				document.getElementById("clientes").className = "linkEspSel";	
				document.getElementById("tabela").value = "clientes";
				ajaxEstados();
			}
		}


			function alteraIn2 (valor, id, id1) {
				document.getElementById(id).innerHTML = valor;
				document.getElementById(id1).value = valor;
			}			

			function alteraIn3 (valor, id, id1) {
				document.getElementById(id).innerHTML = valor;
				document.getElementById(id1).value = valor;
			}			

			function alteraIn (valor, id, id1, campo) {
				document.getElementById(id1).value = campo;			
				document.getElementById(id).innerHTML = valor;
			}
			
			
			function zerar () {
				document.getElementById('aquiestados').innerHTML 	= '<ul><li class="lii" style="margin-top:8px"><a class="hide" href="#" style="margin-bottom:2px;height:33px" onclick="return false" id="cidadecc" >Escolha a op&ccedil;&atilde;o acima..</a></li></ul>';
				document.getElementById('aquiAjax').innerHTML 	= '<ul><li class="lii" style="margin-top:8px"><a class="hide" href="#" style="margin-bottom:2px;height:33px" onclick="return false" id="cidadecc" >Escolha a op&ccedil;&atilde;o acima.</a></li></ul>';
				document.getElementById('dados').innerHTML 	= 'Selecione o estado e a cidade para carregar a lista de representantes.';
			}
			
			function ajaxEstados () {
				document.getElementById('aquiestados').innerHTML = "Aguarde...";
				var tabela = document.getElementById("tabela").value;
				var pagina = 'includes/inc.estado.php';
				new Ajax.Request(pagina,
				{
					method:'get',  
					parameters: {tab: tabela},
					onSuccess: function(transport){
					document.getElementById('aquiestados').innerHTML = transport.responseText;
				},
				onFailure: function(){ alert('Ocooreu um erro em sua conexão com a internet.') }
				});					
			}

			
			function ajaxChama (valor1, valor2, valor3, valor4) {
					alteraIn2 (valor1, valor2, valor3);
					var tabela = document.getElementById("tabela").value;
					if (tabela == "representantes") {
						
						
						var pagina = 'includes/inc.dados.php';
						var tipo = document.getElementById("tipo").value;						
						document.getElementById('dados').style.display = 'none';
						document.getElementById('carreg').style.display = '';
						new Ajax.Request(pagina,
						{
							method:'get',  
							parameters: {id: valor4, tab:tabela},
							onSuccess: function(transport){
								document.getElementById('dados').innerHTML = transport.responseText;
								document.getElementById('carreg').style.display = 'none';
								document.getElementById('dados').style.display = '';
document.getElementById('aquiAjax').innerHTML =	'';								
								
							},
							onFailure: function(){ alert('Ocooreu um erro em sua conexão com a internet.') }
						});					

						
						
						
					} else {
						
					document.getElementById('aquiAjax').innerHTML =	"Aguarde...";
					var tipo = document.getElementById("tipo").value;
					var pagina = 'includes/inc.cidades.php';
				new Ajax.Request(pagina,
				{
					method:'get',  
					parameters: {id: valor4, tab:tabela},
					onSuccess: function(transport){
					document.getElementById('aquiAjax').innerHTML = transport.responseText;
				},
					onFailure: function(){ alert('Ocooreu um erro em sua conexão com a internet.') }
				});		
					}
			}


					function ajaxmanda2(valor1, valor2, valor3, valor4, valor5) {
						alteraIn2 (valor5, valor2, valor3);
						var tabela = document.getElementById("tabela").value;											
						var pagina = 'includes/inc.dados.php';
						var tipo = document.getElementById("tipo").value;						
						document.getElementById('dados').style.display = 'none';
						document.getElementById('carreg').style.display = '';
						new Ajax.Request(pagina,
						{
							method:'get',  
							parameters: {id: valor4, tab:tabela},
							onSuccess: function(transport){
								document.getElementById('dados').innerHTML = transport.responseText;
								document.getElementById('carreg').style.display = 'none';
								document.getElementById('dados').style.display = '';								
							},
							onFailure: function(){ alert('Ocooreu um erro em sua conexão com a internet.') }
						});					
					}
					
			function ajaxChama3 (valor1, valor2, valor3, valor4, valor5) {
					document.getElementById(valor2).innerHTML = valor1;
					document.getElementById(valor3).value = valor5;
					document.getElementById('aquiAjax').innerHTML =	"Aguarde...";
					var pagina = 'includes/inc.prods.php';
				new Ajax.Request(pagina,
				{
					method:'get',  
					parameters: {id: valor4},
					onSuccess: function(transport){
					document.getElementById('aquiAjax').innerHTML = transport.responseText;
				},
					onFailure: function(){ alert('Ocooreu um erro em sua conexão com a internet.') }
				});					
			}

		function abrePopUp(){  
			window.open('../../../pop.acessorestrito.php',
						'Restrito',
						'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=380'
						);  
		}  
		
		function popindique(id, titulo, urll){  
			window.open('../../../pop.indique.php?id='+id+'&tt='+titulo+'&url='+urll,
						'Indique',
						'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=335,height=500'
						);  
		}  
		

