// CodeThatTree PRO
// Version: 1.0.1
// IT IS ILLEGAL TO USE UNREGISTERED VERSION OF THE SCRIPT. WE PERFORM
// MONITORING OF THE SITES THAT USE SCRIPT USING GOOGLE AND SPECIAL WORDS
// INCLUDED INTO THE SCRIPT. WE WILL INITIATE LEGAL ACTIONS AGAINST THE
// PARTIES THAT VIOLATE LICENSE AGREEMENT. PLEASE REGISTER THE SCRIPT.
// Copyright (c) 2003 by CodeThat.Com
// http://www.codethat.com/

var CT_IMG_BLANK = "img/1x1.gif";

var CodeThatTreeRoots = [];


if(!Undef(ua))
if(ua.oldOpera) {
	
	function CT_Tree_Redraw(){
	
		if (Undef(self._FJS_reloading)) {
			self._FJS_reloading = true;
			location.reload()
		}
	
	};
	CodeThat.setResizeHandler(CT_Tree_Redraw);
};


if(!ua.nn4) {	
	function CT_Draw() {
		var i;
		for(i in CodeThatTreeRoots) {
			var a;
			CodeThatTreeRoots[i].draw(a,a,1);
		}
	};
	CodeThat.regEventHandler("load",CT_Draw,window);
};
function gn(a) {
	if(Def(a)) 
		return isNaN(a-0)?0:(a-0);
	return 0;	
};


var Obj;
function findImage(strName)
{
	Obj = null;
        if(ua.nn4) findImage_(window,strName);
	else Obj=CodeThat.findElement(strName);
 	return Obj;
};
function findImage_(node,nameOfObject) {
        	
	if (node.name == nameOfObject ) {Obj = node;return true;}	
	for ( var counter = 0; counter < node.document.images.length; counter++ ) {
		if (node.document.images[counter].name==nameOfObject) {Obj = node.document.images[counter];return true;}
	}
	
	for ( var i = 0; i < node.document.layers.length; i++ ) {
		if(findImage_(node.document.layers[i],nameOfObject)) break;
	}
}






function CT_TCreateShadow (o) {
	var s = o.get('shadow');
	if (s) {
		o._s = new CLayer();
		o._s.setZIndex(o.z()-1);
		o._s.setBgColor(s.color);
		o._s.setVisible(true);
		if(ua.oldOpera)o._s.setRel(true);
		if(ua.nn4)
			o._s.create();
		else
			return o._s.getSource();
	}
};

function CT_TCreateBorder (o) {
	var b = o.get('border');
	if (b) {
		o._b = new CLayer();
		o._b.setZIndex(o.z()+1);
		o._b.setBgColor(b.color);
		o._b.setVisible(true);
		if(ua.oldOpera)o._b.setRel(true);
		o._bb = new CLayer();
		o._bb.setZIndex(o.z()+1);
		o._bb.setBgColor(o.get('bgcolor')||'#FFFFFF');
		o._bb.setVisible(true);
		if(ua.oldOpera)o._bb.setRel(true);
		if(ua.nn4) {
			o._b.create();
			o._bb.create();
		}
		else
			return o._b.getSource()+o._bb.getSource();
	}
};


// Object represents general node structure
function CTreeNode() {
	this.items = [];
}

{
	var CTNp = CTreeNode.prototype;
	CTNp.add = function(node) {
		this.items[this.items.length]=node;
		node.path+=".items["+(this.items.length-1)+"]";
	}; 
	CTNp.init = function() {
		this.path = this._parent==null ? ("CodeThatTreeRoots['"+this._id+"'].r") : this._parent.path;
		this.topID = this._parent==null ? this._id : this._parent.topID;
	};
}




