//2002 Ilya Muzukin O'range v1.2
var ns ;var ie ;var n6;var op;var W;
function
BrowserCheck()
{
    ns=document.layers;
    ie=document.all;
    op=window.opera;
    if(!ie&&document.getElementById){ns=false;n6=true;};
    if(ns||n6||op){W=window.innerWidth-16}else{W=document.body.offsetWidth-20;}
}
function
TIMoveTo(x,y)
{
    if(this.itemCount<1) return;
    this.xpos=x;this.ypos=y;this.css.left=x;this.css.top=y;
}
function
TreeItemGet(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
TreeItemA(id,parid,name,link,target,image,im2)
{
    It=new TreeItem(id,parid,name,link,target,image,im2);
    this.Add(It);
}
function
TreeItemAdd(N)
{
    N.Opened=false;
    It=this.Get(N.parid);
    if(N.parid==this.id)
    {
	N.width=this.width;
	N.bckColor=this.bckColor;
	N.selBckColor=this.selBckColor;
	N.fntColor=this.fntColor;
	N.fntSize=this.fntSize;
	N.iHeight=this.iHeight;
	N.imWidth=this.imWidth;
	N.arrIm=this.arrIm;N.arrIm1=this.arrIm1;
	N.selFntColor=this.selFntColor;
	this.items[this.itemCount]=N;N.d=this.d;
	N.parentItem=this;
	N.bSize=this.bSize;
	N.face=this.face;
	N.onm=this.onm;N.i=this.i;N.b=this.b;N.u=this.u;
	N.bColor=this.bColor;
	N.visibility="hidden";
	this.itemCount++;
	return;
    }
    if(It!=null) {It.Add(N);return;}
}

function
TreeItemWriteDiv()
{
    preload(this.vname+".iob",this.arrIm);preload(this.vname+".iob1",this.arrIm1);preload(this.vname+".imb",this.img2);
    if(this.itemCount<1) return false;
	document.write("<DIV ID='"+this.vname+"'>");
    for(var i=0;i<this.itemCount;i++)
    {
	ci=this.items[i];
	ref=ci.name;if(ci.b)ref="<b>"+ref+"</b>";if(ci.i)ref="<i>"+ref+"</i>";if(ci.u) ref="<u>"+ref+"</u>";
	im="";im1="";cl="";scl="";im2="";ime="";
	cl=" color='"+ci.fntColor+"'";scl=" color='"+ci.selFntColor+"'";
	if(ci.image!=""){im1="<img name='"+ci.vname+"ic' src='";ime="' width='"+this.imWidth+"' height='"+this.iHeight+"' border=0>";}
	w=this.width-this.imWidth-this.iHeight;
	if(ci.itemCount>0&&this.arrIm!=""){im="<img name='"+ci.vname+"im' src='"+this.iob.src+"' height='"+this.iHeight+"' width='"+this.iHeight+"' border=0>";im2="<img name='"+ci.vname+"im' src='"+this.iob1.src+"' height='"+this.iHeight+"' width='"+this.iHeight+"' border=0>";}
	t1="<table border='0' width='"+this.width+"' cellspacing='0' height='"+this.iHeight+"' cellpadding='0'><tr><td width ="+this.imWidth+">"+im1;te=ime+"</td><td width= '"+this.width+"' ><font ";tc=" size='"+ci.fntSize+"' face='"+ci.face+"'>";t2="</font></td><td width="+this.iHeight+">";t3="</td></tr></table>";
	ci.normText=t1+ci.image+te+cl+tc+"<div id='"+ci.vname+"t' >"+ref+"</div>"+t2+im+t3;
	ci.selText=t1+ci.img2+te+scl+tc+ref+t2+im2+t3;
	document.write("<DIV ID='"+ci.vname+"i' >"+ci.normText+"</DIV>");
	if(ie){ci.ilayer=document.all[ci.vname+"i"];ci.tlayer=document.all[ci.vname+"t"];}
	if(n6){ci.ilayer=document.getElementById(ci.vname+"i");
	ci.tlayer=document.getElementById(ci.vname+"t");
	var tl=ci.tlayer.style;
	tl.color=ci.fntColor;tl.fontFamily=this.face;
	tl.fontSize=6+2*ci.fntSize+"pt";
	};
	if(ns)ci.ilayer=eval("document."+this.vname+".document."+ci.vname+"i");
    }
    document.write("</DIV>");
    for(var i=0;i<this.itemCount;i++)
    {
	this.items[i].WriteDiv();
    }
    if(ie){this.layer=document.all[this.vname];this.css=this.layer.style;}
    if(n6){this.layer=document.getElementById(this.vname);this.css=this.layer.style;}
    if(ns){this.layer=eval("document."+this.vname);this.css=this.layer;}
    return false;
}
function
TIEventInit()
{
    var oinit=true;
     for(var i=0;i<this.itemCount;i++)
     {
	 this.items[i].EventInit();
     }
    for(var i=0;i<this.itemCount;i++)
    {
	var style=this.items[i].ilayer;
	if(oinit)this.layer.onmouseout=new Function("e",this.vname+".outHandler(e);return false;");
	oinit=false;
	style.onmouseover=new Function(this.vname+".moveHandler("+i+");return false;");
	style.onmousedown=new Function(this.vname+".downHandler("+i+");return false;");
	if(ns)style.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }
}
function
TreeItemWriteCSS()
{
    var dx;
    var dy;
    var bCol=(ns)?"layer-background-color:" : "background-color:";
    d=this.d;
    if(this.align=="vert")
    {
	Height=this.itemCount*(this.iHeight+d)+2*this.bSize-d;
	Width=this.width+2*this.bSize;
	dx=0;
	dy=this.iHeight+d;
    }
    else
    {
	Height=this.iHeight+2*this.bSize;Width=(this.width+d)*this.itemCount+2*this.bSize-d;
	dy=0;
	dx=this.width+d;
    }
    this.tH=Height; this.tW=Width;
    if(this.itemCount>0)
    {
	if(this.parentItem==null)document.write("<STYLE TYPE='text/css'><!--");
	document.write("#"+this.vname+" {position:absolute;width:"+Width+"px;left:"+this.xpos+"px;top:"+this.ypos+"px;height:"+Height+"px;clip:rect(0,"+Width+","+Height+",0);visibility: "+this.visibility+";"+bCol+this.bColor+"; cursor: hand; z-index:5;}"); 
	for(var i=0;i<this.itemCount;i++)
	{
	    document.write("#"+this.items[i].vname+"i {position:absolute;"+bCol+this.items[i].bckColor+";top:"+(i*dy+this.bSize)+"px;left:"+(i*dx+this.bSize)+"px"+";width:"+this.width+"px;height:"+this.iHeight+"px; z-index:1;}"); 
	    this.items[i].WriteCSS();
	}
	if(this.parentItem==null)document.write("--></STYLE>");
    }
}
function
TreeItemShow(o)
{
    this.focus=-1;
    if(this.itemCount<1) return;
    if(o==1)
    {
	this.css.visibility=(ns)? "show":"visible";
    }
    else
    {
	for(var i=0;i<this.itemCount;i++)this.items[i].Show(0);
	this.css.visibility=(ns)? "hide":"hidden";
    }
}
function
TIToggle(mod)
{
    this.Opened=mod;
    var c1=this.bckColor;var c2=this.selBckColor;
    if(ie||n6)
    {
	im=document.images;
	if(im[this.vname+"im"])im[this.vname+"im"].src=(mod)? this.arrIm1:this.arrIm;
	if(im[this.vname+"ic"])im[this.vname+"ic"].src=(mod)? this.img2:this.image;
	this.ilayer.style.backgroundColor=(mod)? c2 : c1;
	this.ilayer.style.background=(mod)? c2:c1;
	this.tlayer.style.color=(mod)? this.selFntColor:this.fntColor; 
    }
    if(ns)
    {
	var txt=(mod)? this.selText:this.normText;
	this.ilayer.document.bgColor=(mod)? c2 : c1;
	this.Write(txt);
    }
}
function
TreeItemMove(i)
{
    if(this.itemCount<1)return;
    if(this.onm)this.onm(i);
    this.active=true;pI=this.parentItem;ti=this.items[i];ts=this.items[this.selected];
    if(pI!=null){pI.active=true;pI.focus=-1;}
    ts.active=true;
    k=1;j=i;if(this.align!="vert"){k=i;j=1;}
    var nxpos=this.xpos+k*(this.width+this.d);
    var nypos=this.ypos+j*(this.iHeight+this.d);
    if(nxpos+this.width>W) nxpos=nxpos-2*this.width;
    ti.MoveTo(nxpos,nypos);ts.Show(0);ti.Show(1);ts.Toggle(false);ti.Toggle(true);status=ti.link;
    this.selected=i;this.focus=i;
}

function
TreeItemDown(i)
{
    it=this.items[i];

    document.browse.choice.value = it.name;

    if(it.link!="")
    {
	if(it.link.substring(0,11)=="javascript:"){eval(it.link.substring(11,it.link.length));return;}
	if(it.target!="") parent.frames[it.target].location=it.link;
	else location.href=it.link;
    }
}
function
TreeItemReset()
{
    if(this.active)return;
    this.items[this.selected].Show(0);
    if(this.parentItem!=null){
    if(this.parentItem.focus>=0)return;
    this.parentItem.active=false;this.parentItem.Reset();}
    this.items[this.selected].Toggle(false);
}
function
TreeItemWrite(text)
{
    var style=this.ilayer;
    style.document.open();
    style.document.write(text);
    style.document.close();
}
function
TIMout(e)
{
    if(!ns)
    {
    if(n6){mx=e.pageX;my=e.pageY;}else
    {
	mx=window.event.clientX;
	my=window.event.clientY;
	if(!op){my+=document.body.scrollTop;mx+=document.body.scrollLeft;}
    }
    if((mx>this.xpos+1&&mx<this.xpos+this.tW)&&(my>this.ypos+1&&my<this.ypos+this.tH)) return;
    }
    this.active=false;this.focus=-1;
    setTimeout(this.vname+".Reset()",300);
}

function
preload(imgObj,imgSrc)
{
    eval(imgObj+' = new Image()');
    eval(imgObj+'.src = "'+imgSrc+'"');
}

function
popUp(URL)
{
    w = (screen.width) / 8;
    h = (screen.height) / 6;

    winl = (screen.width - w) / 2;
    wint = (screen.height - h) / 2;

    eval("page" + " = window.open(URL,'" + "','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+w+",height="+h+",top="+wint+",left="+winl+"');");
}

function
TreeItem(id,parid,name,link,target,image,im2)
{
    if (TreeItem.dmcount==0)
    {
	// window.parent.DXCategory.browse.choice.value
	/*
	if (window.frames.name != "")
	{
	    alert(
		"window.frames = " + window.frames.name +
		// "\nwindow.parent = " + window.parent.name +
		// "\nwindow.frames.parent = " + window.frames.parent.name +
		// "\ndocument = " + document.name +
		// "\n\nDXContent = " + window.parent.DXContent.name +
		// "\nDXContent = " + window.parent.DXContent.value
		"\n"
	    );
	}
	*/
	// window.frames = window.parent.DXContent;
	// popUp("http://davenx.absol.com/davenx7.gif");
	// popUp("/davenx7.gif");

	w = (screen.width) / 8;
	h = (screen.height) / 6;

	winl = (screen.width - w) / 2;
	wint = (screen.height - h) / 2;

	URL="";
	// prompt = window.prompt("hello");
	// alert("prompt="+prompt.value);
	// pop2=window.open("","popup2");
	// alert("pop2="+pop2.document.name); // .window.name);
	/*
	eval("popup=window.open(URL,'" +
"','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="
+w+",height="+h+",top="+wint+",left="+winl+"');"
	+"alert('popup = ' + popup.name);");
	*/
    }
    this.vname="DdMenu"+TreeItem.dmcount;
    TreeItem.dmcount++;
    this.image=image;
    this.img2=(im2)? im2:image;
    this.name=name;
    this.frname="";
    this.id=id;
    this.parid=parid;
    this.link=link;
    this.target=target;
    this.items=new Array();
    this.itemCount=0;
    this.Opened=false;
    this.bckColor="#f0f0f0";
    this.fntColor="#ffffff";
    this.selFntColor="#00ffff";
    this.fntSize=2;
    this.face="default";
    this.selBckColor="#a0a0a0";
    this.alinkColor="#ffff00";
    this.arrIm="list-img0.gif";
    this.arrIm1="list-img1.gif";
    this.xpos=0;
    this.ypos=0;
    this.selected=0;
    this.height=600;
    this.width=150;
    this.b=false;this.i=false;this.u=false;this.d=1;
    this.iHeight=21;
    this.imWidth=18;
    this.focus=-1;
    this.bSize=1;
    this.tW=0;
    this.tH=0;
    this.onm=null;
    this.bColor="#000000";
    this.WriteCSS = TreeItemWriteCSS;
    this.Show = TreeItemShow;
    this.Add = TreeItemAdd;
    this.WriteDiv = TreeItemWriteDiv;
    this.Get = TreeItemGet;
    this.A = TreeItemA;
    this.align="vert";
    this.moveHandler=TreeItemMove;
    this.outHandler=TIMout;
    this.downHandler=TreeItemDown;
    this.active=false;
    this.Reset=TreeItemReset;
    this.EventInit=TIEventInit;
    this.MoveTo=TIMoveTo;
    this.Write=TreeItemWrite;
    this.Toggle=TIToggle;
    this.normText="";
    this.selText=""
    eval(this.vname + "=this");
}

TreeItem.dmcount=0;
