  function creaXMLHttpRequest() {
    try { req = new XMLHttpRequest();
        } catch(err1) {
          try { req = new ActiveXObject('Msxml2.XMLHTTP');
              } catch (err2) {
                try { req = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (err3) { req = false;
				      }
                }
        }
        return req;
  }

  function ajax(url,query,target) {
    var req=creaXMLHttpRequest();
    req.onreadystatechange=function() {
      if(req.readyState==4) {
        if(req.status==200) {
		  document.getElementById(target).innerHTML=req.responseText; //... si la respuesta simplemente debe llenar el 'target' espeficidado
        }
      }
    }
    myRand=parseInt(Math.random()*99999999);
    req.open("GET",url+'?'+query+'&rand='+myRand,true);
    req.send(null);
  }

  function carga_modelos() {
	valor=document.getElementById("select_marcas").options[document.getElementById("select_marcas").selectedIndex].value;
	if(valor==0) {
	  combo=document.getElementById("select_modelos");
	  combo.length=0;
	  nuevaOpcion=document.createElement("option");
	  nuevaOpcion.value=0;
	  nuevaOpcion.innerHTML="Todos";
      combo.appendChild(nuevaOpcion);
	}
	else ajax("includes/ajax_modelos.php","id="+valor,"fila_modelos");
  }
