/**
 * Toggle FAQ
 *
 * Copyright (c) 2008 Tuesday Multimedia, Arjan (www.tuesday.nl)
 * Source: http://homework.nwsnet.de/news/ea21_turn-nested-lists-into-a-collapsible-tree-with-jquery
 * v2 todo http://be.twixt.us/jquery/treeView.php
 */


$(function() {
    // Find list items representing folders and
    // style them accordingly.  Also, turn them
    // into links that can expand/collapse the
    // tree leaf.

    $('#tree li>ul').each(function(i) {
        // Find this list's parent list item.
        var parent_li = $(this).parent('li');

        // Style the list item as folder.
        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('<span/>').find('span').click(function() {
            // Make the anchor toggle the leaf display.
            sub_ul.toggle();
        });
		
        parent_li.append(sub_ul);
    });
	// Hide all lists except the outermost.
	/* $('#tree ul ul').hide(); */

	// Outhermost li click
	/*
	$('#tree>ul>li').click(function(){
		$(this).parent('ul').children('ul').toggle(
			function(){
				$(this).parent('li').addClass('folderopen');
			},
			function(){
				$(this).parent('li').addClass('folderopen');
			}
			
		);
	});	
	// Child li click
	$('#tree ul ul>li').click(function(){
		$(this).parent('ul').children('ul').toggle();
	});*/
});

