$(document).ready(function()
{
	$("#sections ul.level1").each(function()
	{
		if($(this).attr('rel') == 'empty')
		{
			var next = $(this).next('ul.level2');
			var parent = $(this);
			var link = parent.children().children();
			link.attr('href','#0');
			link.bind('click',function() {
				next.reactivate();
				parent.children().addClass('active');
				parent.children().attr('id','actived');
			});
		}
	}
	);
}
);

$.fn.reactivate = function()
{
	var element = $(this);
	var old_element = $("#sections ul.display");
	$("#sections li.active").each(function()
	{
		$(this).removeClass('active');
		$(this).attr('id','');
	});
	if(old_element.html() == null)
	{
		element.slideDown('slow',
		function()
		{
			element.addClass('display');
		});
	}else
	{
	old_element.slideUp('slow',
	function()
	{
		$(this).removeClass('display');
		element.slideDown('slow',
		function()
		{
			element.addClass('display');
		});
	});
	}
}
