var ns ;
var ie ;
var n6;
var W;

function BrowserCheck() 
	{
	if (document.layers) ns=true;
	if (document.all) ie=true;
	if(!ie&&document.getElementById)
		{
		ns=false;
		n6=true;
		};
	if(ns||n6)
		{
		W=window.innerWidth-16
		}
	else
		{
		W=document.body.offsetWidth-20;
		}
	}

function TreeItem(id,parid,name,link,target,image)
	{
	this.vname="DdMenu"+TreeItem.dmcount;
	this.Rand="class='men_rand'; ";
	TreeItem.dmcount++;
	this.image=image;
	this.name=name;
	this.frname="";
	this.id=id;
	this.parentItem=null;
	this.parid=parid;
	this.link=link;
	this.target=target;
	this.items=new Array();
	this.itemCount=0;
	this.Opened=false;
	this.css=null;
	this.face="";
	this.iob=null;
	this.iob1=null;
	this.selected=0;
	this.focus=0;
	this.bSize=0;
	this.tW=0;
	this.tH=0;
	this.xpos=0;
	this.ypos=0;
	
	this.iHeight=48;
	this.imWidth=20;	
	this.width=216;
	this.height=48;
	
	this.WriteCSS = TreeItemWriteCSS;
	this.Show = TreeItemShow;
	this.Add = TreeItemAdd;
	this.WriteDiv = TreeItemWriteDiv;
	this.Get = TreeItemGet;
	this.A = TreeItemA;
	this.arrIm="tech.gif";
	this.arrIm1="tech.gif";
	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=""	
	this.visibility = "visible";
	eval(this.vname + "=this");
	}

function TIMoveTo(x,y)
	{
	if(this.itemCount<1) return;
	this.xpos=x;
	this.ypos=y;
	this.css.left=this.xpos;
	this.css.top=this.ypos;
	}

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)
	{
	It=new TreeItem(id,parid,name,link,target,image);
	this.Add(It);
	}

function TreeItemAdd(item)
	{
	item.Opened=false;
	It=this.Get(item.parid);
	if(item.parid==this.id)
		{
		item.width=this.width;
		//item.bckColor=this.bckColor;
		//item.selBckColor=this.selBckColor;
		//item.fntColor=this.fntColor;
		//item.fntSize=this.fntSize;
		item.iHeight=this.iHeight;
		item.imWidth=this.imWidth;
		item.arrIm=this.arrIm;item.arrIm1=this.arrIm1;
		item.selFntColor=this.selFntColor;
		this.items[this.itemCount]=item;
		item.parentItem=this;
		//item.bSize=this.bSize;
		//item.face=this.face;
		//item.bColor=this.bColor;
		item.visibility="hidden";
		this.itemCount++;
		return;
		}
	if(It!=null)
		{
		It.Add(item);
		return;
		}
	}

