function populate_areas(obj, prim, val, sel)
{
	var combo = document.getElementById(obj);
	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('area');

			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;
			}
		}
	}
	url = '/_methods/select.asp?tipo=areas2&sid=' + Math.random();
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function populate_cursos(obj, prim, val, sel, area)
{
	var ar = '';
	
	if(area != undefined)
		ar = area;

	var combo = document.getElementById(obj);
	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('curso');

			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;
			}
		}
	}
	url = '/_methods/select.asp?tipo=cursos&area=' + ar + '&sid=' + Math.random();
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
