var req;
var xml_div_id;

function xml_fn(url, f) {
if (((req!=null)&&(req!=undefined))&&(req.readyState!=4)) { setTimeout("xml_fn('"+url+"', '"+f+"')", 500); }
else
{
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = eval(f);
        req.open("GET", url, true);
		req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        req.send(null);
 
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = eval(f);
            req.open("POST", url, true);
			req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
            req.send();
        }
    }
}
}

function xml_div(url, div_id)
{
	xml_div_id=div_id;
    xml_fn(url, 'paste_xml_to_div');
	document.all[xml_div_id].innerHTML="<img src='admin/images/load.gif' border=0 width=12 height=12>";
}

function paste_xml_to_div()
{
	if (req.readyState==4)
	{
		document.all[xml_div_id].innerHTML=req.responseText;
	}
}

function xml_options(t, p, w, select_id)
{
	if ((t)&&(p)&&(w))
	{
		var sel = document.getElementById(select_id);
		sel.options.length = 0;
		sel.options[sel.options.length]=
		new Option('Загрузка', '', false, false);
		xml_fn('ajax_select.php?t='+escape(t)+'&p='+escape(p)+'&w='+escape(w)+'&select_id='+select_id, 'select_fill');
	}
}

function del_options(select_id)
{
	var sel = document.getElementById(select_id);
	sel.options.length = 0;
}

function select_fill ()
{
	if (req.readyState==4)
	{
		data1=req.responseText;
		data1_arr=data1.split('|||');
		select_fill_id=data1_arr[0];
		data=data1_arr[1];
		var sel = document.getElementById(select_fill_id);
		sel.options.length = 0;
		if(data.length == 0) return;
		var arr = data.split('--enter--');
		sel.options[sel.options.length]=
		new Option('', '', false, false);
		for(var i in arr)
		{
			val = arr[i].split('+++');
			if ((val[1]!=undefined)&&(val[0]!=undefined))
			{
				sel.options[sel.options.length]=
				new Option(val[1], val[0], false, false);
			}
		}
	}
}