function TreeItemWriteDiv()
	{
	preload(this.vname+".iob",this.arrIm);
	preload(this.vname+".iob1",this.arrIm1);
	if(this.itemCount<1) return false;
	document.write("<DIV ID='"+this.vname+"'>");
	for(var i=0;i<this.itemCount;i++)
		{
		ref=this.items[i].name;
		im="";
		im1="";
		cl="";
		scl="";
		im2="";
		cl=" color='"+this.fntColor+"'";
		scl=" color='"+this.selFntColor+"'";
		//w=this.width-this.imWidth-this.iHeight;
		if(this.items[i].itemCount>0&&this.arrIm!="")		
			{
			im="<td width='10' ><img name='"+this.items[i].vname+"im' src='/js/tech.gif' border=0></td>";
			im2="<td width='10' ><img name='"+this.items[i].vname+"im' src='/js/tech.gif' border=0></td>";
			}
		t1="<table class='men_table' cellspacing='0' cellpadding='0'><tr><td><table cellspacing='0' cellpadding='0' onMouseOver=\"this.className='men_over';\" onMouseOut=\"this.className='men_norm';\" class='men_norm'>";
		t1= t1 + "<tr><td width='23'></td><td height='"+this.height+"' ><!-- ";
		tc="-->";
		t2="</td>";
		t3="</tr></table></td></tr></table>";
		this.items[i].normText=t1+cl+tc+"<div id='"+this.items[i].vname+"t' >"+ref+"</div>"+t2+im+t3;
		this.items[i].selText=t1+scl+tc+ref+t2+im2+t3;
		document.write("<DIV ID='"+this.items[i].vname+"i'>"+this.items[i].normText+"</DIV>");
		if(ie)
			{
			this.items[i].ilayer=document.all[this.items[i].vname+"i"];
			this.items[i].tlayer=document.all[this.items[i].vname+"t"];
			}
		if(n6)
			{
			this.items[i].ilayer=document.getElementById(this.items[i].vname+"i");
			this.items[i].tlayer=document.getElementById(this.items[i].vname+"t");
			var tl=this.items[i].tlayer.style;
			//tl.color=this.items[i].fntColor;
			//tl.fontFamily=this.face;
			//tl.fontSize=6+2*this.items[i].fntSize+"pt";
			};
		if(ns)this.items[i].ilayer=eval("document."+this.vname+".document."+this.items[i].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;
		}
	}

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(this.vname+".outHandler();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:";
	if(this.align=="vert")
		{
		Height=this.itemCount*this.iHeight+0*this.bSize;
		Width=this.width+0*this.bSize;
		dx=0;
		dy=this.iHeight;
		}
		else
		{
		Height=this.iHeight+0*this.bSize;
		Width=(this.width+0)*this.itemCount+0*this.bSize;
		dy=0;
		dx=this.width+0;
		}
	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;"); 
		document.write(";left:"+this.xpos+"px;top:"+this.ypos+"px;width:"+Width+"px;");
		document.write("visibility: "+this.visibility+"; cursor: default; z-index:1;}\r\n");
		for(var i=0;i<this.itemCount;i++)
			{
			document.write("#"+this.items[i].vname+"i {position:absolute;"); 
			document.write(";top:"+(i*dy+this.bSize)+"px;left:"+(i*dx+this.bSize)+"px"+";width:"+this.width+"px;");
			document.write("height: 0px; z-index:1;}\r\n");
			this.items[i].WriteCSS();
			}
		if(this.parentItem==null)document.write("--></STYLE>\r\n");
		}
	}

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.bckColor;
	//var c2=this.selBckColor;
	if(ie||n6)
		{
		if(document.images[this.vname+"im"])document.images[this.vname+"im"].src=(mod)? this.iob1.src:this.iob.src;
		//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;
	sel=i;
	this.active=true;
	if(this.parentItem!=null)this.parentItem.active=true;
	this.items[this.selected].active=true;
	var nxpos=this.xpos+this.width;
	var nypos=this.ypos+i*this.iHeight;
	if(this.align!="vert")
		{
		nxpos=this.xpos+i*this.width;
		nypos=this.ypos+this.iHeight;
		}
	if(nxpos+this.width>W) nxpos=nxpos*this.width;
	this.items[sel].MoveTo(nxpos,nypos);
	this.items[this.selected].Show(0);
	this.items[sel].Show(1);
	if(sel!=this.focus)
		{
		this.items[this.selected].Toggle(false);
		this.items[sel].Toggle(true);
		status=this.items[sel].link;
		}
	this.selected=sel;
	this.focus=sel;
	}

function TreeItemDown(i)
	{
	sel=i;
	if(this.items[sel].link!="")
		{
		if(this.items[sel].target!="")parent.frames[this.items[sel].target].location=this.items[sel].link;
		else location.href=this.items[sel].link;
		}
	}

function TreeItemReset()
	{
	if(this.active)return;
	for(var i=0;i<this.itemCount;i++)this.items[i].Show(0);
	this.focus=-1;
	if(this.parentItem!=null)
		{
		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(ie)
		{
		mx=window.event.clientX;
		if(document.body.scrollLeft)mx+=document.body.scrollLeft;
		my=window.event.clientY;
		if(document.body.scrollTop)my+=document.body.scrollTop;
		if((mx>this.xpos+1&&mx<this.xpos+this.tW)&&(my>this.ypos+1&&my<this.ypos+this.tH)) return;
		}
	this.active=false;
	setTimeout(this.vname+".Reset()",300);
	}

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

TreeItem.dmcount=0;