// Object represents tree item
function CTreeItem(def,id,parent) {
	// Save parameters from def
	this.text=Undef(def.text)?"":def.text;
	this.style=def.style||{};
	if(Def(def.menu)) { this.mstyle=def.menu.style;this.mOverStyle=def.menu.styleover;} 
	this.styleover=def.styleover;
	// Main text layer
	this._main=new CLayer();
	this._main.setID(id);
	this._id = Undef(id)?CodeThat.newID():id;
	this._e = 
		//<!--
		/*
		//-->
		false;
		//<!--
		*/
		//-->
		//<!--
		false;
		//-->
	this._theight = 0;
	this.onOpen = def.onopen;
	this.onClose = def.onclose;
	this.target=Undef(def.target)?((Undef(parent)||Undef(parent.target))?'':parent.target):def.target;
	this._parent = parent;
	this._imgid = CodeThat.newID();
	this._imgclid = CodeThat.newID();
	this._imgclfid = CodeThat.newID();
	this._imgidover = CodeThat.newID();
	this._tdid = CodeThat.newID();
	this._tid =  CodeThat.newID();
	this.action = def.action || '';	
	this.items = [];
	this.tooltip=Def(def.action)?def.action["title"]:''; 
	//<!--
	this._lined = this.get("lined")||this.getm("lined");
	//-->
	//Mouseover layer
	this._over = new CLayer();
	//Background layer
	this._bkgr = new CLayer();
	//Clickable layer
        this._click = new CLayer();
	// Inherit tree structure
	this.init = CTreeNode.prototype.init;
	this.add = CTreeNode.prototype.add;
	this.init();
}



