   	var req;
    var todo="";

    // etot parser texta vzjat s apple.com
    // retrieve text of an XML document element, including
    // elements using namespaces
    function getElementTextNS(prefix, local, parentElem, index)
    {
        var result = "";
        if (prefix && isIE)
        {
            // IE/Windows way of handling namespaces
            result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
        }
        else
        {
            // the namespace versions of this method
            // (getElementsByTagNameNS()) operate
            // differently in Safari and Mozilla, but both
            // return value with just local name, provided
            // there aren\'t conflicts with non-namespace element
            // names
            result = parentElem.getElementsByTagName(local)[index];
        }
        if (result)
        {
            // get text, accounting for possible
            // whitespace (carriage return) text nodes
            if (result.childNodes.length > 1)
            {
                return result.childNodes[1].nodeValue;
            }
            else
            {
                return result.firstChild.nodeValue;
            }
        } else {
            return "n/a";
        }
    }

    function loadXMLDoc(url) {
        // branch for native XMLHttpRequest object
        if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send(null);
        // branch for IE/Windows ActiveX version
        } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            if (req) {
                req.onreadystatechange = processReqChange;
                req.open("GET", url, true);
                req.send();
            }
        }
    }

    function processReqChange()
    {
        // only if req shows "complete"
        // alert(todo);
        if (req.readyState == 4) {
            // only if "OK"
            if (req.status == 200) {
            	/*
            		swithcer dopolniteljnih funkcij kotorie vipolnjatsja posle podgruzki xml
            	*/
                if (todo=="fill_b")
                {
                	clearList("sel_b");
                    Sel_bOptionsAdd();
                }
                else
                    alert("noaction");
            } else {
                alert("There was a problem retrieving\
                   the XML data:\n" + req.statusText);
            }
        }
    }

    // load xml file
    function loadXMDoc(url, response)
    {

        if (response != "")
        {

        }
        else
            loadXMLDoc(url);
    }

/* nizhe idet to, chto nado podgonjatj pod sebja  */
	// "interface" function
	function fillSel_b(oid)
	{
		loadXMLDoc('select_xml.php?oid='+oid);
	}

	// ochistka starih znachenij iz <select>
    function clearList(lid)
    {
        var select = document.getElementById(lid);
        while (select.length > 0)
            select.remove(0);
    }

    // zapolnenie lista
    function Sel_bOptionsAdd()
    {
        var select = document.getElementById("sel_b");
        var items = req.responseXML.getElementsByTagName("item");

        for (var i = 0; i < items.length; i++)
        {
        	var titem_val = getElementTextNS("", "value", items[i], 0);
        	select.options[i] = new Option(getElementTextNS("", "caption", items[i], 0), titem_val, false, false);
        }
    }




/*
    function countArrElements(arr)
    {
        var c=0;
        for (var key in arr)
            c++;
        return c;
    }
*/