function AJAX()
{
	this.Updater=carregarDados;
	
	function carregarDados(caminhoRetorno, idCpt, metodo, indexOption)
	{				
		var xmlhttp = getXmlHttp();
		
		//Abre url
		xmlhttp.open(metodo.toUpperCase(), caminhoRetorno, true);
		
		//Executa quando o navegador obtiver o código
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4)
			{
				//Lê o texto
				texto = xmlhttp.responseText;
				
				//Transforma em array
				arrayInfo = texto.split(',');
				
				if(texto)
				{
					return createOptions(idCpt, arrayInfo, indexOption);
				}
			}
		}
			
		xmlhttp.send(null);
	}
}

// Cria campo de select
function createOptions(nmSelect, arrayValues, indexText)
{	
	var select, objOption;
    
	//Localiza o campo SELECT
	select = document.getElementById(nmSelect);
	
	//Cria um option vazio *********************************************************
    var objOption = document.createElement('option');
    	objOption.text = "Selecione uma opção";
    	objOption.value = 0;
    	
	try 
	{
		select.add(objOption, null); // standards compliant; doesn't work in IE
	}
	catch(ex) 
	{
	    select.add(objOption); // IE only
	}    	
	//******************************************************************************
	
	// for percorrendo todas as posições de um array.
	for(i=0;i<(arrayValues.length);i++)
	{   
		valores = arrayValues[i].split('_');
		
	    var objOption = document.createElement('option');
	    	objOption.text = valores[1];
	    	objOption.value = valores[0];
	    	
		try 
		{
			select.add(objOption, null); // standards compliant; doesn't work in IE
		}
		catch(ex) 
		{
		    select.add(objOption); // IE only
		}
	}  		
    
    return 0;
}

function getXmlHttp()
{
	var xmlhttp;
	
	try
	{
		xmlhttp = new XMLHttpRequest();
	}
	catch(ee)
	{
		try
		{
			xmlhttp = new ActiveXObject("Msxml2.MLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(E)
			{
				xmlhttp = false;
			}
		}
	}
	
	return xmlhttp;
}