var tree;

window.onload = function() {
	// --- ordinary MooTreeControl example:
	
	tree = new MooTreeControl({
		div: 'mytree',
		mode: 'files',
		grid: true,
		onSelect: function(node, state){
			if(state && node.data.url != null){
				
				if(node.data.url.indexOf('?id=') >= 0){					
					window.location = node.data.url;
				}
			}
		}
	},{
		text: 'Challenges',
		open: true
	});
	
	tree.disable(); // this stops visual updates while we're building the tree...
	
	tree.adopt('challenge_list');
	
	tree.enable(); // this turns visual updates on again.
	tree.expand();	
}