{
	var CTIp = CTreeItem.prototype;

	CTIp.create = function() {
		// Netscape works in other way
		//if(ua.nn4){this.createnn4();return '';}
		// Root should not be creted
		if(this._parent==null)return;
		// Leaf flag
		var leaf = (this.items.length==0);

		// Set last imeges for lined mode
		if(this._lined&&this._last) {
			if(leaf)
				this.style.imgitem = this.get("imgitem_l");
			else {
				this.style.imgdir = this.get("imgdir_l");
				this.style.imgdiropen = this.get("imgdiropen_l");
			}
		}


		// Main container layer
		this._f = new CLayer();
		
		if(!ua.oldOpera)
			this._f.setRel(true);
		// Blank image
                CT_IMG_BLANK=this.get('imgblank')||CT_IMG_BLANK;
		
		var l=this._bkgr; 
	

		//background layer layer
		this.setLayerProp(l,'',this.z()+2,this.get('bgcolor')||'',this.get("bgimg")||'',ua.nn4?false:true);
		var overcss = this.getOver('css')||this.get('css');
		//mouseover layer setup
		this.setLayerProp(this._over,overcss,this.z()+3,this.getOver('bgcolor')||this.get('bgcolor'),this.getOver('bgimg')||'',false);
		
 
        	// Main layer setup
		var t = Undef(this.action)?'':(this.action["target"]||this.target);
		var act =(Undef(this.action)?
			(ua.nn4?("href=\"#\" "):" "):
			("href="+(Undef(this.action["js"])?(Undef(this.action["url"])?("\"javascript:void(0);\" "):("\""+this.action["url"]+"\" "+ (Undef(t)?(""):("target=\""+t+"\" ")))):("\"javascript:"+this.action["js"]+";\" "))));
		
		var onclick="";
		if(this.items.length>0){
			if(ua.oldOpera||ua.nn4) onclick = this.path+".expand();CodeThatTreeRoots['"+this.topID+"'].r.draw();return true; ";
			else onclick = this.path+".expand();return true; ";
		}
		
		var ops=(ua.oldOpera)?"":(" onClick=\"" +onclick+"\"");
		var atag = "<A "+act+(ua.moz?"":ops)+(Def(this.tooltip)?(" title=\""+this.tooltip+"\""):"")+">";
		var imgsrc=leaf?this.get("imgitem"):(this._e?this.get("imgdiropen"):this.get("imgdir"));
		var imgtag=Undef(imgsrc)?"":"<IMG "+(ua.nn4?("NAME=\""):("ID=\""))+this._imgid+"\" BORDER=0 "+(ua.opera7 ? "":"ALIGN=\"left\"") +" src=\""+imgsrc +"\"/>";
		var text =Undef(this.get("color"))?this.text:"<FONT "+(Undef(this.get("color"))?">":(" color=\""+this.get("color")+"\">"))+this.text+"</FONT>";
		var m=this._main; 
		
                var sr='',st=[];
		
		//<!--

		if(Def(this._lined)){
			var p = this._parent;
			var il, st=[];

			while(p._parent!=null) {
		                if(p._parent.items[p._parent.items.length-1]==p)il=CT_IMG_BLANK;else il=this.get("imgline");
				st[st.length]="<td><img border=0 src='"+il+"' "+(ua.opera7?"":"ALIGN='left'")+"/></td>";
				p=p._parent;
                	}
			for(var i=st.length-1;i>=0;--i)sr+=st[i];
		}
		else 
		//-->
		//Making offset layer
		if(!(ua.oldOpera||ua.nn4)){  
			var off=this.get("itemoffset");
			var oy = (Undef(off)?0:off.y - 0);
			if(oy>0) {
				this._off=new CLayer();
				this._off._sh = oy;
				l=this._off;
				l.setRel(true);
				l.setSize(10,oy);
				if(ua.ie5up)l.setHTML("<P>");
			}
		}
		this._level=st.length;

		
		var mh="<table "+(ua.nn4?("NAME=\""):("ID=\""))+this._tid+"\" cellpadding=0 cellspacing=0 border=0>"+(this._lined?('<tr>'+sr):(sr+'<tr>'))+"<td "+(ua.nn4?("NAME=\""):("ID=\""))+this._tdid+"\">"+imgtag+"</td><td><p"+(Undef(this.get("css"))?"":" class=\""+this.get("css")+"\"")+">"+text+"</p></td></tr></table>";
		m.setHTML(mh);
               	this.setLayerProp(m,this.get('css'),this.z()+4,'','',ua.nn4?false:true);
                
	        
		if(ua.nn4)m.create();else this._f.setHTML(m.getSource()); 
		if(ua.nn4)this._bkgr.create();else this._f.appendHTML(this._bkgr.getSource());
 
		//Borders and shadow
		if(this.get('shadow')){if(ua.nn4)CT_TCreateShadow(this);else this._f.appendHTML(CT_TCreateShadow(this));}
		if(this.get('border')){if(ua.nn4)CT_TCreateBorder(this);else this._f.appendHTML(CT_TCreateBorder(this));}
		var w=this.width(),h=this.height();

		// Clickable top layer		
		if(!this.get("form")) {
			l=this._click; 
			l.setHTML(atag +"<img border=0 "+(ua.nn4?("NAME=\""):("ID=\""))+this._imgclid+"\""+(ua.nn4?(" width="+w+" height="+h):"")+" src='"+CT_IMG_BLANK+"'></A>");			
			this.setLayerProp(l,this.getOver('css')||this.get('css'),this.z()+5,'','',ua.nn4?false:true);
			l.addEventHandler("onMouseOver", this.path+".over()");
			l.addEventHandler("onMouseOut", this.path+".out()");
			if(ua.oldOpera) {	
				if(Def(this.action)) {
					var goref;  act='';
					if(t=='_blank')goref="window.open('"+this.action["url"]+"');";
					else if(Undef(t))goref="window.location.href='"+this.action["url"]+"';";
					else goref="parent.frames['"+t+"'].location.href='"+this.action["url"]+"';";
        	                        act =Undef(this.action["js"])?goref:this.action["js"];
					l.addEventHandler("onClick", act+";"+onclick);
				}
				else 
					l.addEventHandler("onClick", onclick);
			}
			if(!leaf && ua.moz)l.addEventHandler("onClick", onclick);
			if(ua.nn4)l.create();else this._f.appendHTML(l.getSource());
		}
		// Clickable folder image layer		
		if(!leaf && imgtag!="") {		
			this._imgclick = new CLayer();
			l=this._imgclick;
			var sHref = (ua.nn4)?("href=\"#\" "):(" ");
			l.setHTML("<A "+ sHref + (ua.moz?"":ops) + "><img border=0 "+(ua.nn4?("width="+this.getImgW()+" height="+this.getImgH()+" NAME=\""):("ID=\""))+this._imgclfid+"\" src='"+CT_IMG_BLANK+"'></A>");
			this.setLayerProp(l,'',this.z()+6,'','',ua.nn4?false:true);
			l.addEventHandler("onMouseOver", this.path+".over()");
			l.addEventHandler("onMouseOut", this.path+".out()");
			if(ua.moz||ua.oldOpera)l.addEventHandler("onClick", onclick);
			if(ua.nn4)l.create();else this._f.appendHTML(l.getSource());
		}
                l=this._over;
                
		var textover = Undef(this.getOver("color"))?this.text:"<FONT "+(Undef(this.getOver("color"))?">":(" color="+this.getOver("color")+">"))+this.text+"</FONT>"
		imgtag=Undef(imgsrc)?"":"<IMG "+(ua.nn4?("NAME=\""):("ID=\""))+this._imgidover+"\" BORDER=0 "+ (ua.opera7 ? "":"ALIGN=\"left\"") +" src=\""+(leaf?this.get("imgitem"):(this._e?this.get("imgdiropen"):this.get("imgdir"))) +"\"/>";
		l.setHTML("<table cellpadding=0 cellspacing=0 border=0>"+(this._lined?('<tr>'+sr):(sr+'<tr>'))+"<td>"+imgtag+"</td><td><p"+(Undef(overcss)?"":" class=\""+overcss+"\"")+">"+textover+"</p></td></tr></table>");
		if(ua.nn4)l.create();else this._f.appendHTML(l.getSource());

		return this._f.getSource()+(Def(this._off)?(this._off.getSource()):'')+(ua.nn4?"<br>":"");
	};

	CTIp.initl = function() {
        	// Root should not be creted
		if(this._parent==null)return;
	
		if(Def(this._off))this._off.assignLayer();
		var leaf = (this.items.length==0);
		if(!ua.nn4)this._f.assignLayer();
	        		
		if(!ua.nn4)this._main.assignLayer();
		var w=this.width(),h=this.height();
		if(ua.opera6&&w==0)w=this._main.getWidth(); 
		if(ua.opera6&&h==0)h=this._main.getHeight(); 
		var bw=0,sw=0;
		if(this._b)bw=this.get("border").width;
		if(this._s)sw=this.get("shadow").width;

		this._h=h;
		var x=this._lined?this.getImgX():0;
		if(!ua.nn4)this._f.setSize(w+2*bw+sw,h+2*bw+sw);
		if(!ua.nn4)this._main.moveTo(bw,bw);

        	if(!ua.nn4)this._bkgr.assignLayer();
		this._bkgr.setSize(w,h);   
		this.moveLayer(this._bkgr,bw,bw);
	
		if(this._s) {
			if(!ua.nn4)this._s.assignLayer();
			this.moveLayer(this._s,2*bw+sw,2*bw+sw);
			this._s.setSize(w,h);
		}
		if(this._b) {
			if(!ua.nn4) {
				this._b.assignLayer();
			        this._bb.assignLayer();
			}
			this.moveLayer(this._b,0,0);
			this.moveLayer(this._bb,bw,bw);

			this._b.setSize(w+bw*2,h+bw*2);
			this._bb.setSize(w,h);
		}

		if(!ua.nn4&&!this.get("form"))this._click.assignLayer();
		this._click.setSize(w,h);
		this.moveLayer(this._click,bw,bw);


		if(!ua.nn4)this._over.assignLayer();
		this._over.setSize(w,h);
		this.moveLayer(this._over,bw,bw);

	
		if(ua.nn6up||ua.opera)
			this.setClImgSize(this._imgclid,w,h);
		if(Def(this._imgclick)) {
			if(!ua.nn4)this._imgclick.assignLayer();
			if(ua.moz||ua.opera)
				this.setClImgSize(this._imgclfid,this.getImgW(),this.getImgH());
			this._imgclick.setSize(this.getImgW(),this.getImgH());
			//<!--
			if(this._lined&&!(ua.oldOpera||ua.nn4))this._imgclick.setPos(x,0);
			//-->
	                if(ua.oldOpera) this._imgclick.moveTo(0,-this.delta(this._imgclick,this._f));
		}
	};
        CTIp.moveLayer = function(l,x,y) {
		if(Undef(l)||ua.nn4)return;
		if(ua.oldOpera) 
			l.moveTo(x,y-this.delta(l,this._f));
		else 
			l.moveTo(x,y);
	};
        CTIp.width = function() {
                if(Def(this.get('size')))return (this.get('size')[0]||this.get('size').width -0);
		
		var t =  CodeThat.findElement(this._tid);
                var w;
		if(ua.nn4) w=this._main.getWidth();
		else {
			w=Def(t)?(Math.max(gn(t.scrollWidth),gn(t.offsetWidth),gn(t.width),gn(t.style.pixelWidth))):0;
			if(this._parent!=null) {
				if(Undef(this._parent._cw))this._parent._cw=0;
				if(this._parent._cw<w)
					this._parent._cw=w;
				else 
					w=this._parent._cw;
			}
		}
		return w;
	};
	CTIp.delta = function(l1,l2) {
		return l1.getAbsolutePos()[1]-l2.getAbsolutePos(0)[1];
	};
	CTIp.height = function() {
                if(Def(this.get('size')))return (this.get('size')[1]||this.get('size').height -0);
		if(this._lined)  return this.getImgH();
		var h;
		if(ua.nn4) h=this._main.getHeight();
		else {
			var t =  CodeThat.findElement(this._tid);
			h=Def(t)?(Math.max(gn(t.scrollHeight),gn(t.offsetHeight),gn(t.height),gn(t.style.pixelHeight)) ):0;
		}
		return h;

	};
        CTIp.left = function() {
		return this._main.getLeft();
	};
        CTIp.top = function() {
		return this._main.getTop();
	};
	CTIp.setLayerProp = function(o,css,z,col,bgimg,vis) {
		o.setCSS(css);
		o.setZIndex(z);
		o.setBgColor(col);
		o.setBgImage(bgimg);
		if(ua.oldOpera)o.setRel(true);
		o.setVisible(vis);
	};
	CTIp.getImgH = function() {
		var i=findImage(this._imgid);
		return Def(i)?i.height:0;
		
	};
	CTIp.getImgW = function() {
		var i=findImage(this._imgid);
		return	Def(i)?i.width:0;
	};
	CTIp.getImgX = function() {
		var i=findImage(this._tdid);
		return Def(i)?(i.offsetLeft||i.clientLeft||i.style.pixelLeft||i.style.left||0):0;
		
	};
	CTIp.getImgY = function() {
		var i=findImage(this._tdid);
		return	Def(i)?(i.offsetTop||i.clientTop||i.style.pixelTop||i.style.top||0):0;
	};
	CTIp.setL = function(l,x,y,w,h) {
		if(Def(l)) {
			l.moveTo(x,y);
			l.setSize(w,h);
		}
	};
	CTIp.moveTonn4 = function(x,y) {
		var w = this.width(),h=this.height();
		var bw=0,sw=0;
		if(this._b) {
			bw=this.get("border").width;
			this.setL(this._b,x,y,w+2*bw,h+2*bw);
			this.setL(this._bb,x+bw,y+bw,w,h);
		}
		if(this._s) {
			sw=this.get("shadow").width;
			this.setL(this._s,x+bw+sw,y+bw+sw,w,h);
		}
	
		this._main.moveTo(x+bw,y+bw);
		this.setL(this._over,x+bw,y+bw,w,h);
		this.setL(this._click,x+bw,y+bw,w,h);
		this.setL(this._bkgr,x+bw,y+bw,w,h);
		this.setL(this._imgclick,x+bw,y+bw,this.getImgW(),this.getImgH());
		

	};
	CTIp.moveTo = function(x,y) {

		if(x==this._x&&y==this._y) return;
		if(ua.nn4){this.moveTonn4(x,y);return;}
		this._f.moveTo(x,y);
		
		if((ua.ie || ua.nn6up || ua.oldOpera) && Undef(this._sizeset)) {
			var bw=0,sw=0;
			if(this._b)bw=this.get("border").width;
			if(this._s)sw=this.get("shadow").width;

			var w = this.width(),h=this.height();
			if(ua.opera6&&w==0)w=this._main.getWidth(); 
			if(ua.opera6&&h==0)h=this._main.getHeight(); 
			
			this._f.setSize(w+2*bw+sw,h+2*bw+sw);
			this._bkgr.setSize(w,h);
                        
			if(ua.oldOpera||ua.ie) 
				this._click.setSize(w,h);
				
			this._sizeset=1;
			this.setClImgSize(this._imgclid,w,h);
			if(Def(this._imgclick)) {
                                this._imgclick.setSize(this.getImgW(),this.getImgH());
				this.setClImgSize(this._imgclfid,this.getImgW(),this.getImgH());
				//<!--
				if(Def(this._lined))this._imgclick.setPos(this.getImgX(),0);
				//-->
			}
		}
	

	
		this._x=x;
		this._y=y;
		
		
		
	};
	CTIp.get = function(key) {
		var val;
		if(Und(this.style)||Und(this.style[key])) {
			// Try to get the parameter from parent
			if(this._parent!=null)
				val = this._parent.getm(key);
			if(Undef(this.style))this.style={};
			if(val)this.style[key]=val;
		}
		else
			val=this.style[key];	
		return val;
	};
	CTIp.getm = function(key) {
		if(Und(this.mstyle)||Und(this.mstyle[key]))
			return this.get(key);
		else
			return this.mstyle[key];
	};
	CTIp.getOverm = function(key) {
		if(Und(this.mOverStyle)||Und(this.mOverStyle[key]))
			return this.getOver(key);
		else
			return this.mOverStyle[key];
	};
	CTIp.getOver = function(key) {
		var val;
		if(Und(this.styleover)||Und(this.styleover[key])) {
			// Try to get the parameter from parent
			if(this._parent!=null)
				val = this._parent.getOverm(key);
			if(Undef(this.styleover))this.styleover={};
                        if(val)this.styleover[key]=val;
		}
		else
			val=this.styleover[key];	
		return val;
	};
	CTIp.over = function () { 
		this._over.setSize(this.width(),this.height());
	        this._main.hide();
		this._over.show(); 
		if(Def(this.tooltip))window.status=this.tooltip;
	};

	
        CTIp.out = function () {
		this._main.show();
		this._over.hide(); 
		if(Def(this.tooltip))window.status="";	        
	};
	CTIp.setExpanded = function(expa,b) {
		var o = this._e==false&&expa==true;
		var c = this._e==true&&expa==false;

		if(expa&&this.get("singlecol")&&this._parent!=null) 
			for(var i = 0;i<this._parent.items.length;++i)this._parent.items[i].setExpanded(false);

		this._e = expa;
		//<!--
		if(!b)CodeThatTreeRoots[this.topID].saveToCookie();
		if(Def(this.onOpen)&&o&&b!=1)eval(this.onOpen);
		if(Def(this.onClose)&&c&&b!=1)eval(this.onClose);
		//-->
		this.setExpImg();
		this.setExpImgOver();
		
		if(!(ua.oldOpera||ua.nn4)&&b!=2)this.draw(this._x,this._y);
		
		
	};
	CTIp.expand = function() {
		this.setExpanded(!this._e);
	};
	CTIp.setClImgSize = function(id,w,h) {
		if(Undef(this[id])) this[id] = CodeThat.findElement(id);
		var i = this[id];
	
		if(Def(i)) {i.width=w;i.height=h;}
	};
	CTIp.setExpImg = function() {

		if(Undef(this._imgel)) this._imgel = CodeThat.findElement(this._imgid);
		var i = this._imgel;		
		if(Def(i)) if(this.items.length>0) i.src=this._e?this.get("imgdiropen"):this.get("imgdir");

        
	};
	CTIp.setExpImgOver = function() {
		if(Undef(this._imgelov)) this._imgelov = CodeThat.findElement(this._imgidover);
		var i = this._imgelov;
		if(Def(i)) if(this.items.length>0) i.src=this._e?this.get("imgdiropen"):this.get("imgdir");

        
	};
	
	CTIp.draw = function(x,y) {
		var l=Def(this._lined);
		var off=this.get("itemoffset");
		var ox = (Undef(off)?0:off.x - 0);
		var oy = l?0:(Undef(off)?0:off.y - 0);
		var ii = this.items;
		//1. Init
		if(this._parent!=null) {
			// Show myself
			this.moveTo(x,(ua.oldOpera||ua.nn4)?y:oy);
			this.setVisible(true);
			this._theight = this.height()+((ua.oldOpera||ua.nn4)?oy:0);
			//<!--
			if(!l)
			//-->
				x+=ox;
		}
		else {
			//Init start coordinates
			x = x || this.startx || Def(ii[0])?ii[0].left():0;
			y = y || this.starty || Def(ii[0])?ii[0].top():0;
			this.startx = x;
			this.starty = y;
			//Root does not exist as item, but it is expanded
			this._theight=0;
			this._e=true;
		}
		var i = 0;
		//2. If I'm expanded call draw to childs
		if(this._e) {
			
			for(; i < ii.length; ++i) {
		                ii[i].draw(x,y+this._theight);
		                var h =ii[i].getTHeight()+oy;
				this._theight+=h;
			}
		}
		else {
			// Hide unexpanded
			for(;i< ii.length;)ii[i++].setVisible(false);
	        }
	
	
	};
	CTIp.z = function () { 
		if(Undef(this.style)||Undef(this.style.z)) {
			// Try to get the parameter from parent
			if(this._parent!=null)
				return this._parent.z();
			else
				return 1;
		}
		else
			return this.style.z;	
	};
	CTIp.getTHeight = function() {
		return this._theight; 
	};
	CTIp.hideL = function(l,b) {
		if(Undef(l))return;
		l.setVisible(b);
		if(!ua.oldOpera) {
			if(b) {
				if(Def(this._h)) {
					var bw=0,sw=0;
					if(this._b)bw=this.get("border").width;
					if(this._s)sw=this.get("shadow").width;

					l.setHeight(this._h+2*bw+sw);
				}
			}
			else {
				this._h=this.height();
				l.setHeight(0);
			}
		}	
		
	};		
	CTIp.setVisible = function(b) {
		//Set visibility flag to this layer and subitems
		if(!b)
			for(var i=0;i<this.items.length;)this.items[i++].setVisible(b);
		this.hideL(this._f,b);
		//Hide other layers
		if(!ua.opera7) {	
			if(!this._over.getVisible())
				this._main.setVisible(b);
			this._bkgr.setVisible(b);
			this._click.setVisible(b);
			if(Def(this._imgclick))this._imgclick.setVisible(b);
			if(Def(this._s))this._s.setVisible(b);
			if(Def(this._b)){this._b.setVisible(b);this._bb.setVisible(b);}
		
		}
		//Hide offset layer if any
		if(Def(this._off)) {this._off.setVisible(b);this._off.setHeight(b?this._off._sh:0);}
	};
	//<!--
	CTIp.expItemByText = function(s,expa) {
		if(s==this.text) {
			this.setExpanded(expa);
			return this;
		}
		for(var i = 0; i < this.items.length; ++i) {		
			var a = this.items[i].expItemByText(s,expa);
			if(a!=null) {
				if(expa) this.setExpanded(expa);
				return a;
			}
		}
		return null;
	};
	CTIp.expItemById = function(s,expa) {
		if(s==this._id) {
			this.setExpanded(expa);
			return this;
		}
		for(var i = 0; i < this.items.length; ++i) {		
			var a = this.items[i].expItemById(s,expa);
			if(a!=null) {
				if(expa) this.setExpanded(expa);
				return a;
			}
		}
		return null;
	};
	CTIp.getState = function(s) {
		var st=s+(this._e?"1":"0");
		for(var i = 0; i < this.items.length; ++i) {		
			st = this.items[i].getState(st);
		}
		return st;
	};
	CTIp.setState = function(s, i) {
		var newi = i+1;
		var l = this.items.length;
		this._e=(l==0)?false:(s.charAt(i)=="1");
		for(var j = 0; j < l; ++j) {		
			newi = this.items[j].setState(s,newi);
		}
		return newi;
	};
	//-->
};


