/*
 * Ext.ux.TreeUnselector
 * Copyright(c) 2009, djodjo.jp
 */
Ext.ux.TreeUnselector = function(){
	
	this.init = function(tree){
		tree.on('render',function(tree){
		var el = tree.getTreeEl();
			el.on('click',function(e,t){
				if(this.id == t.id){
					tree.getSelectionModel().clearSelections();
				}
			},el);
		})
		tree.on('beforeclick',function(node,event){
			if(node.isSelected()){
				node.unselect();
				return false;
			}
		})
	};	
}