//Sitemap Tree 
$(document).ready(function() {
	$('.sitemapcontainer li > ul').each(function(i) { //use the CSS children selector to find lists that have nested lists inside them
        // Go up to the parent list item
        var parent_li = $(this).parent('li');
        // and give it a folder class
        parent_li.addClass('folder');
        // Temporarily remove the list from the
        // parent list item, wrap the remaining
        // text in an anchor, then reattach it.
        var sub_ul = $(this).remove();
        parent_li.wrapInner('<a/>').find('a').click(function() {
            // Make the anchor toggle the leaf display.
            sub_ul.toggle('fast');
			//because this list is made of links, turn those links off for folders
			return false;
        });
        parent_li.append(sub_ul);
    });

	//expand/contract all lists buttons
	$('a.expand').click(function() {
		$('ul ul').show();
	});
	
	$('a.contract').click(function() {
		$('ul ul').hide();
	});
});
