var ImagesDir="http://gamma.infor.pl/portal/inforlex/drzewko_i/";
var Images= new Array(
"plus.gif","plusbottom.gif",
"minus.gif","minusbottom.gif",
"folder.gif","folderopen.gif",
"line.gif","blank.gif",
"join.gif","joinbottom.gif",
"page.gif"
);
var DrzewoIds2 = new Array();

for(var i=0;i<Images.length;i++){
	var Img = new Image();
	Img.src=ImagesDir+Images[i];
}

/* zmieniam odwolania document.all na document.getElementById
*/
function S(id,automat){
	var el = document.getElementById('s'+id);
	if(!el){
		//alert("brak objektu o identyfitatorze s"+id);
		return;
	}
	if(el.style.display=='inline' && !automat) {
		hideUnit(id);
	} else {
		showUnit(id);
	}
    if(typeof(popraw)=='function')
        popraw();
	//if(!automat) 
	//	top.MyNavigate("top.frMain.frFset.frHitlistSerwisy",'blank_serwisy.htm');
}

function onlyOne(id){
	if(id.length!=2) return;
	for(var i in top.DrzewoIds2){
		if(i.length>2 && top.DrzewoIds2[i]==0) continue;
		if(i!=id) hideUnit(i);
	}
}

function showUnit(id){
	var el = document.getElementById('s'+id);
	el.style.display='inline';
	el = document.getElementById('d'+id);
	el.src=ImagesDir+'folderopen.gif';
	el = document.getElementById('p'+id);
	if(el) el.src=ImagesDir+'minus.gif';
	el = document.getElementById('pb'+id);
	if(el) el.src=ImagesDir+'minusbottom.gif';
	// if(top.DrzewoIds2[id]) 
		top.DrzewoIds2[id]=1;	// na potrzeby onlyOne()
	onlyOne(id);
}

function hideUnit(id){
	var el = document.getElementById('s'+id);
	el.style.display='none';
	el = document.getElementById('d'+id);
	el.src=ImagesDir+'folder.gif';
	el = document.getElementById('p'+id);
	if(el) el.src=ImagesDir+'plus.gif';
	el = document.getElementById('pb'+id);
	if(el) el.src=ImagesDir+'plusbottom.gif';
	// 	
	if(top.DrzewoIds2[id]) top.DrzewoIds2[id]=0;	// na potrzeby onlyOne()
}

// do usuniecia?
function getSerwisTyt(kod){
	var al="getSerwisTyt(kod)\nkod="+kod+"\n";
	var a=new Array();
	var k1 = kod.slice(0,2);	al+="k1='"+k1+"'\n";
	var k2 = kod.slice(2,4);	al+="k2='"+k2+"'\n";
	var k3 = kod.slice(4,6);	al+="k3='"+k3+"'\n";

	if(k1!='') a.push(SerwisTytElem(k1));//al+="tyt1='"+tyt1+"'\n";
	if(k1!='' && k2!='') a.push(SerwisTytElem(k1+k2));//al+="tyt2='"+tyt2+"'\n";
	if(k1!='' && k2!='' && k3!='') a.push(SerwisTytElem(k1+k2+k3));//al+="tyt3='"+tyt3+"'\n";
	//alert(al);
	return a;
}
// do usuniecia?
function SerwisTytElem(kod){
	if(!document.all['ah'+kod]) return '';
	var tyt = document.all['ah'+kod].innerHTML;
	return "<a href=\"javascript:gotoSublevel('"+kod+"')\">"+tyt+"</a>";
}
function gotoSerwis(id){
	var a=getSerwisTyt(id);
	top.hlTyt = a.join(' &raquo; ');
	top.scrollYPosDrzewo=document.body.scrollTop;
	
	if(id.length==2)
		document.all['ah'+id].className='apoz1 aktywny';
	else
		document.all['ah'+id].className='aktywny';
	document.all['ah'+id].blur();
	if(document.all['ah'+top.activeTreeElemId] && id!=top.activeTreeElemId){
		document.all['ah'+top.activeTreeElemId].className='nie';
	}
	top.activeTreeElemId=id;
	if(id.length==4) S(id,1);
	//alert(document.all['ah'+id].innerHTML);
	//	alert(top.scrollYPosDrzewo);
	var serwis=Sconvert(id);
	//top.DrzewoIds[id]=2;
	top.hlFilters=new MyHlFilters(serwis.replace('*',''));
	top.MyNavigate("top.frMain.frFset.frHitlistSerwisy",'serwisy_filtr.htm');
	////showSublevel(serwis);
	//alert ('id='+id+"\ntyt="+tyt+"\nserwis="+serwis);
}

function showAll(){
	for(var i in top.DrzewoIds){
		showUnit(i);
	}
}

function hideAll(){
	for(var i in top.DrzewoIds){
		hideUnit(i);
	}
}

function onLoad(){//	alert(top.activeTreeElemId);
	for(var i in top.DrzewoIds){
		if(top.DrzewoIds[i]==1) S(i,1);
	}
	if(top.activeTreeElemId.length=2) S(top.activeTreeElemId,1);

	if(top.activeTreeElemId.length>2 && document.all['ah'+top.activeTreeElemId]){
		document.all['ah'+top.activeTreeElemId].className='aktywny';
		if(top.szNaviTemp.slice(0,6) !='cdweb:') top.frMain.frFset.frDocBottom.location.href='serwisy_filtr.htm';
	}


	//if(top.DrzewoFrCols != ''  && parent.document.getElementById('hf')) parent.document.getElementById('hf').cols=top.DrzewoFrCols;
	//alert(top.scrollYPosDrzewo);
	setTimeout(scrollDrzewo,10);
}

function onUnLoad(){
	var DrzewoFr=null;
	if(DrzewoFr=parent.document.getElementById('hf')){
		if(DrzewoFr.cols)	top.DrzewoFrCols=DrzewoFr.cols;
	}
}
function scrollDrzewo(){
	window.scrollTo(0,top.scrollYPosDrzewo);
}

function dgo(kod,p1,p2,p3,p4,p5,p6) {
	podstaw(kod,p1,p2,p3,p4,p5,p6);
	przestaw_zaznaczony(kod);
	if (kod.length<10) {
		S(kod);
	}
}