	function mensagem(n,VarAux){
		if(n == 0 || n==''){
			return false;
		}
		
		if(VarAux == undefined){
			VarAux = ""; 
		}
		
		var xmlhttp   = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
    		xmlhttp = new XMLHttpRequest();
	        if(xmlhttp.overrideMimeType){
	        	xmlhttp.overrideMimeType('text/xml');
			}
		}else if (window.ActiveXObject){ // IE
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	            } catch (e) {}
    	    }
	    }
	    url = "xml/parametro_sistema.php?IdGrupoParametroSistema=99&IdParametroSistema="+n;

		xmlhttp.open("GET", url,true);
   		xmlhttp.onreadystatechange = function(){ 
   			if(xmlhttp.readyState == 4){ 
   				if(xmlhttp.status == 200){
					if(xmlhttp.responseText != 'false'){
						nameNode = xmlhttp.responseXML.getElementsByTagName("ValorParametroSistema")[0]; 
						nameTextNode = nameNode.childNodes[0];
						var msg = nameTextNode.nodeValue;
						
						if(VarAux!=""){
							msg	=	msg.replace('Valor',VarAux);
						}
					
						alert(msg);
					}
				}
			}
		}
		xmlhttp.send(null);
	}
	function busca_estado_cda(IdPais,IdEstadoTemp,IdCidadeTemp){
		if(IdPais=="") IdPais=0;
		if(IdEstadoTemp==undefined) IdEstadoTemp="";
		if(IdCidadeTemp==undefined) IdCidadeTemp="";
		
		var xmlhttp = false;
		var nameNode, nameTextNode, url;	
		
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
	    	xmlhttp = new XMLHttpRequest();
	        if(xmlhttp.overrideMimeType){
	        	xmlhttp.overrideMimeType('text/xml');
			}
		}else if (window.ActiveXObject){ // IE
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	            } catch (e) {}
	        }
	    }
		url = "xml/estado.php?IdPais="+IdPais;
		xmlhttp.open("GET", url,true);
		xmlhttp.onreadystatechange = function(){ 
		
			// Carregando...
			carregando(true);
			
			if(xmlhttp.readyState == 4){ 
				if(xmlhttp.status == 200){
					if(xmlhttp.responseText == 'false'){
						while(document.formulario.IdEstado.options.length > 0){
							document.formulario.IdEstado.options[0] = null;
						}
						while(document.formulario.IdCidade.options.length > 0){
							document.formulario.IdCidade.options[0] = null;
						}
					}else{
						var IdEstado, NomeEstado;
						while(document.formulario.IdEstado.options.length > 0){
							document.formulario.IdEstado.options[0] = null;
						}
							
						addOption(document.formulario.IdEstado,"","");
						for(var i=0; i<xmlhttp.responseXML.getElementsByTagName("IdEstado").length; i++){
							nameNode = xmlhttp.responseXML.getElementsByTagName("IdEstado")[i]; 
							nameTextNode = nameNode.childNodes[0];
							IdEstado = nameTextNode.nodeValue;
							
							nameNode = xmlhttp.responseXML.getElementsByTagName("NomeEstado")[i]; 
							nameTextNode = nameNode.childNodes[0];
							NomeEstado = nameTextNode.nodeValue;
							
							addOption(document.formulario.IdEstado,NomeEstado,IdEstado);
						}
						if(IdEstadoTemp==""){
							document.formulario.IdEstado.options[0].selected = true;
						}else{
							for(var i=0; i<document.formulario.IdEstado.length; i++){
								if(document.formulario.IdEstado.options[i].value == IdEstadoTemp){
									document.formulario.IdEstado.options[i].selected	=	true;
									i = document.formulario.IdEstado.length;
								}
							}
						}
						if(IdCidadeTemp==""){
							while(document.formulario.IdCidade.options.length > 0){
								document.formulario.IdCidade.options[0] = null;
							}
						}else{
							busca_cidade_cda(IdPais,IdEstadoTemp,IdCidadeTemp)
						}
					}
				}
			} 
			// Fim de Carregando
			carregando(false);
			return true;
		}
		xmlhttp.send(null);
	}
	function busca_cidade_cda(IdPais,IdEstado,IdCidadeTemp){
		if(IdPais=="") IdPais=0;
		if(IdEstado=="" || IdEstado==undefined) IdEstado=0;
		if(IdCidadeTemp==undefined) IdCidadeTemp="";
		
		var xmlhttp = false;
		var nameNode, nameTextNode, url;	
		
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
	    	xmlhttp = new XMLHttpRequest();
	        if(xmlhttp.overrideMimeType){
	        	xmlhttp.overrideMimeType('text/xml');
			}
		}else if (window.ActiveXObject){ // IE
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	            } catch (e) {}
	        }
	    }
		url = "xml/cidade.php?IdPais="+IdPais+"&IdEstado="+IdEstado;
		
		xmlhttp.open("GET", url,true);
		xmlhttp.onreadystatechange = function(){ 
		
			// Carregando...
			carregando(true);
			
			if(xmlhttp.readyState == 4){ 
				if(xmlhttp.status == 200){
					if(xmlhttp.responseText == 'false'){
						while(document.formulario.IdCidade.options.length > 0){
							document.formulario.IdCidade.options[0] = null;
						}
					}else{
						var IdCidade, NomeCidade;
						while(document.formulario.IdCidade.options.length > 0){
							document.formulario.IdCidade.options[0] = null;
						}
							
						addOption(document.formulario.IdCidade,"","");
						
						for(var i=0; i<xmlhttp.responseXML.getElementsByTagName("IdCidade").length; i++){
							nameNode = xmlhttp.responseXML.getElementsByTagName("IdCidade")[i]; 
							nameTextNode = nameNode.childNodes[0];
							IdCidade = nameTextNode.nodeValue;
							
							nameNode = xmlhttp.responseXML.getElementsByTagName("NomeCidade")[i]; 
							nameTextNode = nameNode.childNodes[0];
							NomeCidade = nameTextNode.nodeValue;
							
							addOption(document.formulario.IdCidade,NomeCidade,IdCidade);
						}
						if(IdCidadeTemp == ""){
							document.formulario.IdCidade.options[0].selected = true;
						}else{
							for(var i=0; i<document.formulario.IdCidade.length; i++){
								if(document.formulario.IdCidade.options[i].value == IdCidadeTemp){
									document.formulario.IdCidade.options[i].selected	=	true;
									i = document.formulario.IdCidade.length;
								}
							}
						}
					}
				}
				// Fim de Carregando
				carregando(false);
			} 
			return true;
		}
		xmlhttp.send(null);
	}
	function mensagem_especial(IdGrupoParametroSistema,IdParametroSistema){
		if(IdGrupoParametroSistema == 0 || IdGrupoParametroSistema==''){
			return false;
		}
		if(IdParametroSistema == 0 || IdParametroSistema==''){
			return false;
		}
		
		var xmlhttp   = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
    		xmlhttp = new XMLHttpRequest();
	        if(xmlhttp.overrideMimeType){
	        	xmlhttp.overrideMimeType('text/xml');
			}
		}else if (window.ActiveXObject){ // IE
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	            } catch (e) {}
    	    }
	    }
	    url = "xml/parametro_sistema.php?IdGrupoParametroSistema="+IdGrupoParametroSistema+"&IdParametroSistema="+IdParametroSistema;

		xmlhttp.open("GET", url,true);
   		xmlhttp.onreadystatechange = function(){ 
   			if(xmlhttp.readyState == 4){ 
   				if(xmlhttp.status == 200){
					if(xmlhttp.responseText != 'false'){
						nameNode = xmlhttp.responseXML.getElementsByTagName("ValorParametroSistema")[0]; 
						nameTextNode = nameNode.childNodes[0];
						var NomeCampo = nameTextNode.nodeValue;
					
						alert("Atenção!\n"+NomeCampo+" - Campo obrigatorio.");
					}
				}
			}
		}
		xmlhttp.send(null);
	}
	function busca_cep(CEP){
		if(CEP == ''){
			CEP = 0;
		}
		if(atualizar() == true){
			var nameNode, nameTextNode, url;
			
			var xmlhttp   = false;
			if (window.XMLHttpRequest) { // Mozilla, Safari,...
		    	xmlhttp = new XMLHttpRequest();
		        if(xmlhttp.overrideMimeType){
		        	xmlhttp.overrideMimeType('text/xml');
				}
			}else if (window.ActiveXObject){ // IE
				try{
					xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e){
					try{
						xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		            } catch (e) {}
		        }
		    }
		    
		   	url = "xml/cep.php?CEP="+CEP;
			xmlhttp.open("GET", url,true);
			
			xmlhttp.onreadystatechange = function(){ 
				// Carregando...
				carregando(true);
		
				if(xmlhttp.readyState == 4){ 
					if(xmlhttp.status == 200){
						if(xmlhttp.responseText != 'false'){
							
							nameNode = xmlhttp.responseXML.getElementsByTagName("IdPais")[0]; 
							nameTextNode = nameNode.childNodes[0];
							var IdPais = nameTextNode.nodeValue;
							
							nameNode = xmlhttp.responseXML.getElementsByTagName("IdEstado")[0]; 
							nameTextNode = nameNode.childNodes[0];
							var IdEstado = nameTextNode.nodeValue;
					
							nameNode = xmlhttp.responseXML.getElementsByTagName("IdCidade")[0]; 
							nameTextNode = nameNode.childNodes[0];
							var IdCidade = nameTextNode.nodeValue;					
						
							nameNode = xmlhttp.responseXML.getElementsByTagName("Endereco")[0]; 
							nameTextNode = nameNode.childNodes[0];
							var Endereco = nameTextNode.nodeValue;
						
							nameNode = xmlhttp.responseXML.getElementsByTagName("Bairro")[0]; 
							nameTextNode = nameNode.childNodes[0];
							var Bairro = nameTextNode.nodeValue;
							
							document.formulario.Endereco.value 		= Endereco;
							document.formulario.Bairro.value 		= Bairro;
							document.formulario.IdPais.value 		= IdPais;
							
							busca_estado_cda(IdPais,IdEstado,IdCidade);
						}
					}
					// Fim de Carregando
					carregando(false);
				} 
				return true;
			}
			xmlhttp.send(null);
		}
	}
	function atualizar(){
		return confirm("ATENCAO!\n\nDeseja atualizar endereço?","SIM","NAO");
	}
	