// Object represents tree creation and drawing
function CTree(def, id) {
	this.id = id || CodeThat.newID();
	CodeThatTreeRoots[this.id] = this;
	this.def = def;
	/*STD_UNREG
	if(Def(def.items)) {
		var d = {};
		d.style ={"imgitem":"","form":true};
		d.text = "<FONT color='#8F8F8F' size='1'>"+unescape('%43%6F%64%65%54%68%61%74%2E%43%6F%6D')+"</FONT>";
		def.items[def.items.length]=d;
	}
	*/
	this.r = this.createItems(def,this.id,null
		//<!--  
		/*
		//--> 		
		,0
		//<!--
		*/
		//-->
	);
}

{
	var CTp = CTree.prototype;
	CTp.createItems = function(def,id,parent 
		//<!--  
		/*
		//--> 		
		,l
		//<!--  
		*/
		//--> 		
		) {
	        // Create a new item and add it to the parent
		var node = new CTreeItem(def,id,parent);
		if(parent!=null) parent.add(node);
		if(Def(def.menu)) def = def.menu;
		if(Def(def.items)&&!Undef(def.items.item)) def.items = def.items.item;
		if(Undef(def.items))
			def.items=[];
		else
			if(Def(def.items.text)&& Undef(def.items[0])){var a=def.items;def.items=[];def.items[0]=a;}
		// Loop on subitems
		if(Def(def.items)
		//<!--  
		/*
		//--> 		
		&&l<3
		//<!--
		*/
		//-->
		) {
			for(var i=0;i<def.items.length;++i) {
				var sub = this.createItems(def.items[i],def.items[i].id,node
		//<!--  
		/*
		//--> 		
		,l+1
		//<!--
		*/
		//-->
		);
				if(i==(def.items.length-1))sub._last=true;
			}
		}
		return node;
	};
	//<!--
	CTp.expandAll = function() {
		this.visit('',1);
		this.r.draw();
	};
	CTp.collapseAll = function() {
		this.visit('',2);
		this.r.draw();
	};
	CTp.expandItemByText = function(s) {
		this.r.expItemByText(s,true);
		this.r.draw();
	};
	CTp.collapseItemByText = function(s) {
		this.r.expItemByText(s,false);
		this.r.draw();
	};
	CTp.expandItemById = function(s) {
		this.r.expItemById(s,true);
		this.r.draw();
	};
	CTp.collapseItemById = function(s) {
		this.r.expItemById(s,false);
		this.r.draw();
	};
	//-->
	CTp.visit = function(parent, flag) {
		// Visitor walks on tree and calls create or expand
		var p = Undef(parent)? this.r : parent;
		if(p!=this.r) {
			if(flag==0)
				this.l+=p.create();
			else if(flag==1)
  				p.setExpanded(true,2)
			else if(flag==2)
				p.setExpanded(false,2);
			else if(flag==3) {
				p.initl();
			}
		}
		for(var i=0;i<p.items.length;++i) {
			this.visit(p.items[i],flag);
		}
		
	};
                
	CTp.create = function(x,y) {
	        var abs = false;
		if(Undef(x)&&Undef(y)) {
			x=y=0;
			var d=this.def.position;
			if(Def(d)) {
				x = (d.pos[0]||d.pos.left-0);
				y = (d.pos[1]||d.pos.top-0);
				abs=(!d.absolute)==false;
			} 
		} else abs=true;
		this.abs=abs;

		//<!--
		var st = CodeThat.readCookie(this.id);
		this.r.setState(st,0);
		//-->


		this.l='';
		
		this._fake = new CLayer();
		var f= this._fake;
		d=this.def;
		if(ua.opera7)
			f.setVisible(false);
		else
			f.setVisible(true);
		this.visit('',0);
		f.setRel(true);
		f.setPos(x,y);
		if(Def(d.style)&&Def(d.style.fixwidth))
			f.setSize(d.style.fixwidth-0,
				(d.style.fixheight-0));
		
		
		if(ua.opera5)	
			f.setHTML("<img src=\""+CT_IMG_BLANK+"\"/>");
		else if(ua.opera6) 
			f.setHTML("<table cellpadding=0 cellspacing=0 border=0 width=100% height=100%><tr><td valign=top>"+this.l+"</td></tr></table>");
		else if(!ua.nn4)       
			f.setHTML(this.l);
				
		this._fake.create();
		if(abs) {
			this.draw(x-0,y-0);
		}
		if(ua.opera5)document.write(this.l);	
		
		
	};
	CTp.draw = function(x,y,b) {

		if(!ua.nn4&&Undef(b))return;
      		
		
		if(Undef(x)&&Undef(y)) {	
			x=y=0;
			if(ua.oldOpera||ua.nn4) {
				x = gn(this._fake.getAbsolutePos()[0]);
				y = gn(this._fake.getAbsolutePos()[1]);
			}
			
		}
		this.visit('',3);
                this.r.draw(x,y);
                if(ua.opera7)this._fake.setVisible(true);

	};


	//<!--
	CTp.saveToCookie = function() {
		var st = this.r.getState("");
		// Ten days expire
		CodeThat.writeCookie(this.id,st,86400000);
	};
	//-->
}

