
$(document).ready(function() {

	$('UL.sitemap LI').each(function() {
		if ($(this).children('UL').length > 0) {
			var icon = document.createElement('div');
			var closed = $(this).children('UL').css('display') == 'none';
			$(icon).text(closed ? '+' : '–').addClass('node').click(sitemap_toggle_node);
			$(this).prepend(icon);
		} else {
			$(this).addClass('no-children');	
		}
	});
	
});

function sitemap_toggle_node() {
	$(this).text(($(this).text() == '–') ? '+' : '–')
	$(this.parentNode).children('UL').slideToggle();
}

function sitemap_close_all() {
	$('UL.sitemap UL').hide();
	$('UL.sitemap LI').children('.node').text('+');
}

function sitemap_expand_all() {
	$('UL.sitemap UL').show();
	$('UL.sitemap LI').children('.node').text('–');
}
