var debug = {
	scroller : null,
	image : null,
	state : 0,
	bar : null,
	anim_speed : 200,
	
	initObj : function()
	{
		this.scroller = $('#debug_scroller');
		this.image = $('#debug_but');
		this.bar = $('#debugbar');
		this.image.click(debug.tooglebar);
		this.state = 0;
	},
	
	tooglebar : function()
	{
		if(debug.state == 0) debug.showbar();
		else debug.hidebar();
	},
	
	showbar : function()
	{
		//this.scroller.animate({ width: '285px' },1500);
		this.bar.animate({ left : '0px' },this.anim_speed,null,function() { debug.state = 1;});
		//this.bar.css({left : '0px'});
		this.state = 1;
		
	},
	
	hidebar : function()
	{
		//this.scroller.animate({ width: '0px' },1500);
		this.bar.animate({ left : '-290px' },this.anim_speed,null,function() { debug.state = 0;});
		//this.bar.css({left : '-290px'});
		this.state = 0;
	}
}

var dtree = {
	
	create : function(elem)
	{
		elem.find('li.dtree_sub > span').each(function() { $(this).click(dtree.toogleMenu) })
	},
	
	toogleMenu : function()
	{
		var elem = $(this).parent('li');
		if($(this).hasClass('open')) dtree.hideSubMenu(elem);
		else dtree.showSubMenu(elem);
	},
	
	showSubMenu : function(elem)
	{
		elem.children('span').addClass('open');
		elem.children('ul').show();
	},
	
	hideSubMenu : function(elem)
	{
		elem.children('span').removeClass('open');
		elem.children('ul').hide();
	}
}
