// version 1.2 O'range 2003 Ilya Muzukin ilya@iep.uran.ru
var ns ;
var ie ;
var n6;
var W;
var op;
function BrowserCheck() {
	if (document.layers) ns=true;
	if (document.all) ie=true;
	op=window.opera;
	if(!ie&&document.getElementById){ns=false;n6=true;};
	if(ns||n6){W=window.innerWidth-16}else{W=document.body.offsetWidth-20;}
}
var level=0;
function TreeView(vname,id,parid,name,link,target,image,image1,funct)
{
this.vname="Trv"+TreeView.dmcnt;TreeView.dmcnt++;
this.oname=vname+"lay";
this.image=image;
this.image1=(image1==""||!image1)? image:image1;
this.name=name;
this.frname="";
this.id=id;
this.ih=20;this.iw=20;
this.x=100;this.y=150;
this.w=150;this.h=300;
this.parentItem=null;
this.parid=parid;
this.link=link;
this.funct=funct;
this.target=target;
this.items=new Array();
this.itemCount=0;
this.Opened=true;
this.bckColor="#ffffff";
this.fntColor="#000000";
this.fntSize=2;this.icdc=null;this.icdo=null;
this.linkColor="#0000ff";
this.vlinkColor="#ff00ff";
this.alinkColor="#00ffff";
this.bckIm="image/bck.gif";
this.opIm="image/op.gif";
this.clIm="image/cl.gif";
this.emp="image/emp.gif";
this.tre="image/tre.gif";this.corn="image/corn.gif";this.cont="image/cont.gif";
this.preCode="";
this.postCode="";
this.pc="";this.b=false;this.i=false;this.u=false;
this.fontFace="default";
this.Update = TWUpdate;
this.Switch = TWSwitch;
this.Add = TWAdd;
this.Draw = TWDraw;
this.Get = TWGet;
this.A = TWA;
this.Build=TWBuild;
this.Write=TWWrite;
this.ind=false;this.ilay=null;
eval(this.vname + "=this");
prl(this.vname+".im1",this.image1);prl(this.vname+".im",this.image);
prl(this.vname+".oop",this.opIm);prl(this.vname+".ocl",this.clIm);prl(this.vname+".oemp",this.emp);
prl(this.vname+".otre",this.tre);prl(this.vname+".ocorn",this.corn);
prl(this.vname+".ocont",this.cont);
}
function TWBuild()
{
this.ind=true;
var css="";
var div="";
var bCol=(ns)?"layer-background-color:" : "background-color:";
css="<STYLE TYPE='text/css'><!--"+"#"+this.oname+"{position:absolute;top:"+this.y+"px;left:"+this.x+"px;z-index:8}--></STYLE>";
div="<DIV ID=\""+this.oname+"\">"+this.preCode+this.Draw()+this.postCode+"</DIV>";
document.getElementById("nw").innerHTML=css;
document.getElementById("nw").innerHTML=div;
show("nw");
if(ns)this.ilay=eval("document."+this.oname);
if(ie)this.ilay=document.all[this.oname];
if(n6)this.ilay=document.getElementById(this.oname);
}
function TWWrite(txt)
{if(ns){
this.ilay.document.open();this.ilay.document.write(txt);this.ilay.document.close();
}
if(n6||ie)this.ilay.innerHTML=txt;
}
function TWGet(id)
{
if(id==this.id) return this;
for(var i=0;i<this.itemCount;i++)
{
It=this.items[i].Get(id);
if(It!=null) return It;
}
return null;
}
function TWA(id,parid,name,link,target,image,image1)
{
if(target=="")target="_self";
It=new TreeView(this.vname,id,parid,name,link,target,image,image1);
this.Add(It);
}
function TWAdd(item)
{
item.Opened=(op)? true:false;
It=this.Get(item.parid);
if(item.parid==this.id)
{
this.items[this.itemCount]=item;item.opIm=this.opIm;item.clIm=this.clIm;
item.parentItem=this;item.vname=this.vname;item.tre=this.tre;item.cont=this.cont;item.corn=this.corn;item.emp=this.emp;
this.itemCount++;item.ind=this.ind;item.fontFace=this.fontFace;item.b=this.b;item.i=this.i;item.u=this.u;
item.bckColor=this.bckColor;item.fntColor=this.fntColor;item.fntSize=this.fntSize;item.ih=this.ih;item.iw=this.iw;
return;
}
if(It!=null) {It.Add(item);return;}
}

