/*
$Id: func.js,v 1.10 2008/11/06 16:53:56 max Exp $
vim: set ts=2 sw=2 sts=2 et:
*/

function fcTreeExpand() {
	var li_el = $(this).parents("li[id^='c'");
	$("#" + $(li_el).attr("id") + " > ul").show();
	$("#" + $(li_el).attr("id")).removeClass("collapsed").addClass("expanded");
}

function fcTreeCollapse() {
	var li_el = $(this).parents("li[id^='c'");
	$("#" + $(li_el).attr("id") + " > ul").hide();
	$("#" + $(li_el).attr("id")).removeClass("expanded").addClass("collapsed");
}

function fcInit() {
	$('#catrootmenu li').each(function(){
		if (!$(this).hasClass("expanded")) {
			if ($("#"+this.id+" > ul").length > 0) {
				$("#"+this.id+" > ul").hide();
				$("#"+this.id+" > a > .node").toggle(fcTreeExpand, fcTreeCollapse);
			}
		} else {
			if ($("#"+this.id+" > ul").length > 0) {
				$("#"+this.id+" > a > .node").toggle(fcTreeCollapse, fcTreeExpand);
			}
		}
	});
}

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