
function fcIconsLIExpand() {

    this.className += " show_menu";

    $root_link = $(this).next();
    if ($(this).parent().parent().parent().hasClass("fancycat-explorer-level-0")) {
        $root_link.css("color", "#00A5E7");
    }
    $sub_menu = $(this).parent().next();
    $sub_menu.show();
}

function fcIconsLICollapse() {

    this.className = this.className.replace(/ show_menu/, "");

    $root_link = $(this).next();
    if ($(this).parent().parent().parent().hasClass("fancycat-explorer-level-0")) {
        $root_link.css("color", "");
    }

    $sub_menu = $(this).parent().next();
    $sub_menu.hide();
}

$.event.add(
  window,
'load',
	function() {
	    $('ul.fancycat-explorer-level-0 li').each(function() {
	        if (!$(this).hasClass("expanded")) {
	            if ($("#" + this.id + " > ul").length > 0) {
	                $("#" + this.id + " > ul").hide();
	                $("#" + this.id + " > a span.im").toggle(fcIconsLIExpand, fcIconsLICollapse);
	            }
	        } else {
	            if ($("#" + this.id + " > ul").length > 0) {
	                $("#" + this.id + " > a span.im").addClass("show_menu");
	                $("#" + this.id + " > a span.im").toggle(fcIconsLICollapse, fcIconsLIExpand);
	            }
	        }
	    }
		);
	}
);

