//animate the opening of the branch (a.grower jQueryElement)
function openBranch(jQueryElement, noAnimation) {
		jQueryElement.addClass('OPEN').removeClass('CLOSE');
		if(noAnimation)
			jQueryElement.find('ul:first').show();
		else
			jQueryElement.find('ul:first').slideDown();
}
//animate the closing of the branch (a.grower jQueryElement)
function closeBranch(jQueryElement, noAnimation) {
	jQueryElement.addClass('CLOSE').removeClass('OPEN');
	if(noAnimation)
		jQueryElement.find('ul:first').hide();
	else
		jQueryElement.find('ul:first').slideUp();
}

//animate the closing or opening of the branch (ul jQueryElement)
function toggleBranch(jQueryElement, noAnimation) {
	if(jQueryElement.hasClass('OPEN'))
		closeBranch(jQueryElement, noAnimation);
	else
		openBranch(jQueryElement, noAnimation);
}


//when the page is loaded...
$(document).ready(function () {
		$('ul.tree li.selected').each( function() {
			//if ($(this).is('li'))
				toggleBranch($(this), true);
		});

	//add a fonction on clicks on growers
	$('ul.tree a.grower').click(function(){
		toggleBranch($(this).parent());
		return false;
	});
	//add a fonction on clicks on fleche
	$('ul.tree.dhtml a.fleche').click(function(){
		toggleBranch($(this).parent().parent().parent());
		return false;
	});


});
