function Sitetree() {
	// Main navigation id
	navId = "nav";

	// CSS class names, change if needed
	active = "pde_nav";
	hidden = "pde_hide";
	icon = "pde_icon";

	// Get the nav node 
	root = $("#"+navId);

	// Make sure we got a match
	if (root.length > 0) {
		// Add active flass for CSS
		$(root).addClass(active);

		// Get all LIs containing ULs
		var ulElements = $(root).find("ul");
		liElements = $(ulElements).parent("li");

		// Perform action to each
		$(liElements).each(function(i){
			// Collapse the UL
			$(liElements[i]).addClass(hidden);

			// Create toggle button
			var toggleButton = $('<a href="#"><img src="images/transparent.gif" /></a>');
			$(toggleButton).addClass(icon);

			// Give it an action
			$(toggleButton).click(function(){
				Sitetree.toggle($(this).parent("li"));
				return false;
			});

			// Add it into the begining of the LI
			$(liElements[i]).prepend(toggleButton);

			// Set the alt text
			Sitetree.setAlt(liElements[i]);
		});

		// Open first level
		var firstLevel = $(root).children("."+hidden);
		$(firstLevel).each(function(i){
			Sitetree.toggle(firstLevel[i]);
		});
	}	

};

Sitetree.toggle = function(liElement) {
	$(liElement).toggleClass(hidden);
	
	Sitetree.setAlt(liElement)
}

Sitetree.setAlt = function(liElement) {

	// Get the last link for the alt text
	var links = $(liElement).children("a");
	if (links.length == 1) {
		// It only matched the icon, see if it's inside a H2
		var links = $(liElement).children("h2");
	}
	var linkName = $(links[links.length-1]).text();
	linkName = $.trim(linkName);
	
	// Expand/Collapse based on class
	if ($(liElement).is("."+hidden)) {
		var preText = "Expand ";
	} else {
		var preText = "Collapse ";
	}    
	
	// Set alt text on icon image
	$($($(liElement).children("."+icon)).children("img")).attr("alt", preText+linkName);

}	


$(document).ready(function(){
	Sitetree();
});