function TWDraw(frname,fin)
{if(fin==null)fin=false;
this.frname=frname;
var trt="";var tro="";
var but=(fin)? this.ocorn.src: this.otre.src;
var but1=but;
var balt="'";var balt1="'";
var a1="";
var a2="";
if(this.icdc==null){
var ico= this.im1.src;var ic=this.im.src;
if(this.itemCount>0)
{
but1=this.oop.src;
balt1="-";but=this.ocl.src;balt="+";
};this.pre="";
if(this.parentItem!=null){
this.pre=this.parentItem.pre;
but="<IMG SRC="+but+" height="+this.ih+"  width="+this.iw+"  BORDER='0' alt='"+balt+"'>";
but1="<IMG SRC="+but1+" height="+this.ih+"  width="+this.iw+"  BORDER='0' alt='"+balt1+"'>";
bck="";imstr="";var pl="";imstr1="";
if(!this.ind) pl="top.";
if(this.image!=null){
imstr1="<td height="+this.ih+"><IMG SRC="+ico+" HEIGHT="+this.ih+"  WIDTH="+this.ih+"  BORDER='0'></td>"
imstr="<td height="+this.ih+"><IMG SRC="+ic+" HEIGHT="+this.ih+"  WIDTH="+this.ih+"  BORDER='0'></td>"};
a1="<a href=\"#\" onClick=\"return "+pl+this.vname+".Switch("+this.id+");\" >";
a2="</a>";ref=this.name;if(this.b)ref="<b>"+ref+"</b>";if(this.i)ref="<i>"+ref+"</i>";if(this.u)ref="<u>"+ref+"</u>";
rf=this.link+"' target='"+this.target+"' onClick='return true'";
trt+="<tr height="+this.ih+" ><td> <table border='0' cellspacing='0' cellpadding='0' height="+this.ih+"> "+this.pre+" <td width="+this.iw+" ><a name=\"IT"+this.id+"\"></a>"+
a1+but+a2+"</td>"+
" <td noWrap>"+
imstr+"<td nowrap bgcolor='"+this.bckColor+"'><a href='"+rf+"><font color='"+this.fntColor+"' size='"+this.fntSize+"' face='"+this.fontFace+"' onClick=cf()>"+ref+"</font></td></a></tr></table></td></tr>";
tro+="<tr height="+this.ih+" ><td> <table border='0' cellspacing='0' cellpadding='0' height="+this.ih+"> "+this.pre+" <td width="+this.iw+" ><a name=\"IT"+this.id+"\"></a>"+
a1+but1+a2+"</td>"+
" <td noWrap>"+
imstr1+"<td nowrap bgcolor='"+this.bckColor+"'><a href='"+rf+" onClick=cf()><font color='"+this.fntColor+"' size='"+this.fntSize+"' face='"+this.fontFace+"'>"+ref+"</font></td></a></tr></table></td></tr>";

}
if(this.parentItem==null) {var np="<table border='0' bgcolor='"+this.bckColor+"' cellspacing='0' cellpadding='0' >";trt+=np;tro+=np;}
this.icdc=trt;
this.icdo=tro;
var p2=this.pre;
if(!fin)this.pre=p2+"<td width="+this.iw+" height="+this.ih+"><img src='"+this.ocont.src+"' height="+this.ih+" width="+this.iw+" border=0></td>"; else this.pre=p2+"<td width="+this.iw+" height="+this.ih+"><img src='"+this.oemp.src+"' height="+this.ih+" width="+this.iw+" border=0></td>"; 
if(this.parentItem==null)this.pre="";
};trt=(this.Opened)?this.icdo:this.icdc;
if(this.Opened)
for(var i=0;i<this.itemCount;i++) {
var fn=(i==this.itemCount-1)? true:false;
trt+=this.items[i].Draw(frname,fn);}
if(this.parentItem==null) trt+="</table>";
return trt;
}
function TWUpdate()
{
if(this.parentItem!=null) {this.parentItem.Update();return;}
if(this.ind){
this.Write(this.preCode+this.Draw()+this.postCode);
return;
}
offT=0;offL=0;
 if (document.all) {
       offL = top.frames[this.frname].document.body.scrollLeft;
        offT = top.frames[this.frname].document.body.scrollTop;
    } 
else {
offT =top.frames[this.frname].window.pageYOffset;
offL=top.frames[this.frname].window.pageXOffset;}
D=top.frames[this.frname].document;
if (document.images)
    D.open("text/html", "replace");
  else
   D.open("text/html");
D.write("<html><meta http-equiv=\"Expires\" content=\"0\"><meta http-equiv=pragma content=no-cache>");
D.write("<body bgColor="+this.bckColor+" link="+this.linkColor+" text="+this.fntColor+" vLink="+this.vlinkColor+" aLink="+this.alinkColor+" > "+this.preCode);
D.write(this.Draw(this.frname));
D.write(this.postCode+"</body></html>");
D.close();
top.frames[this.frname].scroll(offL,offT);
}
function TWSwitch(id)
{
It=this.Get(id);
if(It.Opened==true)It.Opened=false;
else It.Opened=true;
var t="";
if(this.ind)t="top.";
this.Update();
return false;
}
function prl(imgObj,imgSrc) {eval(imgObj+' = new Image()');eval(imgObj+'.src = "'+imgSrc+'"');}
TreeView.dmcnt=0;