function AjaxFunction(categoria_value, subcategoria_id, archivo_carga)
{
    var httpxml;

    try
    {
        // Firefox, Opera 8.0+, Safari
        httpxml = new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            httpxml = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                httpxml = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Su navegador no soporta AJAX.\nEs necesario para cargar los combos.");
                return false;
            }
        }
    }

    function stateck()
    {
        var estados = new Array("No inicializado...", "Cargando...", "Esperando al servidor...", "Interactivo...", "Completo");

        var subcat = document.getElementById(subcategoria_id);

        var optn;

        // Antes de añadir el nuevo contenido, debemos eliminar el anterior.
        for(j=subcat.options.length-1;j>=0;j--)
        {
            subcat.remove(j);
        }

        if (httpxml.readyState == 4)
        {
            if (httpxml.status == 200)
            {
                var myarray = eval(httpxml.responseText);

                for (i=0;i<myarray.length;i++)
                {
                    optn = document.createElement("OPTION");
                    optn.value = myarray[i][0];
                    optn.text = myarray[i][1];
                    subcat.options.add(optn);
                }
            }
            else
            {
                optn = document.createElement("OPTION");
                optn.value = "%";
                optn.text = httpxml.status + ": " + httpxml.statusText;
                subcat.options.add(optn);
            }
        }
        else
        {
            optn = document.createElement("OPTION");
            optn.value = "%";
            optn.text = "Estado: " + estados[httpxml.readyState];
            subcat.options.add(optn);
        }
    }

    var url = archivo_carga;
    url = url + "?cat_id=" + categoria_value;
    url = url + "&sid=" + Math.random();

    httpxml.onreadystatechange = stateck;
    httpxml.open("GET",url,true);
    httpxml.send(null);
}
