// JavaScript Document

function Treeview_s(name){
		this.name=name;
		this.elements=new Array();
		
		this.addElement = function(id,state){
			this.elements[id]=state;
		}
		
		this.openElement = function(id){
			this.elements[id]=1;
			document.getElementById(this.name + "_Childs_" + id).style.display="";
			var img=document.getElementById(this.name + "_Image_" + id);
			if (img)
				img.src=Treeview_s.Images["open"].src;
		}
		
		this.closeElement = function(id){
			this.elements[id]=0;
			document.getElementById(this.name + "_Childs_" + id).style.display="none";
			var img=document.getElementById(this.name + "_Image_" + id);
			if (img)
				img.src=Treeview_s.Images["close"].src;
		}
		
		this.changeElement = function(id){
			if (this.elements[id]==0) this.openElement(id);
			else this.closeElement(id);
		}
			
		this.saveOpenedElements=function(){
			var ids="";
			for (var i in this.elements){
				if (this.elements[i]==1) ids+=i+"_";
			}
			Cookie.setCookie(this.name,ids,null);
		}
}

Treeview_s.location="";

Treeview_s.initialize=function(location){
	Treeview_s.location=location;
	Treeview_s.Images=new Array();
	Treeview_s.Images["open"]=new Image();
	Treeview_s.Images["open"].src=location+"pics/stateopen.gif";
	Treeview_s.Images["close"]=new Image();
	Treeview_s.Images["close"].src=location+"pics/stateclose.gif";
}