/* INICIO DOS SCRIPTS RESPONSÁVEIS PELO OUTSELECT */
var p;
var externalFilho;
var browser = false;
try {
    p = new XMLHttpRequest();
} catch (e) {
	browser = true;
	try {
		p = new ActiveXObject("Msxml2.XMLHttp");
	} catch (e) {
	}
}

function HandleStateChange() {
  if (p.readyState == 4) {
    var str, xmlDoc, root;
	var d = p.responseXML;
	xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
	xmlDoc.async = false;
	xmlDoc.resolveExternals = false;
	var text = p.responseText;
	idInner = document.getElementById("id_"+ externalFilho);
    idInner.innerHTML = text;

	campo_filho = document.getElementById(externalFilho);
    campo_filho.disabled = false;
	campo_filho.focus();
	document.body.style.cursor = "default" 
  }
 }

function listNext(pai, marca, app)
{
  var cod_pai, req, cod_marca;
  var xmlopts;
  var filho = app.substring(app.lastIndexOf("=")+1);
  
  campo_filho = document.getElementById(filho);
  campo_filho.selectedIndex = 0;
  campo_filho.disabled = true

  document.body.style.cursor = "wait" 

  campo_pai = document.formDefault[pai];
  if (campo_pai.type == "select-one")
  {
	cod_pai = campo_pai.options[campo_pai.selectedIndex].value;
  } else {
    cod_pai = campo_pai.value;
  }
  
  cod_marca = document.formDefault[marca].value;
  req = app  +"&CODIGO=" + cod_pai + "&CODMARCA=" + cod_marca + "&CAMPOMARCA=" + marca;
  externalFilho = filho;

  if (browser == true) {   
	p.open("GET", req, true);
	p.send();
	p.onreadystatechange = HandleStateChange;
  }
  else {
    p.open("GET", req + "&isGecko=true", false);
	p.send(null);

    if (p.responseXML) {
		var d = p.responseXML;
		select = document.getElementById(externalFilho);
		var len = select.length;
		while(select.length != 0) {
			select.options[0] = null;
		}
		nl = d.getElementsByTagName("option");
		for(i = 0; i < nl.length; i++) {
			select.options[i] = new Option(nl.item(i).text, nl.item(i).value);
		}
		select.disabled = false;
		document.body.style.cursor = "default";
	}
  }
} 
/* FIM DOS SCRIPTS RESPONSÁVEIS PELO OUTSELECT */
