jQuery(document).ready(function($) {

	$('li.level0 ul').hide();
	$('#side-nav li.parent.level0 a').each(function()
	{
		if($(this).parent('li').hasClass('parent'))
		{
			$(this).after('<span class="collapsible close">+</span>');
		}
	});
	$('li.active').each(function(){
		if($(this).hasClass('parent'))
		{
			var collap = $(this).children('span.collapsible');
			collap.removeClass('close');
			collap.addClass('open');
			collap.html('-');
			$(this).children('ul').show();
		}
	});

	$('li.parent a').live('mouseover', function()
	{
		$(this).next('span.collapsible').show();
		
	});

	$('li.parent a').live('mouseoout', function()
	{
		$(this).next('span.collapsible').hide();
		
	});
	$('span.collapsible').live('click', function()
	{
		if($(this).hasClass('close'))
		{	
			$(this).removeClass('close');
			$(this).addClass('open');
			$(this).html('-');
			$(this).next('ul').show();
		}
		else
		{
			$(this).removeClass('open');
			$(this).addClass('close');
			$(this).html('+');
			$(this).next('ul').hide();
		}
	});
});
