function populate_instituicoes(obj, prim, val, sel)
{
	var combo = document.getElementById(obj);
	
	combo.disabled = true;
	
	combo.length = 0;
	combo.length = 1;
	combo.options[0].value = '';
	combo.options[0].text = ' --- Carregando --- ';

	var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
		return;
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var XML = xmlHttp.responseXML.documentElement.getElementsByTagName('instituicao');

			combo.length = 0;
			combo.length = XML.length + 1;
			if(val != null)
				combo.options[0].value = val;
			else
				combo.options[0].value = '';
			combo.options[0].text = prim;
			for(i=0; i<XML.length; i++)
			{
				combo.options[i+1].value = XML[i].getAttribute("id");
				combo.options[i+1].text = XML[i].getAttribute("nome");
				if( (sel != null) && (parseInt(sel) == parseInt(XML[i].getAttribute("id"))) )
					combo.options[i+1].selected = true;
			}
			combo.disabled = false;
		}
	}
	url = '/concursos/_methods/select.php?tipo=instituicoes&sid=' + Math.random();
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function populate_concursos(obj, prim, val, sel, instituicao, status)
{
	var inst = '';
	var stat = '';
	
	if(instituicao != undefined)
		inst = instituicao;
	if(status != undefined)
		stat = status;

	var combo = document.getElementById(obj);

	combo.disabled = true;

	combo.length = 0;
	combo.length = 1;
	combo.options[0].value = '';
	combo.options[0].text = ' --- Carregando --- ';

	var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
		return;
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var XML = xmlHttp.responseXML.documentElement.getElementsByTagName('concurso');

			combo.length = 0;
			combo.length = XML.length + 1;
			if(val != null)
				combo.options[0].value = val;
			else
				combo.options[0].value = '';
			combo.options[0].text = prim;
			for(i=0; i<XML.length; i++)
			{
				combo.options[i+1].value = XML[i].getAttribute("id");
				combo.options[i+1].text = XML[i].getAttribute("nome");
				if( (sel != null) && (parseInt(sel) == parseInt(XML[i].getAttribute("id"))) )
					combo.options[i+1].selected = true;
			}
			combo.disabled = false;
		}
	}
	url = '/concursos/_methods/select.php?tipo=concursos&instituicao=' + inst + '&status=' + stat + '&sid=' + Math.random();
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
