$(document).ready(function(){
	$(".treeMenu ul").hide();
	TM_init($("#sample01"));
	TM_init($("#sample02"), 400, true);
	function TM_init(elem, sp, so){
		if (!sp) sp = 400;
		if (!so) so = false;
		$(">li:has(ul)", elem).each(function() {
			var myTree = this;
			$(">:first-child", myTree).click(function(e){
				var target = this;
				$(">li:has(ul)", elem).each(function(){
					if ($(">:first-child", this).get()[0] == target){
						$(">ul:first", this).slideToggle(sp);
					}else if (so == true){
						$(">ul:first", this).slideUp(sp);
					}
				});
			});
			TM_init($(">ul:first", myTree), sp, so);
		});
	}
});
