//var PathSitioProcesarRubGruMar = "http://notebook:88/Ciardi/Componentes/selectsRubGruMarProcesar.php";
function cargaSelects(Tipo) {
  var PathSitioProcesar = PathSitioProcesarRubGruMar;

  var selectRubro = document.getElementById('ARTICULOS-BUSCADOR-RUBRO');
  var selectGrupo = document.getElementById('ARTICULOS-BUSCADOR-GRUPO');
  var selectMarca = document.getElementById('ARTICULOS-BUSCADOR-MARCA');
  var opcionRubro = selectRubro.options[selectRubro.selectedIndex].value;
  var opcionGrupo = selectGrupo.options[selectGrupo.selectedIndex].value;
  var opcionMarca = selectMarca.options[selectMarca.selectedIndex].value;

  if (Tipo=='RUBRO') {
    selectGrupo.length = 1;
    selectGrupo.disabled = true;
    opcionGrupo = 'todos';
  }

  if (Tipo=='MARCA') {

    var ajaxRUBRO=crearXMLHttpRequest();
    ajaxRUBRO.open("GET",PathSitioProcesar+"?select=RUBRO&opcionRUBRO="+opcionRubro+"&opcionGRUPO="+opcionGrupo+"&opcionMARCA="+opcionMarca,true);
    ajaxRUBRO.onreadystatechange=function() {
      if (ajaxRUBRO.readyState==1) {
        selectRubro.length = 1;
        selectRubro.options[0].innerHTML = 'Cargando...';
        selectRubro.disabled = true;
      }
      if (ajaxRUBRO.readyState==4) {
        selectRubro.parentNode.innerHTML = ajaxRUBRO.responseText;
        selectRubro = document.getElementById('ARTICULOS-BUSCADOR-RUBRO');
        opcionRubro = selectRubro.options[selectRubro.selectedIndex].value;
      }
    }
    ajaxRUBRO.send(null);

  }

  if (Tipo=='RUBRO' || Tipo=='GRUPO') {

    var ajaxMARCA=crearXMLHttpRequest();
    ajaxMARCA.open("GET",PathSitioProcesar+"?select=MARCA&opcionRUBRO="+opcionRubro+"&opcionGRUPO="+opcionGrupo+"&opcionMARCA="+opcionMarca,true);
    ajaxMARCA.onreadystatechange=function() {
      if (ajaxMARCA.readyState==1) {
        selectMarca.length = 1;
        selectMarca.options[0].innerHTML = 'Cargando...';
        selectMarca.disabled = true;
      }
      if (ajaxMARCA.readyState==4) {
        selectMarca.parentNode.innerHTML = ajaxMARCA.responseText;
        selectMarca = document.getElementById('ARTICULOS-BUSCADOR-MARCA');
        opcionMarca = selectMarca.options[selectMarca.selectedIndex].value;
      }
    }
    ajaxMARCA.send(null);

  }

  if (Tipo=='RUBRO' || Tipo=='MARCA') {

    if (opcionRubro!='todos') {
      var ajaxGRUPO=crearXMLHttpRequest();
      ajaxGRUPO.open("GET",PathSitioProcesar+"?select=GRUPO&opcionRUBRO="+opcionRubro+"&opcionGRUPO="+opcionGrupo+"&opcionMARCA="+opcionMarca,true);
      ajaxGRUPO.onreadystatechange=function() {
        if (ajaxGRUPO.readyState==1) {
          selectGrupo.length = 1;
          selectGrupo.options[0].innerHTML = 'Cargando...';
          selectGrupo.disabled = true;
        }
        if (ajaxGRUPO.readyState==4) {
          selectGrupo.parentNode.innerHTML = ajaxGRUPO.responseText;
          selectGrupo = document.getElementById('ARTICULOS-BUSCADOR-GRUPO');
          opcionGrupo = selectGrupo.options[selectGrupo.selectedIndex].value;
        }
      }
      ajaxGRUPO.send(null);
    }

  }

}
