function loadXMLDoc(url) {
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange=AjaxDone;
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
	req.onreadystatechange=AjaxDone;
	req.open("GET", url, true);
  req.send();
        }
    }
}


function AjaxDone() 
{
if (req.readyState == 4 && req.status == 200) 
	{
	response = req.responseXML.documentElement;
	method = response.getElementsByTagName('method')[0].firstChild.data;	// Имя ф-ии
	result = response.getElementsByTagName('result')[0].firstChild.data;		// id корня ветки
	sg= response.getElementsByTagName('sg')[0].childNodes[0].data;			//  Возвращаемая ветка
if(response.getElementsByTagName('sg')[0].childNodes[0].nextSibling)
{
	for(i=0; i<response.getElementsByTagName('sg')[0].childNodes.length; i=i+1)
	{
	sg=sg+response.getElementsByTagName('sg')[0].childNodes[i].nodeValue;
	}
}
	eval(method + "(\'\', result, sg)");
	}
}


function invis(id)
	{
	var tx=$(id);
	if (tx.style.display=='none'){tx.style.display=''}else{tx.style.display='none'}
	}


// Принимает элемент - возвращает его координаты и размеры
function getBounds(element)
{
  var left = element.offsetLeft;
  var top = element.offsetTop;
  for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
  {
    left += parent.offsetLeft;
    top += parent.offsetTop;
  }
return {left:left, top:top, width:element.offsetWidth, height:element.offsetHeight};
}


	function smn(n, dv)
	{
cls("e");
	var chl= $(n + '_T')||document.all(n + '_T');
lf=dv.offsetLeft; tp=dv.offsetTop+25;
	if (chl.style.display == 'none'){chl.style.left=lf+"px" ;chl.style.top=tp+"px";chl.style.display = '';	
	dv.className='mf1';
	}
	else{chl.style.display = 'none'; dv.className='mf';}
	stp();
	}

// Обработка клика по группе уровня 2 и выше
	function smn1(n, dv)
	{
	var parn=dv.parentNode;
	var chl= $(n + '_T');
	clk(parn,1,dv);	// гасим все узлы текущего уровня и их потомков
	lf=dv.offsetLeft+dv.offsetWidth+10; tp=dv.offsetTop;
	if (chl.style.display == 'none'){chl.style.left=lf+"px" ;chl.style.top=tp+"px";chl.style.display = '';	
	dv.className='hor1';
	}
	else{chl.style.display = 'none'; dv.className='hor';}
	window.event.cancelBubble=true;
	}

	function showtext1(n, dv)
	{
cls("fld");
	var chl=$(n + '_A')||document.all(n + '_A');
	if (chl.style.display == 'none'){chl.style.display = '';	
	}
	else{chl.style.display = 'none'; dv.className='hor1';}
	window.event.cancelBubble=true;
	}


// Не даем схлопнуться родительскому узлу при нажатии на ссылку
function stp(evt){
//event.stopPropagation)evt.stopPropagation();	
if (event.stopPropagation)evt.stopPropagation();//Для мозилы и оперы
else event.cancelBubble = true;//для IE
}


function clk(nod,level){
if(nod.hasChildNodes()){
	var child=nod.childNodes;
if(nod.className == 'hor1' && level==2 && nod.id){nod.className= 'hor'}
if(nod.id && level>2){nod.style.display = 'none'}
	for(var i=0; i<child.length; i++){clk(child.item(i),(level+1))}
	}
}





// Принимает имя класса - прячет все элементы с таким классом
function cls(cl){
//alert(cl.className);
//stp();
var ar=getElementsByClassName(cl);
for (i = 0; i<ar.length; i++) {
ar[i].style.display = 'none';
}
}




function getElementsByClassName( className, nodeName ) {
       var result = [], tag = nodeName||'*', node, seek, i;
       var rightClass = new RegExp( '(^| )'+ className +'( |$)' );
       seek = document.getElementsByTagName( tag );
       for( i=0; i<seek.length; i++ )
         if( rightClass.test( (node = seek[i]).className ) )
           result.push( seek[i] );
       return result;
     }


win_p=null;
function HOpen(url,h,w,top,left)
{
 if ((win_p)&&(win_p.close)) win_p.close();
 win_p=window.open( url,'_blank','toolbar=no,status=no,menubar=no,scrollbars=1,width='+w+',height='+h+',top='+top+',left='+left);
 win_p.focus();
}

function calc(){
HOpen('/calc.htm',450,420,10,10)}

function fsr(id){
window.location.href="/cgi-bin/p.cgi?a=fsr&lng=ua&x=14,3&s="+id;
}
